0

I have worked with Enterpise JavaBeans 3.0. I am new to Hibernate.

I understand that every vendor has to implement the Java Persistence API.

When you write a project and you have the option of Hibernate, should Hibernate only be used, or Java Persistence API or are both used?

I would like your advice.

user1348855
  • 155
  • 1
  • 2
  • 9

1 Answers1

0

I would use Hibernate's JPA implementation. This way you could change JPA implementations and avoid getting locked into Hibernate. As you have stated in your question JPA is just a specification and you must choose an implementation, therefore you have no option but to choose both Hibernate and JPA, if you want to use JPA, unless you choose another implementation. The benefit of using JPA over straight Hibernate is that you can switch the implementation because you are following the specification. I have used the HibernateEntity Manager in combination with JPA and Spring successfully in the past and feel it is pretty straight forward once you have the configuration established. Resources such as tutorials and reference material are widely available for this technology stack. You can get the Hibernate EntityManager via Maven with the dependency below.

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>3.6.0.Final</version>
    </dependency> 

Also search stack for more helpful posts including this one:

What are the differences between Hibernate and JPA?

Community
  • 1
  • 1
Kevin Bowersox
  • 93,289
  • 19
  • 159
  • 189