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

I found what’s wrong. Contrary to StackOverflow, I need to replace the collection in the setter … if the new collection is the one Hibernate built while fetching from the database. After replacing my setter with

        if(typeConstraints instanceof PersistentList)
            this.typeConstraints = typeConstraints;
        else {
            this.typeConstraints.clear();
            this.typeConstraints.addAll(typeConstraints);
        }

it all runs smoothly.

2 Likes