Skip to content

Support Hibernate @Any annotation in query derivation #3978

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

academey
Copy link

@academey academey commented Aug 16, 2025

Fixes #2318

Added support for Hibernate's @Any annotation in query derivation.

The issue was that @Any properties are not part of JPA metamodel, causing IllegalArgumentException.

This fix uses reflection to detect @Any annotations and handles them appropriately during query creation.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 16, 2025
@academey academey force-pushed the fix/2318-hibernate-any-annotation-support branch 14 times, most recently from ed0bf90 to 487b80c Compare August 16, 2025 15:13
Fixes spring-projects#2318

Added support for Hibernate's @Any annotation in query derivation.
The issue was that @Any properties are not part of JPA metamodel,
causing IllegalArgumentException.

This fix uses reflection to detect @Any annotations and handles
them appropriately during query creation.

Signed-off-by: academey <[email protected]>
@academey academey force-pushed the fix/2318-hibernate-any-annotation-support branch from 487b80c to cece7cd Compare August 16, 2025 17:00
@mp911de mp911de force-pushed the main branch 2 times, most recently from d0913a7 to db92dc0 Compare August 18, 2025 07:11
@mp911de mp911de added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged labels Aug 18, 2025
@mp911de
Copy link
Member

mp911de commented Aug 18, 2025

We don't want to support additional Hibernate-specific model variants as our baseline is JPA. Rather, if Hibernate would report these elements to the metamodel then things would just work. Over time, a lot of Hibernate ideas went into JPA so I suggest working with the Jakarta Persistence spec to get this item into the standard.

Also, we have TypeInformation for property discovery that we use instead of bare reflection, one could also annotate property accessors instead of fields.

@mp911de mp911de closed this Aug 18, 2025
@academey
Copy link
Author

Thank you for the review and feedback. I understand the project's position on vendor-specific features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jpa find with hibernate Any field error.throw
3 participants