I am going to work on a spring-hibernate enterprise project. When integrating spring with hibernate should i be using JPA or Hibernate for ex: should i configure JPA's entity manager factory or hibernate's session factory in my spring context file?
What are the pros and cons of both the approaches?
- JPA is standard that mean you can write the code and it will run on any JavaEE compliant server. If you are on JBoss, hibernate is the JPA provider and on Glassfish Toplink is the JPA provider.
- Hibernate provides support for JPA and has some extended features. The extended feature will tie you to hibernate but this is fine as along as you get value out of it. Do not play vendor independence beyond it is required.
- If you are using Tomcat which is a plain servlet engine, than you might want to go with hibernate.
A good idea is to start with JPA and see if that serves your purpose. It will be a matter of time that most of the feature will become pare of Hibernate.