EJB Transaction Management

In this section, we discuss some extended topics related to transaction management with EJB components. This material complements the introductory section on EJB transaction management found in Chapter 6. If you are specifically concerned with transaction management related to EJBs , we recommend that you read “Transaction Management” in Chapter 6 since it introduces the basic concepts and some general rules related to both declarative and programmatic transaction management within EJBs. Once you have that material under your belt, if you feel you need to know more, come back to this section for additional coverage.

If you’re using strictly declarative transaction management within EJBs, this is referred to as Container-Managed Transaction Demarcation (CMTD). The container is responsible for starting and committing or rolling back the transactions required by the EJB based on the directives specified in the deployment descriptor as well as some programmatic hints by the developer in the EJB code. The container leverages JTA for the transaction management under the covers.

Using programmatic transaction management within EJB components is a bit of a special case, because the EJB container has a default assumption that it is managing transactions on behalf of its components. Programmatic transaction management within EJB components is sometimes referred to as Bean-Managed Transaction Demarcation (BMTD ). If an EJB developer chooses to use BMTD in a bean, ...

Get Java Enterprise in a Nutshell, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.