From the course: Creating Your First Spring Boot Microservice

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Paging and sorting

Paging and sorting

From the course: Creating Your First Spring Boot Microservice

Start my 1-month free trial

Paging and sorting

- [Instructor] Another cool built in feature of both Spring Data JPA and Spring Data REST is the ease of adding paging and sorting to a repository and an API. We add paging and sorting to the tours API by extending the tour repository from paging and sorting repository. So on the URL, these are the parameters you would use for paging and sorting. There is a size parameter, which takes the size of the page that you want to retrieve. The default of that is 20 if you don't provide it. The page parameter is the page number you want to fetch so that there are several pages, which one do you want, where zero is the first, and the default, if you don't provide it, is zero. Sort is the order of your search results. By default, if you do not provide the sort parameter, it will sort by the entity ID. And if you want to give a direction of your sort, you can optionally put in A-S-C for ascending or D-E-S-C for descending. So let's…

Contents