(Replacing message template with parser tag) |
No edit summary |
||
Line 1: | Line 1: | ||
<message>Write the content here to display this box</message> | <message>Write the content here to display this box</message> | ||
OnDelete is called when an object is deleted - much like a destructor. | OnDelete is called when an object is deleted - much like a destructor. | ||
The delete may fail due to the object - or one of the objects aggregates that is deleted as a consequence of [[Training:Composite and Aggregate and what they imply|Cascading delete]] - is not ready for delete (as if it has still associations not included in the cascading delete). | |||
This may pose problems for you in certain scenarios like for example this example: | |||
[[File:Documentation OCLOperators OnDelete 1734385240315.png|frameless|519x519px]] | |||
In the example above - when a Class1 object is deleted - almost all follow the Cascade delete rules due to the use of Composite on the association ends - however if the link from a class4-object has some class3-objects in its association that is "only" aggregate - the delete will halt - stating that the association end Class4-Class3s is not empty. | |||
In this scenario you might find it beneficial to implement the OnDeleteReasonSolve(reason:string) method. | |||
The OnDeleteReasonSolve method gives you the reason in the incoming parameter - but you may now what the problem is already and just implement the OnDeleteReasonSolve method with action language: | |||
self.Class3s->clear | |||
The check will then be done again - and if no reasons not to delete remain the delete will go through. | |||
See also: [[OCLOperators OnCreate|OnCreate]], [[OCLOperators OnUpdate|OnUpdate]], [[OCLOperators OnStateChange|OnStateChange]] | See also: [[OCLOperators OnCreate|OnCreate]], [[OCLOperators OnUpdate|OnUpdate]], [[OCLOperators OnStateChange|OnStateChange]] | ||
[[Category:OCLOperators]] | [[Category:OCLOperators]] | ||
{{Edited|July|12|2024}} | {{Edited|July|12|2024}} |
Revision as of 21:47, 16 December 2024
OnDelete is called when an object is deleted - much like a destructor.
The delete may fail due to the object - or one of the objects aggregates that is deleted as a consequence of Cascading delete - is not ready for delete (as if it has still associations not included in the cascading delete).
This may pose problems for you in certain scenarios like for example this example:
In the example above - when a Class1 object is deleted - almost all follow the Cascade delete rules due to the use of Composite on the association ends - however if the link from a class4-object has some class3-objects in its association that is "only" aggregate - the delete will halt - stating that the association end Class4-Class3s is not empty.
In this scenario you might find it beneficial to implement the OnDeleteReasonSolve(reason:string) method.
The OnDeleteReasonSolve method gives you the reason in the incoming parameter - but you may now what the problem is already and just implement the OnDeleteReasonSolve method with action language:
self.Class3s->clear
The check will then be done again - and if no reasons not to delete remain the delete will go through.
See also: OnCreate, OnUpdate, OnStateChange