Sobes.tech
Senior

What is the difference between Hibernate and JPA?

sobes.tech AI

Answer from AI

Hibernate is a full-featured ORM (Object-Relational Mapping) library for Java that implements the JPA (Java Persistence API) specification and also provides additional features and extensions.

JPA is a standard API for persistence in Java, defined as a specification. It describes a set of interfaces and annotations for managing object-relational mapping but does not contain its own implementation.

Main differences:

  • JPA is a specification (interfaces and annotations) that sets the rules and contract for ORM.
  • Hibernate is one of the implementations of JPA, as well as an extended ORM library with additional capabilities beyond JPA.

Example: you can use the JPA API in your code, and under the hood, use Hibernate as a provider. Hibernate also allows using its own extensions, such as additional data types, second-level caching, specific queries, etc.