Video in progress

What's the difference between JPA and Hibernate?

JPA (now Jakarta Persistence) is a specification: a set of annotations and interfaces. Hibernate is its most popular implementation, and it adds extra features of its own on top.

📖 Answer

A simple analogy: JPA is a contract, like JDBC, and Hibernate is the driver behind it.

In your code you usually see only JPA types:

import jakarta.persistence.Entity;
import jakarta.persistence.EntityManager;

At runtime, Hibernate's Session, SessionFactory and other classes do the work behind them. In Spring Boot, if you add spring-boot-starter-data-jpa, the default provider is Hibernate.

Hibernate also has things JPA doesn't: @BatchSize, @Formula, @NaturalId, @SoftDelete (6.4+), and its own filters. Once you use them, your code is tied to Hibernate. In practice that's rarely a problem, because almost nobody swaps the provider.

A word on versions: starting with Hibernate 6 and Spring Boot 3, the package is jakarta.persistence, not javax.persistence. If you copy old examples, this is where you get compile errors.