A Transaction Attribute
is a value in an enterprise bean's deployment
descriptor that is used by the EJB container to control the
transaction scope when the enterprise bean's methods are
invoked. The transaction attributes are:
- Required - The container starts a new transaction before
running the method if the client is not associated with a
transaction; otherwise the method executes within the client's
transaction.
- RequiresNew - The container always starts a new transaction
and suspends the client's transaction if the client is running
within a transaction.
- Mandatory - The method executes within the client's
transaction. Only use this attribute if the method must use the client's
transaction; otherwise the container will throw an exception.
- NotSupported - The method only executes within transactions
generated by the client or it executes without a transaction. If
the client is already running within a transaction, the container suspends
the transaction to invoke the method and then resumes the client's
transaction.
- Supports - The method executes within the client's
transaction. If the client is not running within a transaction, the
container runs the method without starting a new transaction.
Because the transactional behavior of methods with
this attribute is unpredictable, you should avoid using this
attribute unless you are very familiar with transaction attributes.
- Never - The method is never executed within a
transaction. If the client is running within a transaction when invoking
a method, an exception is thrown.