When booting Hibernate through JPA APIs, it will use CascadingActions.PERSIST_ON_FLUSH for cascading, and CascadingActions.SAVE_UPDATE if booted up through Hibernate native APIs. According to the semantics of JPA, calling persist with a REMOVED entity will result in the entity becoming managed again. See https://jakarta.ee/specifications/persistence/3.1/jakarta-persistence-spec-3.1#persisting-an-entity-instance and https://jakarta.ee/specifications/persistence/3.1/jakarta-persistence-spec-3.1#a1955 I don’t know if the behavior of the saveOrUpdate operation for such a case is documented anywhere, but it seems to me that it always was this way. You wrote that it “worked” in 5.6.7, but I tried that version and it didn’t. Hibernate throws the same exception with that version. So as far as I can tell, this works as designed and the only bug is in your code, because a cascading association refers to an entity that is marked as removed. |