Skip Headers

# Using the Descriptor addConstraintDependencies Method

Previous

Next

The constraints used by TopLink to determine delete order are inferred from one-to-one and one-to-many mappings. If you do not have such mappings, you can add constraint knowledge to TopLink using the descriptor `addConstraintDependencies(Class)` method.

For example, suppose you have a composition of objects: A contains B (one-to-many, privately owned) and B has a one-to-one, nonprivate relationship with C. You want to delete A (and in doing so the included Bs) but before deleting the Bs, for some of them (not all) you want to delete the associated object C.

There are two possible solutions:

1. Using deleteAllObjects Without addConstraintDependencies

2. Using deleteAllObjects With addConstraintDependencies