W3schools | Tutorialspoint | JavaTpoint

Just another WordPress site

JPA tutorial

JPA tutorial – Java Persistence API tutorial for beginners with examples online on basic, Architecture, ORM Components, Entity Managers, JPQL, Advanced Mappings, Entity Relationships, Criteria API and more.

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.

Important points:

    1. 1. JPA provides the facility to map, store, update and retrieve data from relational databases to Java objects and vice versa.

 

    1. 2. JPA implementation is typically called persistence provider.

 

    1. 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.

JPA tutorial:

Content Protection by DMCA.com
Scroll to top