Last updated on
17 January 2022
|
Also applies to ColdFusion
A persistent CFC can have various methods and if these methods are present, callbacks can be sent on those events to the CFC. The CFC can then handle these events. In this case, the event for entity persistence comes to the CFC that the system loads, inserts, updates, or deletes. These methods are:
- preLoad(): This method is called before the load operation or before the data is loaded from the database.
- postLoad (): This method is called after the load operation is complete.
- preInsert (): This method is called just before the object is inserted.
- postInsert(): This method is called after the insert operation is complete.
- preUpdate (Struct oldData ): This method is called just before the object is updated. A struct of old data is passed to this method to know the original state of the entity being updated.
postUpdate (): This method is called after the update operation is complete.
Note:
When you call the EntitySave() method on an object that is not loaded using EntityLoad(), it gets updated but the intercepter call fails. This happens because an empty map is created for the object and there is no previous data associated with it.
- preDelete (): This method is called before the object is deleted.
- postDelete (): This method is called after the delete operation is complete.