Hello everyone,
I’ve encountered an issue after upgrading to Hibernate 6.6.9.Final from 6.4.10.Final related to the behavior of orphanRemoval = true
when combined with FetchType.LAZY
.
Issue Description
In previous Hibernate versions, if I had a lazily-loaded collection with orphanRemoval = true
and saved the parent entity without explicitly initializing the collection, Hibernate would not attempt to delete any orphans—unless the collection was explicitly modified.
However, after updating to 6.6.9.Final, it seems that Hibernate attempts to remove orphans, even if the lazy collection was never loaded or accessed. This behavior is unexpected and leads to incorrect deletions.
Questions
- Is this a known behavior change in Hibernate 6.6.X.Final?
- Is there any official documentation explaining this change?
- Are there recommended approaches to handle this situation without explicitly initializing every lazy collection?
- Is this expected behavior or is it considered a bug?