Friday, 10 May 2013

If session has thrown ApplicaitonException would you use EJBContext. setRollBackOnly method?

According to the EJB specification, when the Application Exception is thrown, the EJBContext.setRollBackOnly method is not called.
Typically, an enterprise bean marks a transaction for rollback to protect data integrity before throwing an application exception, because application exceptions do not automatically cause the Container to rollback the transaction.
For example, an Account Transfer bean which debits one account and credits another account could mark a transaction for rollback if it successfully performs the debit operation, but encounters a failure during the credit operation.


No comments: