Skip Headers

# CMP Transaction Attribute

Previous

Next

To ensure that all modifications to persistent beans are carried out in the context of a transaction, transactional attributes must be properly specified in the bean deployment descriptors.

The transaction may be either client-controlled or container-controlled.

Client-controlled transactions are started explicitly by your application by way of the `javax.transaction.UserTransaction` interface.

Container-controlled transactions are started implicitly by the container to satisfy the transaction attribute configuration when a bean method is invoked in the absence of a client-controlled transaction.

Table: EJB Transaction State by Transaction Attribute shows what transaction (if any) an EJB method invocation uses depending on how its transaction attribute is configured and whether or not a client-controlled transaction exists at the time the method is invoked.

Oracle recommends that you do not make modifications to entity beans under conditions identified as "Use no transaction" in Table: EJB Transaction State by Transaction Attribute. Oracle also recommends that you avoid using the `Supports` transaction attribute because it leads to a nontransactional state whenever the client does not explicitly provide a transaction.

EJB Transaction State by Transaction Attribute

Transaction Attribute | Client-Controlled Transaction Exists | Client-Controlled Transaction Does Not Exist
--- | --- | ---
`NotSupported` | Use no transaction | Use no transaction
`Supports` | Use client-controlled transaction | Use no transaction
`Required` | Use client-controlled transaction | Use container-controlled transaction
`RequiresNew` | Use client-controlled transaction | Use container-controlled transaction
`Mandatory` | Use client-controlled transaction | Exception raised
`Never` | Exception raised | Use no transaction

Depending on the EJB container you use, you may be able to write without a container-controlled transaction (see "Integrating the Unit of Work With an External Transaction Service"). In this case, TopLink automatically uses a transaction of its own, referred to as a local transaction (see "Local Transactions").