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

Entity Manager Merge


In this and the remaining sections we discuss topics which are applicable to both container-managed and application-managed entity managers. However, our examples will assume a container-managed entity manager is being used.

As we have seen, an entity becomes managed when we use the EntityManager.persist() method. At this point the entity is associated with a persistence context. While an entity is managed the state of the entity is automatically synchronized with the database by the entity manager. By default a persistence context is scoped to a transaction. When the transaction ends, the persistence context ends and the entity is no longer managed. An unmanaged entity is referred to as a detached entity and is no longer associated with a persistence context. This means that further changes to the entity are no longer reflected in the database. If an entity is passed by value, through the remote interface to another application tier for example, then it also becomes...