The cascade delete

From Wiki

Jump to: navigation, search


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.



Related articles:
Category Difficulty Refers
Choosing the primary key ID Generator Data Model Intermediate WebRatio
E-R Schema Technical Reference Beginner Entity
Relation
Getting started with the Data Model Unit Web Model Advanced Data Model Unit
Query Unit
Getting started with the Query Unit Web Model Advanced Query Unit
Data Model Unit
How to implement a custom database Metadata provider Data Model Advanced WebRatio
… further results












Personal tools