spring-data-jpa Repositories


The Spring Data project allows application programmers to work with data stores using a consistent interface that makes use of an abstraction called Repository. A Spring Data Repository is modeled after the Repository pattern made popular by domain-driven design. Spring Data provides a central Java interface named Repository that subprojects can extend to provide features specific to data stores.

In addition to the Repository interface, Spring Data also provides two more core interfaces - CrudRepository that defines the contract for basic CRUD (create, read, update and delete) functionality; and PagingAndSortingRepository that extends CrudRepository by defining a contract for pagination and sorting.

These three core interfaces (Repository, CrudRepository and PagingAndSortingRepository) ensure that:

  1. Application programmers can access data stores (such as relational databases, document based NoSQL databases, graph databases, etc.) in a consistent way.
  2. It is easy to switch the underlying storage for a domain entity (see domain-driven design) without having to also change the way in which the application interacts with the data store.
  3. Specific implementations can provide features specific to data stores.