Java Reference
In-Depth Information
The following table summarizes the different values that we can assign to the
@TransactionAtttibute annotation:
@TransactionAttribute value
Method invoked
while a transaction
is in progress
Method invoked while no
transaction is in progress
TransactionAttributeType.
MANDATORY
Method becomes
part of the existing
transaction.
TransactionRequired
Exception is thrown.
TransactionAttributeType.
NEVER
Method is executed without
any transaction support.
RemoteException
is thrown.
TransactionAttributeType.
NOT_SUPPORTED
Client transaction
is temporarily
suspended, the
method is executed
without transaction
support, and then the
client transaction is
resumed.
Method is executed without
any transaction support.
TransactionAttributeType.
REQUIRED
Method becomes
part of the existing
transaction.
A new transaction is created
for the method.
TransactionAttributeType.
REQUIRES_NEW
Client transaction
is temporarily
suspended, a new
transaction is created
for the method,
and then the client
transaction is
resumed.
A new transaction is
created for the method.
TransactionAttributeType.
SUPPORTS
Method becomes
part of the existing
transaction.
Method is executed without
any transaction support.
The @TransactionAttribute annotation can be used to decorate the class
declaration of our Enterprise JavaBean, or it can be used to decorate a single
method. If used to decorate the class declaration, then the declared transaction
behavior will apply to all methods in the bean, where when used to decorate a
single method, the declared behavior will affect only the decorated method. If a
bean has an @TransactionAttribute annotation both at the class level and at
the method level, the method level annotation takes precedence. If no transaction
attribute is specified for a method, then TransactionAttributeType.REQUIRED
attribute is used by default.
 
Search WWH ::




Custom Search