The life cycle of an entity instance is managed
by its entity manager.
An entity manager instance
is associated with a persistence context. Within
this persistence context, the entity instances and their life cycle
are managed
and can be accessed though the entity manager standard operations.
Entity instances become unmanaged and detached when a transaction
scope
or extended persistence context ends. An important consequence of
this fact
is that detached entities can be serialized and sent across the network
to
a remote client. The client can make changes remotely to these serialized
object instances and send them back to the server to be merged back
and synchronized
with the database.
Note: This behavior is very different from the EJB
2.1 entity
model, where entities are always managed by the container. Because
in EJB
3.0 you are working with entities that are POJOs, this can simplify
how you
design Java™ EE applications, because you are not forced
to
use patterns, such as data transfer objects (DTO), between the business
logic
layer (session beans) and the persistence layer.