I'll use my bean names rather than A, B, and C, otherwise I'll just get confused trying to explain this. I have a User bean. It has a 1:N relationship to Phone. User specifies cascade-delete="no". When a User is deleted, its Phones are deleted. The reverse is not true -- deleting a Phone does not delete its User.
* @ejb.relation * name="User-Phone" * role-name="User-has-many-Phones" * cascade-delete="no" */ public abstract Collection getPhones ( ) ; As this is a bi-directional relationships, here's the other side: * @ejb.relation * name="User-Phone" * role-name="Phones-have-a-User" * cascade-delete="yes" */ public abstract UserLocal getUser ( ) ; In another relationship, BuProfile has a unidirectional N:1 relationship to BusinessUnit. The cascade deletion rules are the same as User-Phone: deleting a BusinessUnit deletes its BuProfiles but not the other way around. Here's the relationship from BuProfile: * @ejb.relation * name="BU-BuProfile" * role-name="BuProfiles-have-a-BU" * cascade-delete="yes" * target-ejb="BusinessUnit" * target-role-name="BU-has-many-BuProfiles" * target-cascade-delete="no" * target-multiple="yes" */ public abstract BusinessUnitLocal getBusinessUnit ( ) ; To summarize the semantics, "cascade-delete" means delete THIS bean type (the one containing the tag) when the related bean is deleted. "target-cascade-delete" means delete the RELATED bean type when this bean is deleted. Note that this may seem backwards compared to the semantics of "multiple" and "target-multiple". "multiple" means there are multiple RELATED beans whereas "cascade-delete" means delete THIS bean when the RELATED bean is deleted. Normally the targets of 1:N relationships are cascade-deleted, but as you can see from the example above, you end up with "yes/no" "no/yes" rather than "yes/yes" "no/no". Good luck! David Harkness Sony Pictures Digital Networks (310) 482-4756 -----Original Message----- From: Ionel Gardais [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 15, 2003 11:37 PM To: [EMAIL PROTECTED] Subject: [Xdoclet-user] cascade delete question Hi, Here is my problem : Considere three beans A, B and C. (B and C are two instance of the same kind) B and C knows A but A does not know B or C (unidirectionnal relationship from B/C to A) When A is deleted, B and C should be deleted too *but* when B or C are deleted, A shouldn't be deleted. In the relationship declaration inside B/C, should I put cascade-delete=true or target-cascade-delete=true ? thanks, ionel ------------------------------------------------------- This SF.net email is sponsored by: VM Ware With VMware you can run multiple operating systems on a single machine. WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the same time. Free trial click here: http://www.vmware.com/wl/offer/345/0 _______________________________________________ xdoclet-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-user ------------------------------------------------------- This SF.net email is sponsored by: VM Ware With VMware you can run multiple operating systems on a single machine. WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the same time. Free trial click here: http://www.vmware.com/wl/offer/345/0 _______________________________________________ xdoclet-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-user
