0 Replies Latest reply on Dec 31, 2002 5:08 PM by Brian Benton

    many-to-many and cascade delete

    Brian Benton Newbie

      I am wondering how some of you have implemented strong aggregation semantics (composition) in a many-to-many relationship.

      Ex. A has a many-to-many relationship with B. However, while A can exist without a corresponding B, B cannot exist without an A.

      Hence, when an instance of A is deleted (a1), any relationships between a1 and instances of B are removed from the association table in the database. But I would also want any instances of B that are *only* related to a1 to also be deleted. I am assuming that setting a <cascade-delete> on the B side of the many-to-many relationship would attempt to remove *all* B instances associated with a1 regardless of whether these B instances are also associated with other instances of A or not. Is this assumption correct? In other words, the container is not smart enough to determine whether or not a given B instance is related to instances of A other than a1 and would thus attempt to delete the given B instance.

      Assuming my assumption above is correct, what methods have some of you employed to enforce such strong aggregation semantics in a many-to-many relationship?

      Regards,
      Brian Benton