Core Concepts
学习 Spring Data JPA 的核心概念
最后更新于
学习 Spring Data JPA 的核心概念
最后更新于
The central interface in the Spring Data repository abstraction is Repository
. It takes the domain class to manage as well as the ID type of the domain class as type arguments. This interface acts primarily as a marker interface to capture the types to work with and to help you to discover interfaces that extend this one. The CrudRepository
interface provides sophisticated CRUD functionality for the entity class that is being managed.
Repository
提供最基本的支持,不包含任何预定义方法。
CrudRepository
预定义了基本的 CRUD 方法。
PagingAndSortingRepository
预定义了分页和排序的功能。
QueryByExampleExecutor
使得继承了该接口的 Repository 具有 Query by Example 的功能。
派生关系如下:
所以,如果没有特殊需求,想要方便地使用 Spring Data JPA 提供的最多功能,使用 JpaRepository
即可。