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
KeysetAwarePagetype is lost for JPA Query MethodsDescription
For JPA Query Methods, Spring Data
AbstractJpaQueryapplies aResultProcessorfor slice/page-like return types, using:(T) ((Slice<?>) source).map(converter::convert)If
sourceisKeysetAwarePageImpl, mapping currently goes through inheritedPageImpl#map(...), which returns a plainPageImplinstance.This loses keyset-aware type information (
PageImplinstead ofKeysetAwarePageImpl).Observed behavior
Later, proxy/interceptor code paths expecting
KeysetAwarePagefail with:java.lang.ClassCastException: class org.springframework.data.domain.PageImpl cannot be cast to class com.blazebit.persistence.spring.data.repository.KeysetAwarePageExpected behavior
Mapped results should preserve keyset-aware page type/metadata so downstream processing that expects
KeysetAwarePageremains valid.Root cause
KeysetAwarePageImplinheritsPageImpl#map(...), which re-materializes mapped content asPageImpl, dropping the concrete keyset-aware type.Proposed fix
Override
map(...)inKeysetAwarePageImplto returnKeysetAwarePageImplwhile preserving: