Enum Class FlushModeType
- All Implemented Interfaces:
EntityManager.CreationOption, EntityManager.Option, Serializable, Comparable<FlushModeType>, Constable
EntityManager.
The flush mode of a
persistence context controls synchronization of modifications
to managed entities with the database.
When a transaction is active and the persistence context is
joined to the transaction, the persistence provider runtime is
permitted to flush pending modifications to the database. The
application can influence the timing of synchronization via the
method EntityManager.flush(), by setting the
FlushModeType, or by specifying a QueryFlushMode.
- When the
flush()method is called, the provider must synchronize every pending modification made to every entity currently associated with the persistence context. - The method
EntityManager.setFlushMode(FlushModeType)can be used to control synchronization initiated automatically by the provider. UnlessEXPLICITis specified, all pending modifications are synchronized with the database when the transaction commits. WhenAUTOis specified, pending modifications might be automatically flushed to the database before execution of a query. - The effect of the
FlushModeTypeof the entity manager may be overridden during execution of a given query by explicitly specifying aQueryFlushModevia the methodQuery.setQueryFlushMode(QueryFlushMode).
If there is no transaction active or if the persistence context has not been joined to the current transaction, the persistence provider must not flush modifications to the database.
An EntityAgent has no associated persistence context,
and so flush modes have no effect on an entity agent, nor on
Query objects created by an entity agent.
- Since:
- 1.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionPending modifications to entities associated with a persistence context joined to the current transaction are automatically flushed to the database when the transaction commits.Pending modifications to entities associated with a persistence context joined to the current transaction are automatically flushed to the database when the transaction commits.Every flush is an explicit operation requested by the application program by callingEntityManager.flush(). -
Method Summary
Modifier and TypeMethodDescriptionstatic FlushModeTypeReturns the enum constant of this class with the specified name.static FlushModeType[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
EXPLICIT
Every flush is an explicit operation requested by the application program by callingEntityManager.flush(). The persistence context is never automatically flushed. Pending modifications to entities held in the persistence context might not be visible to the processing of queries and might never be made persistent.- Since:
- 4.0
-
COMMIT
Pending modifications to entities associated with a persistence context joined to the current transaction are automatically flushed to the database when the transaction commits. The provider is permitted to flush at other times, but is not required to. Pending modifications to entities associated with the persistence context might not be visible to the processing of queries. -
AUTO
Pending modifications to entities associated with a persistence context joined to the current transaction are automatically flushed to the database when the transaction commits. In addition, the persistence provider must ensure that every modification to the state of every entity associated with the persistence context which could possibly affect the result of a query is visible to the processing of the query. The persistence provider implementation might guarantee this by flushing pending modifications to the database before executing the query. The provider is permitted to flush at other times, but is not required to.This is the default flush mode for a newly created
EntityManager.
-
-
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
-