liveBook · Manning

JpaRepository

As explained in Spring Start Here, Second Edition

JpaRepository is a Spring Data JPA repository interface that provides persistence operations for Jakarta Persistence API entities.

JpaRepository is a Spring Data repository contract for applications using a JPA implementation, such as Hibernate. Define an application repository interface that extends it to use operations specific to JPA. section 14.2

Choose a repository contract according to the operations and technology your application needs:

  • Use CrudRepository for CRUD operations, or PagingAndSortingRepository when you also need paging and sorting. section 14.2
  • Use JpaRepository when working with Spring Data JPA and needing operations for a JPA implementation. section 14.2

A JPA repository

An application’s AccountRepository can extend JpaRepository when its persistence uses a JPA implementation such as Hibernate. section 14.2

Figure 14.10 Different Spring Data modules might provide other, more particular contracts. For example, if you use an ORM framework such as Hibernate (which implements the JPA) with Spring Data, you can extend the JpaRepository interface, which is a more particular contract that provides operations applicable only when using a JPA implementation, such as Hibernate.

See how JpaRepository fits among Spring Data’s more technology-specific repository contracts. section 14.2

How Spring Start Here, Second Edition covers it

How deep it goes
Defines JpaRepository as more specific than PagingAndSortingRepository but does not detail its individual operations.
Examples
Uses an AccountRepository interface and Hibernate as examples of JPA-specific repository use.
What you can do after
Apply it by defining a Spring Data repository interface that extends JpaRepository for a JPA implementation.
How it connects
Connects JpaRepository to Spring Data, CrudRepository, PagingAndSortingRepository, JPA, and Hibernate.

Also explained in

Compare how 2 books explain JpaRepository →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring Start Here, Second Edition. The section links point to the parts of the book it draws on.