I encountered this exception message as well. For me the problem was different. I wanted to delete a parent.
In one transaction:
It turns out that I had to do two separate transactions. I committed after referencing the field in the child. Then started a new commit for the delete.
There was no need to delete the child elements or empty the collections in the parent (assuming orphanRemoval = true
.). In fact, this didn't work.
In sum, this error appears if you have a reference to a field in a child object when that object is being deleted.