Skip to content

KeysetAwarePage type is lost for JPA Query Methods #2106

@mj-p

Description

@mj-p

KeysetAwarePage type is lost for JPA Query Methods

Description

For JPA Query Methods, Spring Data AbstractJpaQuery applies a ResultProcessor for slice/page-like return types, using:

(T) ((Slice<?>) source).map(converter::convert)

If source is KeysetAwarePageImpl, mapping currently goes through inherited PageImpl#map(...), which returns a plain PageImpl instance.

This loses keyset-aware type information (PageImpl instead of KeysetAwarePageImpl).

Observed behavior

Later, proxy/interceptor code paths expecting KeysetAwarePage fail with:

java.lang.ClassCastException: class org.springframework.data.domain.PageImpl cannot be cast to class com.blazebit.persistence.spring.data.repository.KeysetAwarePage

Expected behavior

Mapped results should preserve keyset-aware page type/metadata so downstream processing that expects KeysetAwarePage remains valid.

Root cause

KeysetAwarePageImpl inherits PageImpl#map(...), which re-materializes mapped content as PageImpl, dropping the concrete keyset-aware type.

Proposed fix

Override map(...) in KeysetAwarePageImpl to return KeysetAwarePageImpl while preserving:

  • keyset page metadata
  • pageable/keyset pageable semantics
  • total elements

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions