Menu

Hibernate, JPA and Jakarta Persistence

Hibernate, JPA and Jakarta Persistence

Specification and Implementation

JPA originally stood for Java Persistence API. It is a specification, meaning it defines annotations, interfaces, and rules for ORM in Java, but it does not include working code to talk to a database.

Hibernate implements that specification. Other implementations exist, such as EclipseLink, but Hibernate is the most widely used.

From JPA to Jakarta Persistence

When Java EE moved to the Eclipse Foundation, it was renamed Jakarta EE, and JPA became Jakarta Persistence. The base package changed along with the name.

Version

Package

Hibernate

JPA 2.2 and earlierjavax.persistence5.x and earlier
Jakarta Persistence 3.0 and laterjakarta.persistence6.x and later

Hibernate 7 implements Jakarta Persistence 3.2. Older tutorials that import javax.persistence will not compile against it, so the imports must be changed to jakarta.persistence.

Two Ways to Use Hibernate

You can use Hibernate through the standard API or its own native API. The native API extends the standard one, so it offers everything the standard one does and more.

  • EntityManagerFactory and EntityManager belong to Jakarta Persistence.
  • SessionFactory and Session belong to Hibernate and extend the interfaces above.

This handbook uses the native Session API where Hibernate-specific features are useful, and mentions the standard equivalent where one exists. Code written only with the standard API can move more easily to another JPA provider.


Hibernate Tutorial

AP

Abhishek Pati



Learn via Video Course

Java Programming ( Telugu) Logo

Java Programming ( Telugu)

11 hrs



Get in Touch For Details