diff --git a/hibernate-core/src/main/java/org/hibernate/query/Query.java b/hibernate-core/src/main/java/org/hibernate/query/Query.java index 9f846b01ee..0ceafade5b 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/Query.java +++ b/hibernate-core/src/main/java/org/hibernate/query/Query.java @@ -44,8 +44,8 @@ import jakarta.persistence.TypedQuery; * This type simply mixes {@link TypedQuery} defined by JPA with {@link SelectionQuery} * and {@link MutationQuery}. Unfortunately, JPA does not distinguish between * {@link SelectionQuery selection queries} and {@link MutationQuery mutation queries}, - * so we lose that distinction here. However, every {@code Query} may logically be - * classified as one or the other. + * so we lose that distinction here. However, every {@code Query} may logically + * be classified as one or the other. *
* A {@code Query} controls how a query is executed, and allows arguments to be * bound to its parameters. @@ -56,14 +56,14 @@ import jakarta.persistence.TypedQuery; *
+ * This overload simply calls {@link #scroll(ScrollMode)} using the
+ * {@linkplain Dialect#defaultScrollMode() dialect default scroll mode}.
*
* @apiNote The exact behavior of this method depends somewhat
* on the JDBC driver's {@link java.sql.ResultSet} scrolling support
@@ -106,11 +108,13 @@ public interface Query
* The client should call {@link Stream#close()} after processing the
* stream so that resources are freed as soon as possible.
@@ -154,8 +158,8 @@ public interface Query
- * For use with instances of {@code Query
+ * If SQL commenting is enabled, the comment will be added to the SQL
+ * query sent to the database, which may be useful for identifying the
+ * source of troublesome queries.
+ *
+ * SQL commenting may be enabled using the configuration property
+ * {@value org.hibernate.cfg.AvailableSettings#USE_SQL_COMMENTS}.
*
* @return The comment.
*/
@@ -278,6 +283,13 @@ public interface Query
+ * If SQL commenting is enabled, the comment will be added to the SQL
+ * query sent to the database, which may be useful for identifying the
+ * source of troublesome queries.
+ *
+ * SQL commenting may be enabled using the configuration property
+ * {@value org.hibernate.cfg.AvailableSettings#USE_SQL_COMMENTS}.
*
* @param comment The human-readable comment
*
@@ -288,19 +300,22 @@ public interface Query
+ * A database hint is a completely different concept to a JPA hint
+ * specified using {@link jakarta.persistence.QueryHint} or
+ * {@link #getHints()}. These are hints to the JPA provider.
+ *
+ * Multiple query hints may be specified. The operation
+ * {@link Dialect#getQueryHintString(String, List)} determines how
+ * the hint is actually added to the SQL query.
*
* @param hint The database specific query hint to add.
*/
Query
+ * Only the following options are taken into consideration:
+ *
- * The alias-specific lock modes specified here are added to the query's internal
+ * The alias-specific lock modes specified here are added to the
* {@link #getLockOptions() LockOption}s.
*
- * The effect of these alias-specific LockModes is somewhat dependent on the driver/database in use. Generally
- * speaking, for maximum portability, this method should only be used to mark that the rows corresponding to
- * the given alias should be included in pessimistic locking ({@link LockMode#PESSIMISTIC_WRITE}).
+ * The effect of alias-specific locking is quite dependent on the
+ * driver and database. For maximum portability, the given lock
+ * mode should be {@link LockMode#PESSIMISTIC_WRITE}.
*
* @param alias a query alias, or {@code "this"} for a collection filter
* @param lockMode The lock mode to apply.
@@ -354,15 +373,14 @@ public interface Query
- * If the type of the parameter cannot be inferred from the context in which
- * it occurs, use one of the forms accept a "type".
+ * If the type of the parameter cannot be inferred from the context
+ * in which it occurs, use one of the forms accept a "type".
*
* @see #setParameter(String, Object, Class)
* @see #setParameter(String, Object, BindableType)
@@ -391,7 +409,7 @@ public interface Query Query type);
/**
- * Bind an {@link Instant} value to the named query parameter using just the portion
- * indicated by the given {@link TemporalType}.
+ * Bind an {@link Instant} value to the named query parameter using
+ * just the portion indicated by the given {@link TemporalType}.
*/
Query
- * If the type of the parameter cannot be inferred from the context in which
- * it occurs, use one of the forms which accepts a "type".
+ * If the type of the parameter cannot be inferred from the context in
+ * which it occurs, use one of the forms which accepts a "type".
*
* @see #setParameter(int, Object, Class)
* @see #setParameter(int, Object, BindableType)
@@ -442,7 +460,7 @@ public interface Query Query type);
/**
- * Bind an {@link Instant} value to the ordinal query parameter using just the portion
- * indicated by the given {@link TemporalType}.
+ * Bind an {@link Instant} value to the ordinal query parameter using
+ * just the portion indicated by the given {@link TemporalType}.
*/
Query
- * If the type of the parameter cannot be inferred from the context in which
- * it occurs, use one of the forms which accepts a "type".
+ * If the type of the parameter cannot be inferred from the context in
+ * which it occurs, use one of the forms which accepts a "type".
*
* @see #setParameter(QueryParameter, Object, BindableType)
*
@@ -544,11 +562,12 @@ public interface Query Query javaType);
/**
- * Bind multiple arguments to a named query parameter using the passed type-mapping.
+ * Bind multiple arguments to a named query parameter using the given
+ * {@link BindableType}.
*
- * @apiNote This is used for binding a list of values to an expression such as {@code entity.field in (:values)}.
+ * @apiNote This is used for binding a list of values to an expression
+ * such as {@code entity.field in (:values)}.
*
* @return {@code this}, for method chaining
*/
@@ -583,9 +605,10 @@ public interface Query Query javaType);
/**
- * Bind multiple arguments to an ordinal query parameter using the passed type-mapping.
+ * Bind multiple arguments to an ordinal query parameter using the given
+ * {@link BindableType}.
*
- * @apiNote This is used for binding a list of values to an expression such as {@code entity.field in (:values)}.
+ * @apiNote This is used for binding a list of values to an expression
+ * such as {@code entity.field in (:values)}.
*
* @return {@code this}, for method chaining
*/
@@ -654,11 +684,12 @@ public interface Query
+ * The "type mapping" for the binding is inferred from the type of the
+ * first collection element.
*
- * @apiNote This is used for binding a list of values to an expression such as {@code entity.field in (:values)}.
+ * @apiNote This is used for binding a list of values to an expression
+ * such as {@code entity.field in (:values)}.
*
* @return {@code this}, for method chaining
*/
@@ -666,34 +697,37 @@ public interface Query Query javaType);
/**
- * Bind multiple arguments to an ordinal query parameter using the passed type-mapping.
+ * Bind multiple arguments to an ordinal query parameter using the given
+ * {@link BindableType}.
*
- * @apiNote This is used for binding a list of values to an expression such as {@code entity.field in (:values)}.
+ * @apiNote This is used for binding a list of values to an expression
+ * such as {@code entity.field in (:values)}.
*
* @return {@code this}, for method chaining
*/
Query type);
/**
- * Bind multiple arguments to the query parameter represented by the
- * given {@link QueryParameter}.
+ * Bind multiple arguments to the query parameter represented by the given
+ * {@link QueryParameter}.
*
- * The type of the parameter is inferred from the context in which it
- * occurs, and from the type of the first given argument.
+ * The type of the parameter is inferred from the context in which it occurs,
+ * and from the type of the first given argument.
*
* @param parameter the parameter memento
* @param arguments a collection of arguments
@@ -703,31 +737,31 @@ public interface Query Query parameter, Collection extends P> arguments);
/**
- * Bind multiple arguments to the query parameter represented by the
- * given {@link QueryParameter} using the given Class reference to attempt
- * to determine the {@link BindableType} to use. If unable to
- * determine an appropriate {@link BindableType},
- * {@link #setParameterList(String, Collection)} is used
+ * Bind multiple arguments to the query parameter represented by the given
+ * {@link QueryParameter} using the given Class reference to attempt to
+ * determine the {@link BindableType} to use. If unable to determine an
+ * appropriate {@link BindableType}, {@link #setParameterList(String, Collection)}
+ * is used.
*
* @see BindableType#parameterType(Class)
* @see #setParameterList(QueryParameter, java.util.Collection, BindableType)
*
- * @apiNote This is used for binding a list of values to an expression such as {@code entity.field in (:values)}.
+ * @apiNote This is used for binding a list of values to an expression such
+ * as {@code entity.field in (:values)}.
*
* @return {@code this}, for method chaining
*/
Query parameter, Collection extends P> arguments, Class javaType);
/**
- * Bind multiple arguments to the query parameter represented by the
- * given {@link QueryParameter}, inferring the {@link BindableType}.
+ * Bind multiple arguments to the query parameter represented by the given
+ * {@link QueryParameter}, inferring the {@link BindableType}.
+ *
+ * The "type mapping" for the binding is inferred from the type of the first
+ * collection element.
*
- * Bind multiple arguments to a named query parameter.
- *
+ * Set the lock options for the query.
+ *
*