![]() | |
| |
NOT_SUPPORTED
The container invokes an enterprise bean method whose transaction attribute is set to the NOT_SUPPORTED value with an unspecified transaction context.
If a client calls with a transaction context, the container SUSPENDS the association of the transaction context with the current thread before invoking the enterprise bean's business method. The container RESUMES the suspended association when the business method has completed. The suspended transaction context of the client is not passed to the resource managers or other enterprise bean objects that are invoked from the business method.
If the business method invokes other enterprise beans, the container passes no transaction context with the invocation.
REQUIRED
The container must invoke an enterprise bean method whose transaction attribute is set to the REQUIRED value with a valid transaction context.
If a client invokes the enterprise bean's method while the client is associated with a transaction context, the container invokes the enterprise bean's method in the client's transaction context.
If the client invokes the enterprise bean's method while the client is NOT ASSOCIATED with a transaction context, the container AUTOMATICALLY STARTS a new transaction before delegating a method call to the enterprise bean business method. The container automatically enlists all the resource managers accessed by the business method with the transaction. If the business method invokes other enterprise beans, the container passes the transaction context with the invocation. The container attempts to commit the transaction when the business method has completed. The container performs the commit protocol before the method result is sent to the client.
SUPPORTS
The container invokes an enterprise bean method whose transaction attribute is set to SUPPORTS as follows:
If the client calls WITH a transaction context, the container performs the same steps as described in the REQUIRED case.
If the client calls WITHOUT a transaction context, the container performs the same steps as described in the NOT_SUPPORTED case.
The SUPPORTS transaction attribute must be used with caution. This is because of the different transactional semantics provided by the two possible modes of execution. Only the enterprise beans that will execute correctly in both modes should use the SUPPORTS transaction attribute.
REQUIRES_NEW
The container MUST invoke an enterprise bean method whose transaction attribute is set to REQUIRES_NEW with a NEW TRANSACTION CONTEXT.
If the client invokes the enterprise bean's method while the client is not associated with a transaction context, the container automatically STARTS a new transaction before delegating a method call to the enterprise bean business method. The container automatically enlists all the resource managers accessed by the business method with the transaction. If the business method invokes other enterprise beans, the container passes the transaction context with the invocation. The container attempts to commit the transaction when the business method has completed. The container performs the commit protocol before the method result is sent to the client.
If a client calls with a transaction context, the container SUSPENDS the association of the transaction context with the current thread before starting the new transaction and invoking the business method. The container RESUMES the suspended transaction association after the business method and the new transaction have been completed.
MANDATORY
The container must invoke an enterprise bean method whose transaction attribute is set to MANDATORY in a client's transaction context. The client is REQUIRED to call with a transaction context.
If the client calls with a transaction context, the container performs the same steps as described in the REQUIRED case.
If the client calls without a transaction context, the container throws the javax.ejb.EJBTransactionRequiredException. If the EJB 2.1 client view is used, the container throws the javax.transaction.TransactionRequiredException exception if the client is a remote client, or the javax.ejb.TransactionRequiredLocalException if the client is a local client.
NEVER
The container invokes an enterprise bean method whose transaction attribute is set to NEVER WITHOUT a transaction context defined by the EJB specification. The client is required to call WITHOUT a transaction context.
If the client calls WITH a transaction context, the container throws the javax.ejb.EJBException. If the EJB 2.1 client view is used, the container throws the java.rmi.RemoteException exception if the client is a remote client, or the javax.ejb.EJBException if the client is a local client.
If the client calls WITHOUT a transaction context, the container performs the same steps as described in the NOT_SUPPORTED case.
Transaction Attribute Summary
The following table provides a summary of the transaction context that the container passes to the business method and resource managers used by the business method, as a function of the transaction attribute and the client's transaction context. T1 is a transaction passed with the client request, while T2 is a transaction initiated by the container.
Table 9.1. Transaction Attribute Summary
| Transaction attribute | Client's transaction | Transaction associated with business method | Transaction associated with resource managers |
|---|---|---|---|
NOT_SUPPORTED | none | none | none |
T1 | none | none | |
REQUIRED | none | T2 | T2 |
T1 | T1 | T1 | |
SUPPORTS | none | none | none |
T1 | T1 | T1 | |
REQUIRES_NEW | none | T2 | T2 |
T1 | T2 | T2 | |
MANDATORY | none | ERROR | N/A |
T1 | T1 | T1 | |
NEVER | none | none | none |
T1 | ERROR | N/A |
|
|
|
|
Hosting provided by PerfoHost: KVM VPS. Unix VPS. Windows VPS. VPN. Domains. Dedicated servers. Colocation.