O'Reilly logo

Spring Data by Petri Kainulainen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Paginating query results

Paginating query results is a very common requirement for practically every application that presents some kind of data. The key component of the pagination support of Spring Data JPA is the Pageable interface that declares the following methods:

Method

Description

int getPageNumber()

Returns the number of the requested page. The page numbers are zero indexed. Thus, the number of the first page is zero.

int getPageSize()

Returns the number of elements shown on a single page. The page size must always be larger than zero.

int getOffset()

Returns the selected offset according to the given page number and page size.

Sort getSort()

Returns the sorting parameters used to sort the query results.

We can use ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required