The PagingAndSortingRepository interface

PagingAndSortingRepository extends CrudRepository and provides methods in order to retrieve entities with pagination and a specified sort mechanism. Take a look at the following example:

    public interface UserRepository     extends PagingAndSortingRepository<User, Long> {      }

Important things to note are as follows:

  • public interface UserRepository extends PagingAndSortingRepository : The UserRepository interface extends the PagingAndSortingRepository interface
  • <User, Long>: Entities are of type User and have an ID field of type Long

Get Mastering Spring 5.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.