Emit Sort.Order separator before non-first orders in AOT generation - #2381
Closed
atirna wants to merge 1 commit into
Closed
Emit Sort.Order separator before non-first orders in AOT generation#2381atirna wants to merge 1 commit into
atirna wants to merge 1 commit into
Conversation
Derived query methods with two or more static OrderBy properties produced invalid Java from JdbcCodeBlocks.buildSort: the separator was appended after each non-first order, so Sort.by(order1 order2, ) failed to compile in compileAotJava. Emit the separator before each non-first order instead. Fixes spring-projects#2377 Signed-off-by: Atirna <288419661+atirna@users.noreply.github.com>
schauder
added a commit
that referenced
this pull request
Sep 10, 2026
Derived query methods with two or more static OrderBy properties produced invalid Java from JdbcCodeBlocks.buildSort: the separator was appended after each non-first order. Emit the separator before each non-first order instead. Closes #2377 Signed-off-by: Atirna <288419661+atirna@users.noreply.github.com> Original pull request #2381
schauder
added a commit
that referenced
this pull request
Sep 10, 2026
Derived query methods with two or more static OrderBy properties produced invalid Java from JdbcCodeBlocks.buildSort: the separator was appended after each non-first order. Emit the separator before each non-first order instead. Closes #2377 Signed-off-by: Atirna <288419661+atirna@users.noreply.github.com> Original pull request #2381
Contributor
|
Thanks, for the PR. That's fixed. |
schauder
added a commit
that referenced
this pull request
Sep 10, 2026
Derived query methods with two or more static OrderBy properties produced invalid Java from JdbcCodeBlocks.buildSort: the separator was appended after each non-first order. Emit the separator before each non-first order instead. Closes #2377 Signed-off-by: Atirna <288419661+atirna@users.noreply.github.com> Original pull request #2381
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.
Derived query methods with two or more static
OrderByproperties produce Java from the AOT generator that does not compile, socompileAotJavafails and the app cannot build in AOT / GraalVM native mode.Why
JdbcCodeBlocks.buildSortappended the,separator after each non-first order instead of before, sofindAllByOrderByFirstNameAscLastNameDesc()generated:which javac rejects with
')' or ',' expected. With one static OrderBy property the loop happened to work because the trailing separator landed after the last (only) order, masking the bug. The separator now goes before each non-first order:Single-order emission is unchanged (
findTop5ByOrderByAgeand its test cover that).Verification
main:./mvnw -pl spring-data-jdbc verify -Dit.test=JdbcRepositoryContributorIntegrationTests -Dspring.profiles.active=h2: context load fails withCompilationException: Unable to compile sourceon the malformedSort.by(...)Tests run: 38, Failures: 0, Errors: 0listWithMultipleStaticOrderByPropertiesinserts a duplicate firstname so the second order key decides the row order, and asserts both keys' effect on the resultFixes #2377