The Web Graph Database

wiki:Docs/CascadingDelete

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:

<implementsMethod><![CDATA[
    public void cascadingDelete()
        throws
            org.infogrid.meshbase.transaction.TransactionException,
            NotPermittedException
    {
        org.infogrid.mesh.set.MeshObjectSet lineItems = traverse( ExampleSubjectArea.BILLOFMATERIALS_COMPRISES_LINEITEM.getSource() );
        for( MeshObject lineItem : lineItems ) {
            getMeshBase().getMeshBaseLifecycleManager().deleteMeshObject( lineItem );
        }
    }
]]></implementsMethod>

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