Closed sven-geisenhainer closed 6 months ago
/cc @geoand (kotlin), @gsmet (hibernate-orm), @yrodiere (hibernate-orm)
Thanks for reporting.
Can this be reproduced without Quarkus, e.g. with https://github.com/hibernate/hibernate-test-case-templates/blob/main/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/QuarkusLikeORMUnitTestCase.java (or a Kotlin equivalent)?
If so, it would be great to take that reproducer directly to the Hibernate ORM Jira: https://hibernate.atlassian.net/
If not, then there's a chance we can do something about it in Quarkus itself.
Yes I can reproduce this using a Kotlin specific Hibernate ORM Unit Test without Quarkus, so obviously this is a Hibernate issue - please forward the issue to the appropriate place - Thanks.
Hibernate reproducer: hibernate-test.zip
Hi @sven-geisenhainer, it would be great if you could open a new issue in Hibernate's tracker attaching your reproducer. Please ensure you're enabling bytecode enhancement (which is on by default in Quarkus) as it's needed to support lazy attribute loading.
Bytecode enhancement was indeed not enabled in my reproducer, but enabling it did not help. I created a ticket in the Hibernate tracker.
Can be closed, issue is caused by using val instead of var when defining entity properties which worked in the past.
Thanks for the update
Describe the bug
With Quarkus 3.7.0 a serious JPA/Hibernate malfunction was introduced when using Kotlin which cannot be observed with 3.6.9, and which also cannot be reproduced using Java code.
The bug has several different symptoms - one is that lazy loading of entity fields does not work anymore - Hibernate will not fetch the fields marked as being lazy at all, even if they get accessed in the code - see the reproducer below.
The bug still exists in current stable release 3.9.1.
Expected behavior
Entity fields marked as being lazy by
@Basic(fetch = FetchType.LAZY)
will get loaded when accessed in the code. With Hibernates SQL logging feature enabled, a log message like this will appear on field access:Actual behavior
Fields marked as being lazy will not get fetched at all, and the above message is not logged.
How to Reproduce?
Use the attached project (requires local Docker daemon for PSQL devservices) and run the contained test (
mvnw test
), it will fail with:org.opentest4j.AssertionFailedError: expected: not <null>
kotlin-test.zip
Output of
uname -a
orver
Darwin MacBook-Pro.local 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:10:42 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6000 arm64
Output of
java -version
openjdk version "21.0.1" 2023-10-17 LTS OpenJDK Runtime Environment Zulu21.30+15-CA (build 21.0.1+12-LTS) OpenJDK 64-Bit Server VM Zulu21.30+15-CA (build 21.0.1+12-LTS, mixed mode, sharing)
Quarkus version or git rev
3.9.1
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)
Additional information
No response