How does pagination work in Spring Data? How is Page different from Slice?
Short answer
Spring Data takes a Pageable (page counted from 0, size, sort) and builds LIMIT/OFFSET. Page adds a COUNT for the total; Slice only knows if a next page exists.
3 points to say:
- Spring Data pages are counted from 0.
- Cap the page size and whitelist sort columns.
- Always end the sort with a unique key such as
id.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.