When using container-managed transactions, the method transaction attributes specify how the component participates in transactions. When a client or another component calls a method, the transaction attribute determines whether the method executes in the same transaction context, in a new transaction context, or cannot execute in transactions at all.
Table 1-1 lists the transaction attribute values. Requires, Supports, Requires New, or Mandatory are the values that specify container-managed transaction demarcation. You can set the Transaction Attribute for the component and for individual methods in the home and remote interfaces. Values set at the method level override the component setting.
Attribute |
Description |
---|---|
NotSupported |
(The component-level default.) The EJB component's methods never execute as part of a transaction. If the EJB component is activated by a client that has a pending transaction, the EJB component’s work is performed outside the existing transaction. Since entity beans are almost always involved in transactions, this value is not usually used for an entity bean. |
Supports |
The EJB component can execute in the context of an EAServer transaction, but a transaction is not required to execute the component’s methods. If a method is called by a base client that has a pending transaction, the method’s database work occurs in the scope of the client’s transaction. Otherwise, the EJB component’s database work is done outside of any transaction. |
Required |
The EJB component always executes in a transaction. Use this option when your EJB component’s database activity needs to be coordinated with other components, so that all components participate in the same transaction. |
RequiresNew |
Whenever the EJB component is instantiated, a new transaction begins. |
Mandatory |
EJB component methods must be called in the context of a pending transaction. If a client calls a method without an open transaction, the EAServer ORB throws an exception. |
Never |
The component’s methods never execute as part of a transaction, and the component may cannot be called in the context of a transaction. If a client or another component calls the component with an outstanding transaction, EAServer throws an exception. |