In Java and the Spring Framework, a Spring Data repository is a high-level abstraction that provides a mechanism for encapsulating storage, retrieval, and search behavior that is specific to a particular data source, such as a relational database
The most basic repository is JpaRepository
JpaRepository
extends PagingAndSortingRepository
which in turn extends CrudRepository
.
Their main functions are:
CrudRepository
mainly provides CRUD functions.PagingAndSortingRepository
provides methods to do pagination and sorting records.JpaRepository
provides some JPA-related methods such as flushing the persistence context and deleting records in a batch.