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 not supported transaction attribute instructs the container to suspend the calling transaction, if any, while executing the bean method.
The required transaction attribute instructs the container to use the calling transaction while executing the bean method, and to create a new transaction for the execution of the bean method if there is no calling transaction.
The supports transaction attribute instructs the container to use the calling transaction while executing the bean method, and to execute the bean method outside transaction if there is no calling transaction.
The requires new transaction attribute instructs the container to suspend the calling transaction, if any, and to create a new transaction for the execution of the bean method.
The mandatory transaction attribute instructs the container to execute the bean method inside the calling transaction, and to throw an exception if there is no calling transaction.
The never transaction attribute instructs the container to execute the bean method outside transaction, and to throw an exception if there is a calling transaction.
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.