Creating a repository extending 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 the User type and have an ID field of the Long type.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset