Reproducible with attached test case. We have two entities in our domain model which are related similar to the TreeNode and ReferencedEntity classes.
TreeNodes have a reference to their parents and a set of references to some ReferencedEntities. In our production code we have several custom validations that access the someSet property of TreeNode. After upgrading to Hibernate 6.2.2.Final (from Version 5.6.14.Final) these validations failed when deleting TreeNode entities (through the deleteAll method of a CrudRepository). The stack trace was similar to the one generated by the attached test case:
By debugging the (hibnerate) code we found that a UpdateEntityAction was generated on flush because the parent property was different. As far as we could see, this happened because parent was set to null in the DefaultDeleteEventListener using ForeignKeys.Nullifier. The test case simulates the validation using a PreUpdateEventListener that accesses the someSet property. |