Enum Class QueryFlushMode
- All Implemented Interfaces:
Statement.Option, StoredProcedureQuery.Option, TypedQuery.Option, Serializable, Comparable<QueryFlushMode>, Constable
Query. An explicitly-specified
query-level
flush mode overrides the current
flush mode of the
persistence context.
When a Jakarta Persistence or native SQL query is executed
within a transaction via an instance of Query obtained
from an EntityManager joined to the transaction, the
effective flush mode is determined by the current flush mode
of the Query object, if any flush mode has been
specified by calling Query.setFlushMode(FlushModeType) or
Query.setQueryFlushMode(QueryFlushMode), or, otherwise, by the current
flush mode of the persistence context.
- If
FLUSHis set, the persistence provider is required to flush modifications to the database before executing the query. - If
NO_FLUSHis set, the persistence provider is not required to flush modifications to the database before executing the query; if, in addition, the current flush mode of the entity manager isFlushModeType.EXPLICIT, the persistence provider is not permitted to flush modifications to the database.
DEFAULT is set:
- If
FlushModeType.AUTOis in effect, the provider must ensure that every modification to the state of every entity associated with the persistence context which could possibly affect the result of the query is visible to the processing of the query. The provider implementation might guarantee this by flushing pending updates to modified entities to the database before executing the query. - If
FlushModeType.EXPLICITis in effect, the provider is not permitted to flush modifications to the database before executing the query. Pending modifications to entities in the persistence context might not be visible to the processing of the query. - If
FlushModeType.COMMITis in effect, it is unspecified how pending modifications to entities in the persistence context affect the results of the query.
When there is no transaction active, or if the persistence context has not been joined to the current transaction, the persistence provider must not flush pending modifications to the database, regardless of the flush mode.
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:
- 4.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionThe persistence provider must determine whether to flush before executing the query by considering the current flush mode of the persistence context.The persistence provider is required to flush pending modifications to the database before executing the query.The persistence provider is not required to flush pending modifications to the database before executing the query. -
Method Summary
Modifier and TypeMethodDescriptionstatic QueryFlushModeReturns the enum constant of this class with the specified name.static QueryFlushMode[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
FLUSH
The persistence provider is required to flush pending modifications to the database before executing the query. Pending modifications to entities held in the persistence context are always visible to the processing of the query. The current flush mode of the persistence context is completely overridden. -
NO_FLUSH
The persistence provider is not required to flush pending modifications to the database before executing the query. Pending modifications to entities held in the persistence context might not be visible to the processing of the query.- If the current
flush mode of the persistence context is
FlushModeType.EXPLICIT, the persistence provider is not permitted to flush pending modifications before executing the query. - Otherwise, this mode is considered a hint to the persistence provider.
- If the current
flush mode of the persistence context is
-
DEFAULT
The persistence provider must determine whether to flush before executing the query by considering the current flush mode of the persistence context.
-
-
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
-