Pagination is the technique of splitting a large result set into smaller, fixed-size pages that can be retrieved one at a time instead of loading everything at once. Spring Data JPA implements this natively through the Pageable interface, which repository methods can accept as a parameter.
A product listing endpoint returning thousands of products would accept a page number and size from the client, use PageRequest.of(page, size) to build a Pageable, and return only that slice of results along with total page count for building a UI pager.
public interface ProductRepository extends JpaRepository<Product, Long> {
}
// In a service or controller
Pageable pageable = PageRequest.of(0, 20, Sort.by("name").ascending());
Page<Product> productPage = productRepository.findAll(pageable);
List<Product> products = productPage.getContent();
int totalPages = productPage.getTotalPages();A concise interview answer is
Pagination breaks a large result set into pages, and in Spring Data JPA I implement it by passing a Pageable, built with PageRequest.of(page, size, sort), into a repository method. The method returns a Page<T> that carries the content plus metadata like total pages and elements, so the database only fetches the rows for that one page instead of the whole table.
Last updated: 11 November 2026
Previous question: What is Query by Example in Spring Data JPA?
Next question: What are some common CrudRepository methods?