background image

RequiresNew Attribute

<< Container-Managed Transactions | Summary of Transaction Attributes >>
<< Container-Managed Transactions | Summary of Transaction Attributes >>

RequiresNew Attribute

A transaction attribute can have one of the following values:
Required
RequiresNew
Mandatory
NotSupported
Supports
Never
Required
Attribute
If the client is running within a transaction and invokes the enterprise bean's method, the
method executes within the client's transaction. If the client is not associated with a transaction,
the container starts a new transaction before running the method.
The Required attribute is the implicit transaction attribute for all enterprise bean methods
running with container-managed transaction demarcation. You typically do not set the
Required
attribute unless you need to override another transaction attribute. Because
transaction attributes are declarative, you can easily change them later.
RequiresNew
Attribute
If the client is running within a transaction and invokes the enterprise bean's method, the
container takes the following steps:
1. Suspends the client's transaction
2. Starts a new transaction
3. Delegates the call to the method
4. Resumes the client's transaction after the method completes
Bean-1
.
.
.
method-A(){
.
.
.
bean-2.method-B()
}
Bean-2
.
.
.
method-B(){
.
.
.
}
TX1
{
TX?
{
FIGURE 33­1
Transaction Scope
Container-Managed Transactions
Chapter 33 · Transactions
999