Skip to content

Keyset pagination in a repository interface #3806

@yakom

Description

@yakom

hello,

i scoured the documentation and even used LLMs to search for an answer (sick!), but i found nothing.

the main point is - i'm trying to implement keyset pagination. is it possible to define such a repository interface method?

List<Entity> findAllBy(Specification<Entity> specification, Sort sort, Limit limit);

the where condition is in the specification, ordering and limiting need to go along. i don't want to use Pageable in order not to have the extra count query executed, since that defeats the point. and if it's true that Limit is converted to Pageable under the hood, then it's not the way to go anyway.

another option would be perhaps dynamic limit value, but from what i see it's not possible as well?

is there a way to implement proper keyset pagination with Spring Data that i don't see, aside from implementing a custom repository?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions