The question in my thread is: can only the owning side of a relation invoke propgation of PERSIST, MERGE, REFRESH?
I have a self-referencing class "Competency". Each competency can have child competencies and it can be itself a child competency of some other parent competency. A "composes" field holds a competency list of all child competencies. @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH}) @JoinTable(name = "competency_composition") public List<Competency> getComposes() { return composes; } The inverse is stored in the field "composedBy" which is also a list of type competency. This also means that I use a bidirectional relationship. @ManyToMany( mappedBy = "composes", cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH}) public List<Competency> getComposedBy() { return composedBy; } As you can see for cascading I use all types except for REMOVE. The reason is, I just want to detach a competency from its relations to other competencies without removing them. To remove a competency I though I could just do the following: a) set "composes" and "composedBy" to null b) save the competency to propagate the deletion of relations in the database c) remove the competency from the database (wiithout touching other competencies) by its DAO It turns out that testing this in a DAO won't produce any error nor any ConstraintViolationException if the removed competency has actually parent competencies. While step b) removes the competency from the database, the setting of "composedBy" to null (or even to composedBy.clear()) is not propagated to the parent competencies' "composes" field. Well, actually it is to some extent: The reference to the deleted competency is set to Null, but this Null object is not removed from the "composes" list. Instead, to remove a competency properly, I have to a) set "composes" to null b) iterate through the "composedBy" list and remove the competency from all its parent competency's "composes" list. c) save the parent competency by the DAO c) remove the actual competency by the DAO. So, is this the expected and correct behaviour? Would be glad, if someone has an answer to this. Or some pointer to further reading resources. Thanks, Martin -- View this message in context: http://www.nabble.com/Cascading%3A-I-need-your-confirmation-tf4593036s2369.html#a13112180 Sent from the AppFuse - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]