-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
HHH-18489 Lazy, unowned one-to-one associations get loaded eagerly in queries - even with bytecode enhancement #8812
Conversation
…s (and more) in queries
|
||
final Set<String> initializedLazyAttributeNames = interceptor.getInitializedLazyAttributeNames(); | ||
final Set<String> initializedLazyAttributeNames = interceptor.getInitializedLazyAttributeNames(); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note
PersistentAttributeInterceptor.getInitializedLazyAttributeNames
); | ||
if ( set ) { | ||
result = selectedValue; | ||
interceptor.attributeInitialized( fetchGroupAttributeDescriptor.getName() ); |
Check notice
Code scanning / CodeQL
Deprecated method or constructor invocation Note
PersistentAttributeInterceptor.attributeInitialized
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. LGTM as long as this passes the test, but I noticed what could be a bug; see below.
...ain/java/org/hibernate/bytecode/enhance/spi/interceptor/LazyAttributeLoadingInterceptor.java
Outdated
Show resolved
Hide resolved
46c3dbc
to
3f8e726
Compare
… queries - even with bytecode enhancement
@yrodiere I applied your suggestions. What do you think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with that area of the code, but as far as I can tell it makes sense, thank you.
Do you think this can reasonably be backported to 6.6? ("no" is fine by me, I'm just asking)
Thanks! So we would be good to merge, but... s390x tests are failing, which may be caused by this PR since the failures on |
not sure how the changes in this PR may affect the failing test, trying to re-run the job |
lgtm. thanks! |
@dreab8 I think I may have found a regression with lazy loaded one-to-one associations. I was able to see some test failures by running the tests in this PR with I encountered these failures when upgrading to Hibernate 6.6 (coming from 6.5) when trying to load models that had lazy one-to-one relationships defined. Additionally, I noticed that the failures were still happening even when I eager-fetched those relations. The exception I hit my application was hibernate-orm/hibernate-core/src/main/java/org/hibernate/engine/internal/ManagedTypeHelper.java Line 285 in f0f9691
I confirmed that enabling bytecode enhancements fixes the exception in my application when using Hibernate 6.6 Please let me know if you'd like to see this issue created as a ticket |
@sebersole @yrodiere forgot to ping some other members of the Hibernate team on the comment above |
@jimsimon-wk Tests in this PR would be expected to fail if bytecode enhancement is disabled, because lazy-loaded one-to-one associations can only work with bytecode enhancement. Now, lazy-loaded one-to-one associations should not make you application fail if you don't have bytecode enhancement -- these associations should just degrade gracefully into being loaded eagerly. If you can write a reproducer based on https://github.com/hibernate/hibernate-test-case-templates/blob/main/orm/hibernate-orm-6/ where having a lazy-loaded one-to-one association in your model makes Hibernate ORM throw a |
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.
https://hibernate.atlassian.net/browse/HHH-18489