Skip to content

Resolve is-prefixed Boolean property paths against the JPA metamodel - #4305

Open
SHEOMM wants to merge 1 commit into
spring-projects:mainfrom
SHEOMM:gh-4303
Open

SHEOMM wants to merge 1 commit into
spring-projects:mainfrom
SHEOMM:gh-4303

Conversation

@SHEOMM

@SHEOMM SHEOMM commented Jul 30, 2026

Copy link
Copy Markdown

Closes #4303

A Kotlin Boolean property named isActive is exposed to Spring Data as isActive, while a JPA property-access mapping derives the metamodel attribute active from the isActive() getter. As a result, findByIsActiveTrue() parses successfully but renders an invalid JPA path.

The parsed segment is now resolved against the JPA metamodel first. If no direct attribute exists, the decapitalized name is used only when the metamodel attribute is read through the same zero-argument boolean or Boolean getter. Direct attributes such as a field-access isActive retain precedence, so this does not introduce general accessor-name aliasing.

The change covers JPQL and Criteria derived-query paths, with regression tests for direct-attribute precedence, nested paths, keyset use, and an unrelated getFoo accessor.

  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

For entities using JPA property access, a Kotlin Boolean property named isActive is exposed by Spring Data as isActive but by the JPA metamodel as active, because property access derives the attribute name from the isActive() getter. Neither findByActiveTrue() nor findByIsActiveTrue() resolves end to end.

Resolve the parsed property path segment against the metamodel first and, only if that fails for an is-prefixed segment, accept the attribute that property access derives from the very same zero-argument boolean getter. Query and Criteria path building then use the resolved attribute names.

Closes spring-projects#4303

Signed-off-by: Seongho Eom <esh0821@snu.ac.kr>
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.

Kotlin is-prefixed Boolean properties fail in derived queries with JPA property access

2 participants