Skip Headers

# CMP Controlled Transactions

Previous

Next

Entity beans that use container-managed persistence may participate in transactions that are either client demarcated or container demarcated.

A client demarcated transaction occurs when a client of an entity bean directly sets up transaction boundaries using the `javax.transaction.UserTransaction` interface.

A container demarcated transaction occurs when the container automatically wraps an invocation on an EJB in a transaction based upon the transaction attributes supplied in the EJB deployment descriptor.

In transactions involving EJB, TopLink waits until the transaction begins its two-phase commit process before updating the database. This allows for the following:

- SQL optimizations that ensure only changed data is written to the data source

- Proper ordering of updates to allow for database constraints

For more information, see "Integrating the Unit of Work With CMP".