Skip Headers

# Deleting Objects

Previous

Next

To delete objects in a unit of work, use the `deleteObject` or `deleteAllObjects` method. When you delete an object that is not already registered in the unit of work, the unit of work registers the object automatically.

When you delete an object, TopLink deletes the object's privately owned child parts, because those parts cannot exist without the owning (parent) object. At commit time, the unit of work generates SQL to delete the objects, taking database constraints into account.

When you delete an object, you must take your object model into account. You may need to set references to the deleted object to null (for an example, see "Using privateOwnedRelationship").

This section explains how to delete objects within a unit of work, including the following:

- Using privateOwnedRelationship

- Explicitly Deleting From the Database

- Understanding the Order in Which Objects Are Deleted