The Web Graph Database


Cascading delete

Cascading delete is an operation commonly known in database design. For example, consider a BillOfMaterials that contains several LineItems. When an instance of BillOfMaterials is deleted, it generally makes sense to also delete the LineItems at the same time. The "cascading effect" of deletes gives this operation its name.

InfoGrid supports a simple version of cascading deletes since V990. What exactly needs to be done when a MeshObject is deleted is defined in the model. For example, the following method:

    public void cascadingDelete()
        org.infogrid.mesh.set.MeshObjectSet lineItems = traverse( ExampleSubjectArea.BILLOFMATERIALS_COMPRISES_LINEITEM.getSource() );
        for( MeshObject lineItem : lineItems ) {
            getMeshBase().getMeshBaseLifecycleManager().deleteMeshObject( lineItem );

is automatically invoked prior to the deletion of an instance of BillOfMaterials. As written above, this will delete each comprised instance of LineItem. Of course, LineItem could have its own cascadingDelete method, which would be invoked automatically as well.

Of course, developers are free to invoke other types of callback code in the cascadingDelete method, e.g. to bless or unbless relationships or perform other types of operations.

Last modified 4 years ago Last modified on 07/20/10 04:54:27