hibernate-orm icon indicating copy to clipboard operation
hibernate-orm copied to clipboard

HHH-19203 Unexpected association fetch triggered by Bean Validation

Open Kamii0909 opened this issue 9 months ago • 3 comments

More details on Hibernate forum.


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-19203

Kamii0909 avatar Feb 26 '25 08:02 Kamii0909

Thanks for your pull request!

This pull request appears to follow the contribution rules.

› This message was automatically generated.

I made adjustments and slight cleaning with the changes from https://github.com/hibernate/hibernate-orm/pull/9806. I noticed formatting of relevant files is kinda off, but I refrained from formatting everything because I want to keep the change set minimum.

PersistenceUnitUtil.isLoaded is a fairly heavy-handed approach. I suppose a better implementation would get the PropertyAccess from EntityPersister instead. I didn't immediately do this because collecting these information upfront would be a lot of memory bloat, since I think for the majority of properties, it will never be lazily initialized without the root object being lazy themself. Collecting them lazily on first use wouldn't have much different with PersistenceUnitUtil.

I am not confident in Hibernate internal that I could detect all possibly lazily initialized properties. Aside from associations, I think we also have lazy basic group, but iirc that requires bytecode enhancement, which is well covered already?

Kamii0909 avatar Mar 31 '25 03:03 Kamii0909

Hey @marko-bekhta would you mind checking if this makes sense, and checking whether there are any unexpected difference with JPATraversableResolver ?

yrodiere avatar Oct 06 '25 09:10 yrodiere