Your likely problem
Looks like you have a Parent entity and a Child entity. The Parent
has a collection of Child entities with cascade=”all-delete-orphan”.
You are setting a new collection via the
setter thus leaving the original collection unreferenced by the Parent
entity. This doesn’t fly well with Hibernate and leaves it confused
about what to do.
parent.setChilden(new HashSet<Child>()); // This won’t work. Could be an ArrayList too.
parent.getChildren().clear(); // There, fixed that!
So generally speaking, just clear out the old collection, rather than dereferencing it and creating a new one.
orphanRemoval=true, cascade=CascadeType.ALL