JPA vs ORM vs Hibernate?
I have read about them through various resources. Importants ones are :-
- Wikipedia article about each of them
- What's 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
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.
Hibernate: Its the implementation of above concept.
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
Solution 1:
-
ORM is the approach of taking object-oriented data and mapping to a relational data store (e.g. tables in a RDBMS)
-
JPA is the Java EE standard specification for ORM in Java EE.
-
The reference implementation for JPA is EclipseLink. If you don't explictly configure a provider, EclipseLink is used under the covers.
-
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.
-
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:
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.