As a developer, you can write an application that updates data in multiple databases distributed across multiple sites. The site might use EJB servers from different vendors. This section provides overview information on the following topics:
The Enterprise JavaBeans Specification, v2.1 requires support for flat (as opposed to nested) transactions. In a flat transaction, each transaction is decoupled from and independent of other transactions in the system. Another transaction cannot start in the same thread until the current transaction ends.
Flat transactions are the most prevalent model and are supported by most commercial database systems. Although nested transactions offer a finer granularity of control over transactions, they are supported by far fewer commercial database systems.
Understanding the distinction between global and local transactions is crucial in understanding the Application Server support for transactions. See Transaction Scope.
Both local and global transactions are demarcated using the javax.transaction.UserTransaction interface, which the client must use. Local transactions bypass the transaction manager and are faster. For more information, see Naming Environment for J2EE Application Components.
The EJB protocol is designed to give the container the flexibility to select the disposition of the instance state at the time a transaction is committed. This allows the container to best manage caching an entity object’s state and associating an entity object identity with the EJB instances.
Option A: The container caches a ready instance between transactions. The container ensures that the instance has exclusive access to the state of the object in persistent storage.
In this case, the container does not have to synchronize the instance’s state from the persistent storage at the beginning of the next transaction.
Commit option A is not supported for this Application Server release.
Option B: The container caches a ready instance between transactions, but the container does not ensure that the instance has exclusive access to the state of the object in persistent storage. This is the default.
In this case, the container must synchronize the instance’s state by invoking ejbLoad from persistent storage at the beginning of the next transaction.
The life cycle for every business method invocation under commit option C looks like this:
ejbActivate -> ejbLoad -> business method -> ejbStore -> ejbPassivate
If there is more than one transactional client concurrently accessing the same entity EJBObject, the first client gets the ready instance and subsequent concurrent clients get new instances from the pool.
The Application Server deployment descriptor has an element, commit-option, that specifies the commit option to be used. Based on the specified commit option, the appropriate handler is instantiated.
An administrator can control a number of domain-level Transaction Service settings. For details, see Configuring the Transaction Service.
The Transaction Timeout setting can be overridden by a bean. See Bean-Level Container-Managed Transaction Timeouts.
In addition, the administrator can monitor transactions using statistics from the transaction manager that provide information on such activities as the number of transactions completed, rolled back, or recovered since server startup, and transactions presently being processed.
For information on administering and monitoring transactions, see the Application Server Administration Console online help and the Sun Java System Application Server Platform Edition 8.2 Administration Guide.