Skip to content

Fix AOT-generated GreaterThanEqual query to call greaterThanOrEquals - #2374

Open
jejes323 wants to merge 1 commit into
spring-projects:mainfrom
jejes323:fix-gte-aot-codegen
Open

Fix AOT-generated GreaterThanEqual query to call greaterThanOrEquals#2374
jejes323 wants to merge 1 commit into
spring-projects:mainfrom
jejes323:fix-gte-aot-codegen

Conversation

@jejes323

Copy link
Copy Markdown

What

JdbcCodeBlocks#appendCriteria generated Criteria.greaterThanEquals(...) for the GTE comparator, but Criteria only declares greaterThanOrEquals(Object). Any repository method using the GreaterThanEqual derived-query keyword therefore failed to compile once Spring AOT processing was enabled (compileAotJava, bootBuildImage, jib, etc.), while the sibling LessThanEqual keyword worked correctly and generated .lessThanOrEquals(...).

Fixes #2365.

Why

case LTE -> builder.add(".lessThanOrEquals($L)", renderPlaceholder(value));
case GT  -> builder.add(".greaterThan($L)", renderPlaceholder(value));
case GTE -> builder.add(".greaterThanEquals($L)", renderPlaceholder(value)); // missing "Or"

Criteria only exposes greaterThanOrEquals(Object) (no greaterThanEquals), so the generated source referenced a method that doesn't exist:

public List<PaymentEntity> findAllByValueDateGreaterThanEqual(LocalDate from) {
    Criteria criteria = Criteria.where("valueDate").greaterThanEquals(from); // cannot find symbol
    ...
}

The non-AOT runtime path (CriteriaFactory) already maps GREATER_THAN_EQUAL to greaterThanOrEquals correctly, so only the AOT source-generation path in JdbcCodeBlocks had the typo.

Change

One-word fix: .greaterThanEquals($L).greaterThanOrEquals($L).

Tests

Added findAllByAgeGreaterThanEqual and findAllByAgeLessThanEqual to JdbcRepositoryContributorIntegrationTests (and the corresponding derived-query methods to the test UserRepository), asserting the correct result set at the boundary value.

  • Without the fix, findAllByAgeGreaterThanEqual fails to load its ApplicationContext because the AOT-compiled fragment doesn't compile (verified locally by reverting the one-line fix).
  • With the fix, ./mvnw -pl spring-data-jdbc test -Dtest=JdbcRepositoryContributorIntegrationTests passes: 39/39, 0 failures, 0 errors.

JdbcCodeBlocks generated Criteria.greaterThanEquals(...) for the GTE
comparator, but Criteria only declares greaterThanOrEquals(Object).
This made any repository method using the GreaterThanEqual keyword
fail to compile under Spring AOT processing, while the sibling
LessThanEqual keyword worked correctly.

Closes spring-projectsGH-2365

Signed-off-by: leavingisfine <185443765+jejes323@users.noreply.github.com>
@jejes323
jejes323 force-pushed the fix-gte-aot-codegen branch from dfbae21 to 8ff0454 Compare August 31, 2026 05:46
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AOT-generated derived query for GreaterThanEqual calls non-existent Criteria.greaterThanEquals(...) instead of greaterThanOrEquals(...)

2 participants