hibernate-orm
hibernate-orm copied to clipboard
HHH-19203 Unexpected association fetch triggered by Bean Validation
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
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?
Hey @marko-bekhta would you mind checking if this makes sense, and checking whether there are any unexpected difference with JPATraversableResolver ?