[Design of JBoss jBPM] - Identity module cascading delete of doom
by david.lloyd@jboss.com
In User.hbm.xml, we have this collection:
| <set name="memberships" cascade="all">
| <key column="USER_" />
| <one-to-many class="org.jbpm.identity.Membership" />
| </set>
|
In Group.hbm.xml, the same collection is referenced:
| <set name="memberships" cascade="all">
| <key column="GROUP_" />
| <one-to-many class="org.jbpm.identity.Membership" />
| </set>
|
and Membership.hbm.xml has:
| <many-to-one name="user" column="USER_" cascade="all" foreign-key="FK_ID_MEMSHIP_USR"/>
| <many-to-one name="group" column="GROUP_" cascade="all" foreign-key="FK_ID_MEMSHIP_GRP"/>
|
This is a problem because if you delete a user or a group, it cascades madly through all the users and groups that are related by membership.
I think that the desired behavior would be that if a User is deleted, then all the corresponding memberships should be deleted but NOT the groups. Likewise, if a Group is deleted, the memberships for that Group should also be deleted, but not the Users.
I think (pending some testing) that the way to achieve this is to remove the cascade="all" from the "many-to-one" tags in Membership.
Anyone have any objection or thoughts on this?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4043816#4043816
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4043816
17 years, 9 months