Normally, all entity bean updates within a transaction are batched and executed at the end of the transaction. The only exception is the database flush that precedes execution of a finder or select query.
Since a transaction often spans many method calls, you might want to find out if the updates made by a method succeeded or failed immediately after method execution. To force a flush at the end of a method’s execution, use the flush-at-end-of-method element in the sun-ejb-jar.xml file. Only non-finder methods in the Local, Local Home, Remote, and Remote Home interfaces of an entity bean can be flush-enabled.
Upon completion of the method, the EJB container updates the database. Any exception thrown by the underlying data store is wrapped as follows:
If the method that triggered the flush is a create method, the exception is wrapped with CreateException.
If the method that triggered the flush is a remove method, the exception is wrapped with RemoveException.
For all other methods, the exception is wrapped with EJBException.
All normal end-of-transaction database synchronization steps occur regardless of whether the database has been flushed during the transaction.