Home  >  Forum  >  Spring
Post New Query

Difference between Spring JPA and Hibernate

joined on
August 12,2015
Asked on November 24,2015
What is difference between JPA and Hibernate and if I am working with Spring, which one is better using Spring with JPA or Spring with Hibernate.
joined on
October 10,2013
Replied on November 24,2015

JPA is Java Persistence API and Hibernate is JPA provider. JPA has only java interfaces but not its implementations whereas Hibernate has implementations of those interfaces. Suppose we have JPA interface as given below.
interface JPAManageData {
void save();
void delete();
void select();
But without implementation of this interface, we cannot achieve anything. Now here comes the role of JPA provider. There are different JPA providers such as Toplink, OpenJPA, Eclipselink and Hibernate. So without using JPA provider, we cannot use JPA. If we choose Hibernate as JPA provider, then we use the JPA specification implemented by Hibernate. Hibernate may implement JPA interface as follows.
class JPAManageData {
void save() {
void delete() {
void select() {

Spring JPA

If we use Spring JPA with Hibernate, then we use all method signatures provided by JPA specification and Hibernate will provide implementations of those methods. Tomorrow if we want to change JPA provider then it is only the matter of configuration change.
If we use Spring with Hibernate, then we will use methods provided by Hibernate specific to it and then later we cannot change our ORM. So using Spring with JPA has advantage over flexibility of changing JPA provider because of some performance reason.

Now find the URL for Spring with JPA using Hibernate JPA provider
Spring 4 MVC + JPA 2 + Hibernate + MySQL Integration Example

URL for Spring with Hibernate
Spring 4 + Hibernate 4 + Gradle Integration Example using Annotation

Write Answer


Copyright ©2017 concretepage.com, all rights reserved |Privacy Policy | Contact Us