Handling transactions the easy way

The easiest way of handling transactions is to let the EJB container manage transactions. This is facilitated through the use of the @TransactionManagement annotation. When Container Managed Transactions (CMT) are used, the developer can select the appropriate transaction attributes for the class and/or methods.

Getting ready

The use of CMT is effected by:

  1. Using the @TransactionManagement annotation for the class
  2. Using the TransactionManagementType.CONTAINER element, as part of the previous annotation, to specify that CMT is being used
  3. Using the @TransactionAttribute annotation at the class or method level to specify the scope of the transaction

    By default, classes and methods use CMT. This means that the above annotations ...

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.