- All Implemented Interfaces:
Serializable,Comparable<SynchronizationType>,Constable
EntityManager is always automatically synchronized with
the current transaction.
SYNCHRONIZEDindicates that the persistence context is automatically joined to the current transaction, and that modifications are always automatically synchronized with the database according to the current flush mode.UNSYNCHRONIZEDindicates that the persistence context is not automatically joined to the current transaction, and that its modifications are not synchronized with the database until it is explicitly joined to the current transaction by callingEntityManager.joinTransaction().
By default, a container-managed persistence context is of type
SYNCHRONIZED and is automatically joined to the current
transaction. A container-managed persistence context of type
UNSYNCHRONIZED is not enlisted in the current transaction
until joinTransaction() is called. The synchronization
type for a container-managed persistence context is specified by
PersistenceContext.synchronization().
By default, an application-managed persistence context
associated with a JTA entity manager and created within the
scope of an active JTA transaction is automatically joined to
that transaction. An application-managed JTA persistence context
created outside the scope of an active JTA transaction, or any
application-managed persistence context created with type
UNSYNCHRONIZED, is not enlisted with a transaction until
joinTransaction() is called. The synchronization type for
an application-managed JTA persistence context is specified via
EntityManagerFactory.createEntityManager(SynchronizationType).
An application-managed persistence context associated with a resource-local entity manager is always automatically joined to any resource-local transaction begun for that entity manager.
- Since:
- 2.1
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionThe persistence context is automatically joined to the current transaction, and modifications are automatically synchronized with the database according to the current flush mode.The persistence context must be explicitly joined to the current transaction by callingEntityManager.joinTransaction(). -
Method Summary
Modifier and TypeMethodDescriptionstatic SynchronizationTypeReturns the enum constant of this class with the specified name.static SynchronizationType[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
SYNCHRONIZED
The persistence context is automatically joined to the current transaction, and modifications are automatically synchronized with the database according to the current flush mode. -
UNSYNCHRONIZED
The persistence context must be explicitly joined to the current transaction by callingEntityManager.joinTransaction(). When the persistence context is not joined to a transaction, modifications cannot be synchronized with the database, regardless of the current flush mode. The persistence provider must not flush pending modifications to the database until the persistence context is joined to a transaction.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-