Customizing the Commit Phase
The TransactionListener interface defines beforeCommit() and afterCommit() methods. You can implement a transaction listener and add it to the transactions list of event listeners by calling the transaction’s addTransactionListener() method. For example, in an entity object’s code, call:
Your entity objects are also transaction listeners, and are already on your transaction’s list of event listeners. Because of this, you can also override an entity object’s beforeCommit() and afterCommit() methods. The simple example in the slide shows adding a printed notification that a record has been committed; however, you could perform any action, such as notifying an employee’s manager by email that information about an employee has been updated.
The procedure for customizing rollback behavior is similar to the procedure for customizing commit behavior. The TransactionListener interface also defines beforeRollback() and afterRollback() methods that are called before and after a rollback operation.