Learn how Spring Data REST maps special URL parameters to Spring Data JPA PagingAndSortingRepository interface methods.
- Another cool built-in feature of both Spring Data JPA…and Spring Data Rest is the the ease of adding…paging and sorting to an API.…So, let's add Paging and Sorting to the Tours API…by extending from Paging and Sorting Crud Repository.…So, we're going to our Tour Repository and we're changing it…to Paging and Sorting Repository,…and we can also add…Paging and Sorting to query methods by updating…the return type to Page and adding the parameter 'Pageable.'…So, on the URL, these are the parameters you would use…for paging and sorting. There is the size parameter…which is the size of the page that you want to retrieve.…
The default for 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 how you want the data sorted.…By default, if you don't provide the Sort parameter,…it will sort by the entity ID…and if you want to give a direction of your sort,…
Released
12/20/2016- Setting up the project
- Building, deploying, and launch the microservice
- Declaring Spring Data JPA repository interfaces
- Invoking repositories
- Using Spring Data query methods
- Exposing RESTful APIs with Spring Data REST
- Using the /search resource to invoke query methods
- Paging and sorting
- Declaring a new REST controller
- Creating HTTP methods for creating, reading, updating and deleting persistent data.
Share this video
Embed this video
Video: Paging and sorting