Friday 17 January 2014

Deleting the child records when the master records gets delete

We go for association when there is relation between the two tables. For example Order and Order Items. When we delete the Order then Order Items under that Order should get delete.  How can we achieve this?. There is an option provided by the ADF framework  association called "Implement Cascade Delete". Just we need to select that option, automatically the ADF framework will handle the master-child record.

First create the associations between the order and Items, if the association did not get create while creating the Entity Objects for the Order and OrderItems as shown in the below image


After creation of Association, open the association, go to the Relationship tab and expand the Behavior options at the bottom. Select the Composition Associations check-box, then select the Implement Cascade Delete check-box as shown in the below image .



Now if you delete the master record, automatically the child record gets delete.