-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
NPE when fetching entity containing OneToOne property joined by multiple columns from the non-owning side #41700
Comments
/cc @geoand (kotlin) |
cc @yrodiere |
Hi, Do you have any reason to believe this problem is caused by Quarkus itself? If not, could you please create a reproducer based on https://github.com/hibernate/hibernate-test-case-templates/blob/main/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/QuarkusLikeORMUnitTestCase.java, and report this on the Hibernate JIRA (unless it's already fixed in Hibernate ORM 6.6.0.CR1)? Thank you. |
I am not certain if it is or is not caused by Quarkus, so I generated two projects and added tests finding EntityA (non-owning) and EntityB (owning) separately:
Actually, I was going back testing some older Quarkus versions down to 3.7.4 and this error still happens, so I am not sure why I am only seeing it now. Anyway, it is breaking using Quarkus but it is not when using Hibernate only. Thanks |
Thanks for the reproducers.
There's a difference between your Quarkus reproducer and the Hibernate-only reproducer: you're not using generated IDs on the Hibernate-only reproducer. Adding So... this problem does indeed stem from a bug in Hibernate ORM. |
Reported upstream as https://hibernate.atlassian.net/browse/HHH-18390 |
Describe the bug
I started after I updated my project from Quarkus 3.8.5 to 3.12.0 (and .1), but this error also happens on 3.11.x.
Every entity with a property mapped by
OneToOne
using@JoinColumns
started failing to load from the non-owning side (themappedBy
side).Example Entity A:
Example Entity B:
Example:
Expected behavior
No response
Actual behavior
I get the following error:
How to Reproduce?
No response
Output of
uname -a
orver
Linux pop-os 6.8.0-76060800daily20240311-generic #202403110203
171019808822.04~1a3dbc7 SMP PREEMPT_DYNAMIC Mon M x86_64 x86_64 x86_64 GNU/LinuxOutput of
java -version
openjdk version "21.0.2" 2024-01-16 LTS OpenJDK Runtime Environment Temurin-21.0.2+13 (build 21.0.2+13-LTS) OpenJDK 64-Bit Server VM Temurin-21.0.2+13 (build 21.0.2+13-LTS, mixed mode, sharing)
Quarkus version or git rev
3.12.0
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)
Additional information
As far as I dived in, I can see when it loads EntityA, it initializes its relations (
EntitySelectFetchInitializer::initializeInstance
). It tries to generate a key (EntityUniqueKey
) for the inverse relation by passing a blank instance of the entity (EntityA<null>
), where it tries to generate a hashCode (EntityUniqueKey::hashCode
) from the null id.Also, it now creates a
EntitySelectFetchByUniqueKeyInitializer
instead of aEntityDelayedFetchInitializer
like before for entityA (seeInitializersList
).If I have both
@OneToOne
with@JoinColumns
on both sides (EntityA
andEntityB
), the error does not happen.The text was updated successfully, but these errors were encountered: