Interface Query<T>

Type Parameters:
T - The result type for selection queries or the target type for mutation queries.
All Superinterfaces:
CommonQueryContract, Query
All Known Subinterfaces:
MutationQueryImplementor<T>, NativeQuery<T>, NativeQueryImplementor<R>, ProcedureCallImplementor<R>, QueryImplementor<T>, SelectionQuery<R>, SelectionQueryImplementor<R>

@Incubating public interface Query<T> extends CommonQueryContract
Within the context of an active session, an instance of this type represents an executable query, either:
  • a Query written in HQL or native SQL,
  • a named Query written in HQL or native SQL, or
  • a criteria query.

The subtype NativeQuery represents a Query written in native SQL.

This type simply mixes the TypedQuery interface defined by JPA with SelectionQuery and MutationQuery. Unfortunately, JPA does not distinguish between selection queries and mutation queries, so we lose that distinction here. However, every Query may logically be classified as one or the other.

A Query may be obtained from the Session by calling:

A Query controls how a Query is executed, and allows arguments to be bound to its parameters.

Note that this interface offers no real advantages over SelectionQuery except for compatibility with the JPA-defined TypedQuery interface.

See Also: