What is JPA (Java persistence API) ?

  • JPA (Java persistence API) is a specification for accessing, persisting and managing data between Java Objects and Relational Database.
  • Technically JPA is just set of interfaces (Specification) and thus require an implementation.
  • It needs ORM(Object Relational Mapping) implementation to work with and persist Java Objects

ORM – what is Object Relational Mapping?

ORM or Object Relational Mapping is a system that implements the responsibility of mapping the Object to Relational Model. That means it is responsible to store Object Model data into Relational Model and further read the data from Relational Model into Object Model.

JPA Implementation

what is java persistence api (jpa)

  • There are several Object Relational Mapping implementations.
    1. Hibernate – Open Source
    2. Top Link – By Oracle
    3. Eclipse Link – Eclipse Persistance Platform
    4. Open JPA – By Apache
    5. MyBatis – Open Source – Formerly known as iBATIS
    6. Many More …
  • Eclipse Link (Eclipse Persistence Platform led by Oracle) Project as the reference implementation for the JPA 2.0 , JSR 317 Standard

Some popular implementations are Hibernate, EclipseLink, and Apache OpenJPA. JPA defines the metadata via annotations in Java classes or via XML configuration files. However, we can use both XML and annotation to describe the metadata.

JPA and Hibernate

Hibernate is the popular and most advanced among all JPA implementations due to Red Hat. Hibernate ORM is one of the most mature JPA implementations, and still a popular option for ORM in Java. It uses its own tweaks and added features that may be used in addition to its JPA implementation. It has a bigger community of users and is well documented. Some of the additional proprietary features are support for multi-tenancy, inheritance, joining entities in queries, timestamp management, Hibernate Search, Hibernate Validator, and Hibernate OGM, which supports domain-model persistence for NoSQL.

More JPA tutorials: