Support Set return types in MongoDB AOT repositories.#5227
Open
maryantocinn wants to merge 1 commit into
Open
Conversation
Closes spring-projects#5225 Signed-off-by: Maryanto <54889592+maryantocinn@users.noreply.github.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.
Summary
Fixes AOT-generated repository implementations for query methods returning
Set<T>.ExecutableFindOperation.TerminatingResults#all()returns aList<T>. Previously, the generated method returned that value directly even when the repository method declared aSet<T>, causing the generated source to fail compilation becauseList<T>cannot be converted toSet<T>.The generated code now uses
DefaultConversionServiceto adapt the result to the declaredSetreturn type. This applies to both entity and projection query results.Related issue
Closes #5225
Test plan
Added a generated-code unit test verifying that
Setreturn types useDefaultConversionService.Added integration tests for derived queries returning sets of entities and projections.
Verified the original reproducer compiles its generated AOT sources against the fixed snapshot.
Ran:
./mvnw -pl spring-data-mongodb -Dtest=MongoRepositoryContributorTests,QueryMethodContributionUnitTests test