This article is not up to date and it has been substitute with new up to date content.

Please look the new up to date content.

The cascade delete

by Laura Cigardi
617 views Published on Oct 24, 2011
SQL
Applies to: All versions
Table of contents

The Cascade Delete option permits to implicitely delete other objects, which are in relationship with the objects you are going to remove. This option can be set on each role of the relationships in the data model and affects the behaviour of the delete unit. The default delete unit behaviour consists of:

  1. disconnect the objects to delete from the related objects identified by the outgoing relationships.
  2. remove the files of BLOB attributes according to the specified Delete Policy
  3. delete the selected objects from the database or from the related session object (in case of volatile entity)

When the Cascade Delete option is enabled, the delete unit, before permorming the disconnect to the related objects, deletes all the objects which are involved into the relationship-role where the Cascade Delete option has been set. Let's see an example.

Suppose to have the following data model:

When you delete a company, you want to delete also all the related divisions and all the employee that work in that divisions. To specify this behaviour you have to:

  1. select the "companyToDivision" role of the relationship connecting the Company and the Division entity and check the Cascade Delete option in the Properties View.
  2. select the "divisionToEployee" role of the relationship connecting the Division and the Employee entity and check the Cascade Delete option in the Properties View.

You do not have to do anything particular in the data model. Everytime you place a delete unit on the Company entity you are implicitely deleting also all the related division and employess. You do not have to model the deletion of divisions and employess explicitely, as you did in the previous version of WebRatio. In the following image you can compare the model in WebRatio 5, using the Cascade Delete option and the model in WebRatio 4.3.

 

 
 

This article is not up to date and it has been substitute with new up to date content.

Please look the new up to date content.