Logical unit of work
When you change resources that are categorized as non-recoverable (such as serial files on Windows 2000), your work is relatively permanent; neither your code nor EGL run-time services can simply rescind the changes. When you change resources that are categorized as recoverable (such as relational databases), your code or EGL run-time services either can commit the changes to make the work permanent or can rollback the changes to return to content that was in effect when changes were last committed.
Recoverable resources are as follows:
- Relational databases
- CICS queues and files that are configured to be recoverable
- MQSeries message queues, unless your MQSeries record specifies otherwise, as described in MQSeries support
A logical unit of work identifies input operations that are either committed or rolled back as a group. A unit of work begins when your code changes a recoverable resource; and ends when the first of these events occurs:
- Your code invokes the system function sysLib.commit or sysLib.rollback to commit or roll back the changes
- EGL run-time services performs a rollback in response to a hard error that is not handled in your code; in this case, all the programs in the run unit are removed from memory
- An implicit commit occurs, as happens in the following cases--
- A program issues a show statement.
- The top-level program in a run unit ends successfully, as described in Run unit.
- A Web page is displayed, as when a page handler issues a forward statement.
- A program issues a converse statement and any of the following applies:
- You are not in VisualAge Generator compatibility mode, and the program is a segmented program
- sysVar.commitOnConverse is set to 1
- You are in VisualAge Generator compatibility mode, and sysVar.segmentedMode is set to 1
Unit of work for Java
In a Java run unit, the details are as follows:
- When any of the Java programs ends with a hard error, the effect is equivalent to performing rollbacks, closing cursors, and releasing locks.
- When the run unit ends successfully, EGL performs a commit, closes cursors, and releases locks.
- You can use multiple connections to read from multiple databases, but you should update only one database in a unit of work because only a one-phase commit is available. For related information, see sysLib.connectionService.
- When an EGL-generated program is accessed by way of an EGL-generated EJB session bean, transaction control may be affected by a transaction attribute (also called the container transaction type), which is in the deployment descriptor of the EJB session bean. The transaction attribute affects transaction control only when the linkage options part, callLink element, property remoteComType for the call is direct, as described in remoteComType in callLink element.
The EJB session bean is generated with transaction attribute REQUIRED, but you can change the value at deployment time. For details on the implications of the transaction attribute, see your Java documentation.
Related concepts
MQSeries support
Run unit
SQL support
Related tasks
Setting up a J2EE JDBC connection
Understanding how a standard JDBC connection is made
Related reference
Default database
sysLib.commit
sysLib.connectionService
sysLib.rollback
Java wrapper classes
luwControl in callLink element
remoteComType in callLink element
sqlDB