7.7.5. Transactions

The flat transaction model is supported. Depending on the configuration of the component application, transactions are demarcated either by the beans or by the container.

When bean managed transaction demarcation is used, the individual methods of a bean can use the UserTransaction interface of JTA to begin and commit or rollback a transaction.

When container managed transaction demarcation is used, the individual methods of a bean can use transaction attributes, specified either in the method annotations or in the deployment descriptor. The transaction attributes tell the container how to demarcate the transactions:

The state of a session bean is not a transactional resource and therefore is not influenced by transaction commit or rollback. A session bean can implement the SessionSynchronization interface of JTA to receive the afterBegin, beforeCompletion, afterCompletion notifications. These can be used to commit or rollback the state of the session bean explicitly.

Some limitations exist. (EJB 2.1 and below) Entity beans must use container demarcated transactions. (EJB 3.0 and above) Entity beans must use the calling transaction.