Transaction errors will frequently result in the transaction being roll backed. That is, any and all operations performed would be reversed and the database will be restored to its previous state. Rollback will automatically occur when a Java unchecked exception is thrown. A rollback may also be performed explicitly by the EJB when conditions warrant a rollback. In a BMT either the
UserTransaction's rollback or
setRollbackOnly methods are used to explicitly rollback the transaction. In a CMT, the
setRollbackOnly method is used. The
setRollbackOnly method is designed to be used with a two-phase commit protocol. The invocation of the method is a way to vote for a rollback.
The general approach to rolling back ...