Add PageableItemReader - #5477
Open
scordio wants to merge 1 commit into
Open
Conversation
Signed-off-by: Stefano Cordio <stefano.cordio@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds
PageableItemReader, a type-safeRepositoryItemReaderalternative that uses aFunction<Pageable, Slice<?>>instead of the reflection-based strategy for query invocation.PageableItemReaderis deliberately designed afterRepositoryItemReaderin its paging, restart, and locking behavior. However, it favors constructor parameters instead of setters for mandatory configuration.In addition, compared to
RepositoryItemReader, there are two improvements:org.springframework.data.domain.Sortat construction time instead of insidedoPageRead()volatilefield modifiers were redundant with the existingReentrantLockSuch improvements could also be applied to
RepositoryItemReader, but I preferred keeping this PR focused on the new class. Please let me know ifRepositoryItemReadershould get the same; I'll be happy to raise a separate PR for it.Please note that I preferred introducing a dedicated reader rather than enhancing
RepositoryItemReaderto support both use cases (following the rationale at #4484 (comment)). However, in case enhancingRepositoryItemReaderwould be preferred, let me know and I'll take care of the changes.Open Points
There are at least two more things to do:
PageableItemReaderto the documentationRepositoryItemReaderin favor ofPageableItemReader?However, before starting, I'd like a preliminary feedback to make sure I'm going in the right direction.