9.5.1 Definition method
You define the method of managing transactions by using a container.
You can specify the transaction attributes for each Enterprise Bean, interface, and method. When the transaction attributes are not specified, the attributes specified for the upper level become applicable.
-
Application in Enterprise Beans
Apply the assigned transaction attributes to the methods in the Enterprise Bean.
-
Application in interfaces
Apply the assigned transaction attributes to the methods in the interface.
-
Application in methods
Apply the assigned transaction attributes to one method.
- Organization of this subsection
(1) Attribute file to be edited
From the following attribute files, edit the attribute file that maps to the type of Enterprise Bean that sets the transaction attributes:
-
Session Bean attribute file
-
Entity Bean attribute file
-
Message-driven Bean attribute file
(2) Acquiring the attribute file to be edited and setting the attributes
-
Acquiring the attribute file
Execute the following command to acquire an Enterprise Bean attribute file:
- Execution format
cjgetappprop [server-name] [-nameserver provider-URL] -name J2EE application-name -type ejb -resname EJB-JAR-display-name/Enterprise-Bean-display-name -c path-of-the-Enterprise-Bean-attribute file
- Example of execution
cjgetappprop MyServer -name adder -type ejb -resname adder/adder_eb -c C:\home\adder_ejb.xml
-
Setting the attributes
Execute the following command to apply the values of the Enterprise Bean attribute file:
- Execution format
cjsetappprop [server-name] [-nameserver provider-URL] -name J2EE application-name -type ejb -resname EJB-JAR-display-name/Enterprise-Bean-display-name -c path-of-the-Enterprise-Bean-attribute-file
- Example of execution
cjgetappprop MyServer -name adder -type ejb -resname adder/adder_eb -c C:\home\adder_ejb.xml
(3) Attribute settings to be edited
The following table describes the settings for the container transaction attributes (<container-transaction>):
Items |
Mandatory |
Corresponding tags |
---|---|---|
Description |
O |
<description> |
Method description |
O |
<method> - <description> |
Interface classification |
O |
<method> - <method-intf> |
Method name |
Y |
<method> - <method-name> |
Transaction attribute |
Y |
<trans-attribute> |
For property settings, reference the following subsections:
-
3.4.1 Specifications of the HITACHI Session Bean Property file in the uCosminexus Application Server Application and Resource Definition Reference Guide
-
3.5.1 Specifications of the HITACHI Entity Bean Property file in the uCosminexus Application Server Application and Resource Definition Reference Guide
-
3.6.1 Specifications of the HITACHI MessageDrivenBean Property file in the uCosminexus Application Server Application and Resource Definition Reference Guide
The following points specify the transaction attributes and explain the transaction management operations:
-
NotSupported
The method is not executed in a container-managed transaction.
-
Supports
The process of method transaction differs on a case-to-case basis. Use this attribute only for the method that runs correctly inside the transaction and outside the transaction.
-
Required
The container always executes the method inside the transaction.
-
RequiresNew
The method is always executed in a new transaction.
-
Mandatory
The method must always use a client transaction. In other words, the client must invoke the method inside the transaction.
-
Never
The method cannot be executed inside the transaction. In other words, the client must invoke the method outside of the transaction.
(4) Notes
-
The transaction attributes that you can set differ based on the type of Enterprise Bean. For details on the transaction attributes that you can set and the transaction management operations, see the uCosminexus Application Server Common Container Functionality Guide.
-
In the Session Bean property (<transaction-type>), if it is specified that the Session Bean will manage its own transaction, then in this setting, the transaction attributes cannot be changed.
-
In the case of the Message-driven Bean, you can only set the onMessage method.