Specification: a detailed description of the design.
What is ORM?
ORM refers to the Object-Relational Mapping. It is a programming technique for converting data between incompatible type systems like relational databases and object oriented programming languages like java.
What is JPA?
JPA refers to Java Persistence API. JPA is just a specification and several implementations are available like Hibernate, EclipseLink and Apache OpenJPA. The reference implementation of JPA is EclipseLink.
JPA is like an interface which provides a set of rules and guidelines that must be followed by its implementation. It is the JPA implementation which will provide the under the hood functionality.
For example when we use Hibernate with JPA we are actually using the Hibernate JPA implementation. The benefit of this is that we can swap out Hibernate’s implementation of JPA for another implementation of the JPA specification. When you use straight Hibernate you are locking into the implementation because other ORMs may use different methods or configurations and annotations, therefore we cannot just switch over to another ORM.
- 1. JPA provides the facility to map, store, update and retrieve data from relational databases to Java objects and vice versa.
2. JPA implementation is typically called persistence provider.
3. JPA use the persistence metadata for defining the mapping between Java objects and database tables.
4. JPA defines the persistence metadata by using annotations or XML or a combination of both. If both annotations and XML are used to define the persistence metadata for an entity then XML configuration overwrites the annotations configuration.