First page Back Continue Last page Text

oracle adf workshop

Notes:


Example: Updating a Deleted Flag Instead of Deleting Rows

Your requirements may demand that rows are never physically deleted from a table, but rather only have the value of a DELETED column changed from N to Y to mark it as deleted. There are two method overrides required to alter an entity object’s default behavior to achieve this effect:

1. Update a DELETED flag when a row is removed: Generate a Java class for your entity object and override the remove() method to set the deleted flag before calling the super.remove() method. The row will still be removed from the row set, but it will have the value of its DELETED flag modified to Y in the entity cache. It is important to set the attribute before calling super.remove(), because an attempt to set the attribute of a deleted row causes DeadEntityAccessException.

2. Force an update instead of a delete: Override the doDML() method and write code that conditionally changes the operation flag. When the operation flag equals DML_DELETE, your code will change it to DML_UPDATE instead.

With this overridden doDML() method in place to complement the overridden remove() method described in the previous section, any attempt to remove an entity row through any view object based on that entity will update the DELETED column instead of physically deleting the row. However, to prevent rows that are marked deleted from appearing in view object query results, you need to include DELETED = 'N' as part of the WHERE clause of each view object.