1 Reply Latest reply on Dec 1, 2003 4:59 PM by John Anderson

    Understanding cascade-delete

    John Anderson Newbie

      I'm currently working on the 2nd Installment of Hightower's CMP tutorial from DeveloperWorks. I've slightly modified the examples presented to use Servlet's as clients instead of the command based utility.

      Here is the problem I'm running into.

      The example uses CMR to set up a bidirectional One to One relationship. This relationship should map UserInfo to UserContact. The UserInfo object holds an email String and a password String. The UserContact object hold FirstName, WorkPhone, etc.

      In the deployment descriptor I've got the relationship defined to use <cascade-delete/>. Supposedly when the UserInfo object is deleted, it should take the UserContact object with it. This is not the case! I have to explicitly call: UserInfo.remove(email) and UserContact.remove(email) in order to get the rows for both objects removed from the database.

      I've found other examples of using <cascade-delete> from Sun's website, but all of those examples seem to use only a unidirectional relationship. Has anyone been successfull in deleting dependent objects of a bi-directional relationship?