Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g (10.1.3.5.0) Part Number E13981-01 |
|
|
View PDF |
For an enterprise bean that uses container-managed transactions, you can configure how the container manages transactions when a client invokes a bean method (see "Using Deployment XML").
For more information, see the following:
To configure how the container manages transactions when a client invokes a bean method, use the ejb-jar.xml
file <assembly-descriptor>
subelement <container-transaction>
, as Example 21-4 shows.
Example 21-4 Configuring Transaction Attribute for an EJB 2.1 Session Bean
<assembly-descriptor> <container-transaction> <method> <ejb-name>CreditService</ejb-name> <method-name>setLimit</method-name> <method-params> <method-param>int</method-param> </method-params> </method> <trans-attribute>Required</trans-attribute> </container-transaction> ... </assembly-descriptor>
The <container-transaction>
element contains one or more <method>
elements and one <trans-attribute>
element. The <trans-attribute>
element applies to all the <method>
elements. You can specify methods by name, by name and parameters (signature), or you can specify all methods of the specified enterprise bean using a wildcard <method-name>*</method-name>
.
Table 21-2 lists the values for the <trans-attribute>
element that you can specify and shows how the container will respond depending on whether or not a client-controlled transaction exists at the time the method is invoked
Table 21-2 Valid Values for the <trans-attribute> Element
Transaction Attribute | ClientEControlled Transaction Exists | ClientEControlled Transaction Does Not Exist |
---|---|---|
|
Container suspends client transaction |
Use no transaction |
|
Use client-controlled transaction |
Use no transaction |
|
Use client-controlled transaction |
Container starts a new transaction |
|
Container suspends client transaction and creates a new transaction |
Container starts a new transaction |
|
Use client-controlled transaction |
Exception raised |
|
Exception raised |
Use no transaction |
Footnote 1 Default for EJB 2.1 message-driven beans.
Footnote 2 Default for EJB 2.1 session beans and BMP entity beans.
Footnote 3 Default for EJB 2.1 CMP entity beans.