pagination: Spring Data JPA Page vs Slice vs keyset Window scrolling, with the SQL and REST shapes

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b4bLvQVbZweAqqf54x
This commit is contained in:
Claude
2026-11-16 11:13:56 +05:30
parent e3d1b550ae
commit 91938727f2
42 changed files with 1446 additions and 0 deletions
@@ -0,0 +1,11 @@
Spring Data JPA: 4.1.2
# one fresh context, one repository method: findFirst10ByCategoryOrderByIdAsc("books", position)
1. keyset, initial -> book-1..book-10
2. keyset, after book-10 -> book-11..book-20
3. offset, initial -> book-1..book-10
4. offset, after row 10 -> book-11..book-20
5. keyset, after book-10 again -> book-1..book-10 (step 2 returned book-11..book-20)
statement for step 5: select p1_0.id,p1_0.category,p1_0.name,p1_0.price from product p1_0 where p1_0.category=? order by p1_0.id fetch first ? rows only
# a different method, findFirst5ByCategoryOrderByIdDesc, after the offset calls above
keyset initial -> book-25..book-21, keyset after book-21 -> book-20..book-16