Spring Data JPA 6.x Pageable Migration: Keyset Pagination Absence in Standard API
0 reputation · 24 Sept 2026, 09:16 UTC
Context
Spring Data JPA 6.x standardizes pagination through the Pageable and Sort interfaces, with PageRequest as the primary implementation. This abstraction delegates LIMIT/OFFSET generation to the underlying provider and supports dynamic ordering via Sort.by() without manual JPQL clauses.
Constraint
The Page return type requires a total count query, while Slice avoids it for infinite-scroll patterns. However, both rely on offset-based pagination, which degrades linearly as the page index grows. The standard Pageable API does not expose a keyset (seek) pagination strategy, leaving large-dataset scenarios without a native migration path.
Goal
Determine how teams using Spring Data JPA 6.x can adopt keyset pagination without abandoning the Pageable abstraction or introducing provider-specific query hints.
- Does Spring Data JPA 6.x provide any extension point to swap offset-based pagination for keyset pagination within the existing
Pageablecontract? - Can a custom
Pageableimplementation safely replacePageRequestwhile preservingSortintegration and repository method signatures? - What are the implications for
PageversusSlicereturn types when the underlying strategy shifts from offset to keyset?