Handling transactions manually

Handling a transaction manually provides the developer with more control over the transaction, but requires more work. This type of transaction control is called a BMT.

It is possible to begin and start a transaction anywhere within a method. The boundaries of a transaction are explicitly set using the begin and commit transaction methods. For CMT the boundaries of a transaction are effectively the method. BMTs are only possible for session- and message-driven beans. They cannot be used for entities.

Getting ready

The steps used to handle transactions manually include:

  1. Using the @TransactionManagement annotation to specify bean-managed transactions
  2. Injecting an instance of the UserTransaction object
  3. Enclosing the transaction ...

Get EJB 3.1 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.