Skip to main content

Java Persistence APIs

These are the APIs and rules set by the framework. You can use them in any Java app. They work with any database.

  • They define how database data maps to and from Java objects.
  • They give APIs to act on the database.

ORM - Object-Relational Mapping​

ORM makes database work simpler. It adds a layer that maps objects to database tables. You can use one language across the whole app.

Hibernate and Eclipselink are ORM libraries. Both follow the JPA rules.

Spring Data​

Spring Data doesn't follow the JPA rules on its own. Instead, it wraps them. This saves you from writing boiler plate code for basic CRUD methods.

You make a repository by extending two interfaces. They're JpaRepository and JpaSpecificationExecutor. Spring then adds all the queries at compile time.

Repository Interfaces

A repository interface is one good example. It builds many methods for you.

jpa-orm