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

Extended Persistence Context


So far, all of our examples have used transaction scoped entity managers. Whenever a new transaction started, a new persistence context was created. This was true for both container-managed and application-managed entity managers. In the case of application-managed entity managers, as we have seen, the application explicitly starts and ends the transaction. In the case of container-managed entity managers, by default a transaction starts when a remote client invokes a session bean method. The transaction ends when that session bean method ends. This is the default transaction behavior and as we shall see in Chapter 7, it is possible to configure transaction start and end points to some extent.

Transaction scoped entity managers have a rather restrictive effect when it comes to applications using stateful session beans.

Suppose we have a remote client, BankClient, which invokes three methods in turn on a stateful session bean, BankService. The first method adds...