|
Page Edited :
OPENEJB :
Transaction Annotations
Transaction Annotations has been edited by David Blevins (Sep 11, 2007). Content:The javax.ejb.TransactionAttribute annotation (@TransactionAttribute) can be applied to a bean class or it's methods. Usage of the @TransactionAttribute requires you to specify on of six different transaction attribute types defined via the javax.ejb.TransactionAttributeType enum.
Per EJB 3.0 the default transaction attribute for all EJB 3.0 applications is REQUIRED. The default transaction attribute for EJB 2.1, 2.0 and 1.1 applications is vendor specific. In OpenEJB EJB 2.1, 2.0 and 1.1 applications also use REQUIRED as the default. Attribute Types summaryA simplistic way to visualize the transaction attributes is as follows.
MANDATORYA MANDATORY method is guaranteed to always be executed in a transaction. However, it's the caller's job to take care of suppling the transaction. If the caller attempts to invoke the method outside of a transaction, then the container will block the call and throw them an exception. REQUIREDA REQUIRED method is guaranteed to always be executed in a transaction. If the caller attempts to invoke the method outside of a transaction, the container will start a transaction, execute the method, then commit the transaction. REQUIRES_NEWA REQUIRES_NEW method is guaranteed to always be executed in a transaction. If the caller attempts to invoke the method inside or outside of a transaction, the container will still start a transaction, execute the method, then commit the transaction. Any transaction the caller may have in progress will be suspended before the method execution then resumed afterward. NEVERA NEVER method is guaranteed to never be executed in a transaction. However, it's the caller's job to ensure there is no transaction. If the caller attempts to invoke the method inside of a transaction, then the container will block the call and throw them an exception. NOT_SUPPORTEDA NOT_SUPPORTED method is guaranteed to never be executed in a transaction. If the caller attempts to invoke the method inside of a transaction, the container will suspend the caller's transaction, execute the method, then resume the caller's transaction. SUPPORTSA SUPPORTS method is guaranteed to adopt the exact transactional state of the caller. These methods can be invoked by caller's inside or outside of a transaction. The container will do nothing to change that state. |
Unsubscribe or edit your notifications preferences
