JPA vs ORM vs Hibernate?

JavaHibernateJpaOrm

Java Problem Overview


I have read about them through various resources. Importants ones are :-

  1. Wikipedia article about each of them
  2. https://stackoverflow.com/questions/9881611/whats-the-difference-between-jpa-and-hibernate

Here is my understanding about whats the difference b/w them. I am not sure if i am right about JPA vs ORM

  1. ORM: Object Relational Mapping is concept/process of converting the data from Object oriented language to relational DB and vice versa For example in java its done with the help of reflection and jdbc.

  2. Hibernate: Its the implementation of above concept.

  3. JPA: Its the one step above ORM. Its high level API and specification so that different ORM tools can implement so that it provides the flexibility to developer to change the implementation from one ORM to another (for example if application uses the JPA api and implementaion is hibernate. In future it can switch to IBatis if required. But on the other if application directly lock the implementation with Hibernate without JPA platform, switiching is going to be herculean task)

There can be ORM implementation with/without JPA specification.For example as per this link under hibernate section only Hibernate versions 3.2 and later provide an implementation for the Java Persistence API

Java Solutions


Solution 1 - Java

  1. ORM is the approach of taking object-oriented data and mapping to a relational data store (e.g. tables in a RDBMS)

  2. JPA is the Java EE standard specification for ORM in Java EE.

  3. The reference implementation for JPA is EclipseLink. If you don't explictly configure a provider, EclipseLink is used under the covers.

  4. Hibernate is another implementation of the JPA specification, in that you can use the standard JPA APIs and configure your application to use Hibernate as the provider of the spec under the covers.

  5. Hibernate also provides a superset of the ORM features beyond what is specified in the JPA spec. Meaning, that while it provides an implementation of the JPA API, it also provides more features beyond what JPA specifies.

Solution 2 - Java

The only mistake you seemed to make in your understanding is >Its the one step above ORM

One quick note, The libraries starting with javax.persistence are associated with JPA. You should prefer these over Hibernate Libraries whenever possible. Because these are Portable. However, you will get some extra features in Hibernate, and in those precise cases, please feel free to use Hibernate.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionM SachView Question on Stackoverflow
Solution 1 - JavaKevin HookeView Answer on Stackoverflow
Solution 2 - JavaMiguel ÁngelView Answer on Stackoverflow