orphanRemoval = true
and
FetchType.LAZY
in Hibernate 6.6.X:
Title: Issue with
orphanRemoval = true
and
FetchType.LAZY
in Hibernate 6.6.X
Body:
I'm encountering an issue while using Hibernate 6.6.X with
orphanRemoval = true
in combination with
FetchType.LAZY
.
I have a parent entity that has a one-to-many relationship with child entities. I've configured the relationship as follows:
@Entity
public class Parent {
@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
private Set<Child> children = new HashSet<>();
}
When I try to remove a child entity from the collection of children in the parent entity, it does not seem to get removed properly if the parent entity is loaded lazily. I suspect that it might be related to the way Hibernate handles the lazy loading of collections in conjunction with orphan removal.
Has anyone experienced this issue with
orphanRemoval = true
and
FetchType.LAZY
in Hibernate 6.6.X?
What would be the best approach to ensure that orphaned entities are removed correctly when using lazy loading?
Is there a known workaround or solution to this problem?
Any insights or suggestions would be greatly appreciated!
Feel free to modify any part of the question to better fit your situation or style!