Skip Headers

# Using deleteAllObjects Without addConstraintDependencies

Previous

Next

In the first option, you do not identify the one-to-many (A to B) relationship as privately owned. When deleting an A object, you must delete all of its B objects, as well as any C objects, as shown in the following example:

    uow.deleteObject(existingA);
    uow.deleteAllObjects(existingA.getBs());
    // delete one of the Cs
    uow.deleteObject(((B) existingA.getBs().get(1)).getC());

This option produces the following SQL:

    DELETE FROM B WHERE (ID = 2)
    DELETE FROM B WHERE (ID = 1)
    DELETE FROM A WHERE (ID = 1)
    DELETE FROM C WHERE (ID = 1)