Hibernate – A collection with cascade=”all-delete-orphan” was no longer referenced by the owning entity instance

I’m having the following issue when trying to update my entity:

"A collection with cascade=”all-delete-orphan” was no longer referenced by the owning entity instance".

I have a parent entity and it has a Set<...> of some children entities. When I try to update it, I get all the references to be set to this collections and set it.

The following code represents my mapping:

@OneToMany(mappedBy = "parentEntity", fetch = FetchType.EAGER)
@Cascade({ CascadeType.ALL, CascadeType.DELETE_ORPHAN })
public Set<ChildEntity> getChildren() {
    return this.children;
}

I’ve tried to clean the Set<..> only, according to this: How to “possible” solve the problem but it didn’t work.

If you have any ideas, please let me know.

Thanks!

30 Answers
30

Leave a Comment