Book Image

EJB 3 Developer Guide

By : Michael Sikora
Book Image

EJB 3 Developer Guide

By: Michael Sikora

Overview of this book

Table of Contents (18 chapters)
EJB 3 Developer Guide
Credits
About the Author
About the Reviewers
Preface
Annotations and Their Corresponding Packages

Container-Managed Transaction Demarcation


When using Container-managed transactions we need to decide where a transaction starts and where it ends. Container-managed demarcation policies are defined by transaction attributes. There are six transaction attributes: SUPPORTS, NOT_SUPPORTED, REQUIRED, REQUIRES_NEW, MANDATORY, NEVER.

These can be set on the session bean's class or method. Transaction attributes can also be set for message driven beans as we shall see in Chapter 8.

A Java application method which is not in a transaction may invoke a session bean method. This session bean method execution may span a transaction, so the method start and end will demarcate the transaction. In another scenario a session bean method which is in a transaction may invoke another session bean method. Do we start a new transaction for this second method, or is the second method run within the first method's transaction? The transaction attributes cater for these scenarios.

SUPPORTS

If the caller is in a transaction...