V
V
VasilievAleksey2014-07-16 09:30:39
Java
VasilievAleksey, 2014-07-16 09:30:39

JPA and Hibernate or Hibernate?

I started studying ORM, read a little theory, realized that you can work with hibernate through JPA or separately from it, in fact, how would it be better ?! I'm not going to switch from Hibernate in the future application, besides this, are there any other advantages of JPA? Actually, before that, I worked with entities through JPA

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Smirnov, 2014-07-24
@VasilievAleksey

JPA is an interface to the JAVA language and has no implementation in the language itself. If you just add JPA annotations to your classes, then absolutely nothing will happen. In order for the annotations to start "working", you should deploy and configure a framework in the project that will "find" all classes with JPA annotations and "join" them with the DBMS entities. Your framework is Hibernate.
Regarding " you can work with hibernate through JPA or separately from it " - this is mainly a matter of taste. You have two options to tell Hibernate which classes to "map" onto the database tables:
1. Add JPA annotations to the classes
2. Create XML files that describe the mapping of classes to database objects.
In terms of available functionality, both methods are equal, while JPA annotations are more modern. I would recommend JPA, because when you open the class, you will immediately see that it is "mapped", and in the case of using XML, the "mapped" class is visually indistinguishable from other classes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question