Open DeKoxD opened 1 month ago
/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.
Anyway, it is breaking using Quarkus but it is not when using Hibernate only.
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 @GeneratedValue
to BaseEntity#id
(and adjusting test setup/cleanup as well as ID expectations) leads to identical result the Hibernate-only reproducer.
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~1710198088~22.04~1a3dbc7 SMP PREEMPT_DYNAMIC Mon M x86_64 x86_64 x86_64 GNU/Linux
Output 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 aEntitySelectFetchByUniqueKeyInitializer
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.