JPA vs Hibernate

Hibernate · lesson 2 of 32 · 2 min read

Know which annotations come from the spec and which ones are Hibernate-only extras.

Open this lesson in the learning hub

Key points

  • Jakarta Persistence (JPA) is the specification: interfaces and annotations in jakarta.persistence. It runs nothing by itself.
  • Hibernate ORM is the implementation that does the work. Spring Boot ships it as the default JPA provider.
  • Since Spring Boot 3 and Hibernate 6 the package is jakarta.persistence, not javax.persistence. Older tutorials will not compile.
  • Stay on JPA types (EntityManager, @Entity) for portable code. Drop to Hibernate types (Session, @BatchSize) when the spec has no answer.
  • Spring Data JPA sits one layer higher again: it writes the repository implementation for you, still on top of Hibernate.

JPA is the contract, Hibernate is the engine, Spring Data JPA is the convenience layer.

This is a reading copy. The full lesson — with the visual explainer, the interactive lab and a Run button for the code — lives in the Hibernate course, and every lesson in it is listed on the Hibernate contents page.