Interface CommonQueryContract

All Superinterfaces:
Query
All Known Subinterfaces:
CommonQueryContractImplementor, MutationQuery, MutationQueryImplementor<T>, NativeQuery<T>, NativeQueryImplementor<R>, ProcedureCall, ProcedureCallImplementor<R>, Query<T>, QueryImplementor<T>, SelectionQuery<R>, SelectionQueryImplementor<R>

public interface CommonQueryContract extends Query
Defines the aspects of query execution and parameter binding that apply to all forms of querying:

Also acts as the primary extension point for the Jakarta Persistence Query hierarchy.

Queries may have parameters, either ordinal or named, and the various setParameter() operations of this interface allow an argument to be bound to a parameter. It's not usually necessary to explicitly specify the type of an argument, but in rare cases where this is needed:

For example:

session.createSelectionQuery("from Person where address = :address", Person.class)
        .setParameter("address", address, Person_.address.getType())
        .getResultList()
entityManager.createQuery( "from Person where address = :address", Person.class)
        .setParameter("address", TypedParameterValue.of(Person_.address.getType(), address))
        .getResultList()

The operation setQueryFlushMode(QueryFlushMode) allows a temporary flush mode to be specified, which is in effect only during the execution of this query. Setting the query flush mode does not affect the flush mode of other operations performed via the parent session. This operation is usually used as follows:

query.setQueryFlushMode(NO_FLUSH).getResultList()

The call to setQueryFlushMode(NO_FLUSH) disables the usual automatic flush operation that occurs before query execution.

See Also: