It is disastrous that in one case an exception is thrown and in the other case not, even though it is the same semantics. This is simply a bad quality of the software. It is your decision to reopen the bug and thus improve the quality of the software.
These statements are absurd. This question is: what to do with an object that has been explicitly marked for removal, and is thus in the transient state, but has not been dereferenced by an association which is mapped CascadeType.PERSIST. This is an admitted corner case, where the “correct” behavior is at least a bit unclear. However, the simplest and most consistent interpretation is that, since {{CascadeType.PERSIST}}means: move a referenced transient instance to the persistent state, the instance should be made (again) persistent at flush-time. And so that’s what Hibernate does when operating in JPA-compliant mode. This is completely fine, as far as I’m concerned. What we could consider doing is aligning the behavior in native bootstrap mode with the behavior just described, and I think there’s a somewhat good argument for doing that. (But that’s the exact opposite of what you’re asking for.) |