Interface MutationQuery
- All Superinterfaces:
CommonQueryContract
- All Known Subinterfaces:
NativeQuery<T>,NativeQueryImplementor<R>,ProcedureCallImplementor<R>,Query<R>,QueryImplementor<R>,SqmQueryImplementor<R>
- All Known Implementing Classes:
AbstractQuery,NativeQueryImpl,ProcedureCallImpl,QuerySqmImpl
insert, update, or delete. It is a slimmed-down
version of Query, providing only methods relevant to mutation queries.
A MutationQuery may be obtained from the Session
by calling:
QueryProducer.createMutationQuery(String), passing the HQL as a string,QueryProducer.createNativeMutationQuery(String), passing native SQL as a string,QueryProducer.createMutationQuery(jakarta.persistence.criteria.CriteriaUpdate)orQueryProducer.createMutationQuery(jakarta.persistence.criteria.CriteriaDelete), passing a criteria update or delete object, orQueryProducer.createNamedMutationQuery(String), passing the name of a query defined usingNamedQueryorNamedNativeQuery.
A MutationQuery controls how the mutation query is executed, and
allows arguments to be bound to its parameters.
- Mutation queries must be executed using
executeUpdate(). - The various overloads of
setParameter(String, Object)andsetParameter(int, Object)allow arguments to be bound to named and ordinal parameters defined by the query.
-
Method Summary
Modifier and TypeMethodDescriptionintExecute an insert, update, or delete statement, and return the number of affected entities.setComment(String comment) Set a comment for this query.setFlushMode(FlushModeType flushMode) Set theFlushModein to use for this query.setHibernateFlushMode(FlushMode flushMode) Set the currentFlushModein effect for this query.Set a hint.setParameter(int position, Object value) Bind the given argument to an ordinal query parameter.setParameter(int position, Instant value, TemporalType temporalType) Bind anInstantto an ordinal query parameter using just the portion indicated by the givenTemporalType.setParameter(int position, Calendar value, TemporalType temporalType) setParameter(int position, Date value, TemporalType temporalType) <P> MutationQuerysetParameter(int position, P value, Class<P> type) Bind the given argument to an ordinal query parameter using the givenClassreference to attempt to infer theBindableType.<P> MutationQuerysetParameter(int position, P value, BindableType<P> type) Bind the given argument to an ordinal query parameter using the givenBindableType.setParameter(Parameter<Calendar> param, Calendar value, TemporalType temporalType) setParameter(Parameter<Date> param, Date value, TemporalType temporalType) <T> MutationQuerysetParameter(Parameter<T> param, T value) setParameter(String name, Object value) Bind the given argument to a named query parameter.setParameter(String name, Instant value, TemporalType temporalType) Bind anInstantto the named query parameter using just the portion indicated by the givenTemporalType.setParameter(String name, Calendar value, TemporalType temporalType) setParameter(String name, Date value, TemporalType temporalType) <P> MutationQuerysetParameter(String name, P value, Class<P> type) Bind the given argument to a named query parameter using the givenClassreference to attempt to infer theBindableType.<P> MutationQuerysetParameter(String name, P value, BindableType<P> type) Bind the given argument to a named query parameter using the givenBindableType.<P> MutationQuerysetParameter(QueryParameter<P> parameter, P value, Class<P> type) Bind an argument to the query parameter represented by the givenQueryParameter, using the givenClassreference to attempt to infer theBindableTypeto use.<P> MutationQuerysetParameter(QueryParameter<P> parameter, P val, BindableType<P> type) Bind an argument to the query parameter represented by the givenQueryParameter, using the givenBindableType.<T> MutationQuerysetParameter(QueryParameter<T> parameter, T value) Bind an argument to the query parameter represented by the givenQueryParameter.setParameterList(int position, Object[] values) Bind multiple arguments to an ordinal query parameter.setParameterList(int position, Collection values) Bind multiple arguments to an ordinal query parameter.<P> MutationQuerysetParameterList(int position, Collection<? extends P> values, Class<P> javaType) Bind multiple arguments to an ordinal query parameter using the givenClassreference to attempt to infer theBindableType.<P> MutationQuerysetParameterList(int position, Collection<? extends P> values, BindableType<P> type) Bind multiple arguments to an ordinal query parameter using the givenBindableType.<P> MutationQuerysetParameterList(int position, P[] values, Class<P> javaType) Bind multiple arguments to an ordinal query parameter using the givenClassreference to attempt to infer theBindableType.<P> MutationQuerysetParameterList(int position, P[] values, BindableType<P> type) Bind multiple arguments to an ordinal query parameter using the givenBindableType.setParameterList(String name, Object[] values) Bind multiple arguments to a named query parameter.setParameterList(String name, Collection values) Bind multiple arguments to a named query parameter.<P> MutationQuerysetParameterList(String name, Collection<? extends P> values, Class<P> javaType) Bind multiple arguments to a named query parameter using the givenClassreference to attempt to infer theBindableTypeIf unable to infer an appropriateBindableType, fall back toCommonQueryContract.setParameterList(String, Collection).<P> MutationQuerysetParameterList(String name, Collection<? extends P> values, BindableType<P> type) Bind multiple arguments to a named query parameter using the givenBindableType.<P> MutationQuerysetParameterList(String name, P[] values, Class<P> javaType) Bind multiple arguments to a named query parameter using the given Class reference to attempt to determine theBindableTypeto use.<P> MutationQuerysetParameterList(String name, P[] values, BindableType<P> type) Bind multiple arguments to a named query parameter using the givenBindableType.<P> MutationQuerysetParameterList(QueryParameter<P> parameter, Collection<? extends P> values) Bind multiple arguments to the query parameter represented by the givenQueryParameter.<P> MutationQuerysetParameterList(QueryParameter<P> parameter, Collection<? extends P> values, Class<P> javaType) Bind multiple arguments to the query parameter represented by the givenQueryParameterusing the givenClassreference to attempt to infer theBindableTypeto use.<P> MutationQuerysetParameterList(QueryParameter<P> parameter, Collection<? extends P> values, BindableType<P> type) Bind multiple arguments to the query parameter represented by the givenQueryParameter, using the givenBindableType.<P> MutationQuerysetParameterList(QueryParameter<P> parameter, P[] values) Bind multiple arguments to the query parameter represented by the givenQueryParameter.<P> MutationQuerysetParameterList(QueryParameter<P> parameter, P[] values, Class<P> javaType) Bind multiple arguments to the query parameter represented by the givenQueryParameterusing the givenClassreference to attempt to infer theBindableTypeto use.<P> MutationQuerysetParameterList(QueryParameter<P> parameter, P[] values, BindableType<P> type) Bind multiple arguments to the query parameter represented by the givenQueryParameter, using the given theBindableType.setProperties(Object bean) Bind the property values of the given bean to named parameters of the query, matching property names with parameter names and mapping property types to Hibernate types using heuristics.setProperties(Map bean) Bind the values of the givenMapto named parameters of the query, matching key names with parameter names and mapping value types to Hibernate types using heuristics.setTimeout(int timeout) Set the query timeout in seconds.Methods inherited from interface org.hibernate.query.CommonQueryContract
getComment, getFlushMode, getHibernateFlushMode, getTimeout
-
Method Details
-
executeUpdate
int executeUpdate()Execute an insert, update, or delete statement, and return the number of affected entities.For use with instances of
MutationQuerycreated usingQueryProducer.createMutationQuery(String),QueryProducer.createNamedMutationQuery(String),QueryProducer.createNativeMutationQuery(String),QueryProducer.createQuery(jakarta.persistence.criteria.CriteriaUpdate), orQueryProducer.createQuery(jakarta.persistence.criteria.CriteriaDelete).- Returns:
- the number of affected entity instances (may differ from the number of affected rows)
- See Also:
-
setFlushMode
Description copied from interface:CommonQueryContractSet theFlushModein to use for this query.- Specified by:
setFlushModein interfaceCommonQueryContract- See Also:
-
setHibernateFlushMode
Description copied from interface:CommonQueryContractSet the currentFlushModein effect for this query.- Specified by:
setHibernateFlushModein interfaceCommonQueryContract- See Also:
-
setTimeout
Description copied from interface:CommonQueryContractSet the query timeout in seconds.Any value set here is eventually passed directly along to the JDBC statement, which expressly disallows negative values. So negative values should be avoided as a general rule.
A value of zero indicates no timeout.
- Specified by:
setTimeoutin interfaceCommonQueryContract- Parameters:
timeout- the timeout in seconds- Returns:
this, for method chaining- See Also:
-
setComment
Description copied from interface:CommonQueryContractSet a comment for this query.- Specified by:
setCommentin interfaceCommonQueryContract- See Also:
-
setHint
Description copied from interface:CommonQueryContractSet a hint. The hints understood by Hibernate are enumerated byAvailableHints.- Specified by:
setHintin interfaceCommonQueryContract- See Also:
-
setParameter
Description copied from interface:CommonQueryContractBind the given argument to a named query parameter.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".
- Specified by:
setParameterin interfaceCommonQueryContract- See Also:
-
setParameter
Description copied from interface:CommonQueryContractBind the given argument to a named query parameter using the givenClassreference to attempt to infer theBindableType. If unable to infer an appropriateBindableType, fall back toCommonQueryContract.setParameter(String, Object).- Specified by:
setParameterin interfaceCommonQueryContract- See Also:
-
setParameter
Description copied from interface:CommonQueryContractBind the given argument to a named query parameter using the givenBindableType.- Specified by:
setParameterin interfaceCommonQueryContract
-
setParameter
Description copied from interface:CommonQueryContractBind anInstantto the named query parameter using just the portion indicated by the givenTemporalType.- Specified by:
setParameterin interfaceCommonQueryContract
-
setParameter
- Specified by:
setParameterin interfaceCommonQueryContract- See Also:
-
setParameter
- Specified by:
setParameterin interfaceCommonQueryContract- See Also:
-
setParameter
Description copied from interface:CommonQueryContractBind the given argument to an ordinal query parameter.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".
- Specified by:
setParameterin interfaceCommonQueryContract- See Also:
-
setParameter
Description copied from interface:CommonQueryContractBind the given argument to an ordinal query parameter using the givenClassreference to attempt to infer theBindableType. If unable to infer an appropriateBindableType, fall back toCommonQueryContract.setParameter(int, Object).- Specified by:
setParameterin interfaceCommonQueryContract- See Also:
-
setParameter
Description copied from interface:CommonQueryContractBind the given argument to an ordinal query parameter using the givenBindableType.- Specified by:
setParameterin interfaceCommonQueryContract
-
setParameter
Description copied from interface:CommonQueryContractBind anInstantto an ordinal query parameter using just the portion indicated by the givenTemporalType.- Specified by:
setParameterin interfaceCommonQueryContract
-
setParameter
- Specified by:
setParameterin interfaceCommonQueryContract- See Also:
-
setParameter
- Specified by:
setParameterin interfaceCommonQueryContract- See Also:
-
setParameter
Description copied from interface:CommonQueryContractBind an argument to the query parameter represented by the givenQueryParameter.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".
- Specified by:
setParameterin interfaceCommonQueryContract- Parameters:
parameter- the query parameter mementovalue- the argument, which might be null- Returns:
this, for method chaining- See Also:
-
setParameter
Description copied from interface:CommonQueryContractBind an argument to the query parameter represented by the givenQueryParameter, using the givenClassreference to attempt to infer theBindableTypeto use. If unable to infer an appropriateBindableType, fall back toCommonQueryContract.setParameter(QueryParameter, Object).- Specified by:
setParameterin interfaceCommonQueryContract- Parameters:
parameter- the query parameter mementovalue- the argument, which might be nulltype- aBindableTyperepresenting the type of the parameter- Returns:
this, for method chaining- See Also:
-
setParameter
Description copied from interface:CommonQueryContractBind an argument to the query parameter represented by the givenQueryParameter, using the givenBindableType.- Specified by:
setParameterin interfaceCommonQueryContract- Parameters:
parameter- the query parameter mementoval- the argument, which might be nulltype- aBindableTyperepresenting the type of the parameter- Returns:
this, for method chaining
-
setParameter
- Specified by:
setParameterin interfaceCommonQueryContract- See Also:
-
setParameter
- Specified by:
setParameterin interfaceCommonQueryContract- See Also:
-
setParameter
- Specified by:
setParameterin interfaceCommonQueryContract- See Also:
-
setParameterList
Description copied from interface:CommonQueryContractBind multiple arguments to a named query parameter.The "type mapping" for the binding is inferred from the type of the first collection element.
- Specified by:
setParameterListin interfaceCommonQueryContract- Returns:
this, for method chaining- See Also:
-
setParameterList
Description copied from interface:CommonQueryContractBind multiple arguments to a named query parameter using the givenClassreference to attempt to infer theBindableTypeIf unable to infer an appropriateBindableType, fall back toCommonQueryContract.setParameterList(String, Collection).- Specified by:
setParameterListin interfaceCommonQueryContract- Returns:
this, for method chaining- See Also:
-
setParameterList
<P> MutationQuery setParameterList(String name, Collection<? extends P> values, BindableType<P> type) Description copied from interface:CommonQueryContractBind multiple arguments to a named query parameter using the givenBindableType.- Specified by:
setParameterListin interfaceCommonQueryContract- Returns:
this, for method chaining
-
setParameterList
Description copied from interface:CommonQueryContractBind multiple arguments to a named query parameter.The "type mapping" for the binding is inferred from the type of the first collection element
- Specified by:
setParameterListin interfaceCommonQueryContract- Returns:
this, for method chaining
-
setParameterList
Description copied from interface:CommonQueryContractBind multiple arguments to a named query parameter using the given Class reference to attempt to determine theBindableTypeto use. If unable to determine an appropriateBindableType,CommonQueryContract.setParameterList(String, Collection)is used- Specified by:
setParameterListin interfaceCommonQueryContract- Returns:
this, for method chaining- See Also:
-
setParameterList
Description copied from interface:CommonQueryContractBind multiple arguments to a named query parameter using the givenBindableType.- Specified by:
setParameterListin interfaceCommonQueryContract- Returns:
this, for method chaining
-
setParameterList
Description copied from interface:CommonQueryContractBind multiple arguments to an ordinal query parameter.The "type mapping" for the binding is inferred from the type of the first collection element
- Specified by:
setParameterListin interfaceCommonQueryContract- Returns:
this, for method chaining
-
setParameterList
Description copied from interface:CommonQueryContractBind multiple arguments to an ordinal query parameter using the givenClassreference to attempt to infer theBindableType. If unable to infer an appropriateBindableType, fall back toCommonQueryContract.setParameterList(String, Collection).- Specified by:
setParameterListin interfaceCommonQueryContract- Returns:
this, for method chaining- See Also:
-
setParameterList
<P> MutationQuery setParameterList(int position, Collection<? extends P> values, BindableType<P> type) Description copied from interface:CommonQueryContractBind multiple arguments to an ordinal query parameter using the givenBindableType.- Specified by:
setParameterListin interfaceCommonQueryContract- Returns:
this, for method chaining
-
setParameterList
Description copied from interface:CommonQueryContractBind multiple arguments to an ordinal query parameter.The "type mapping" for the binding is inferred from the type of the first collection element
- Specified by:
setParameterListin interfaceCommonQueryContract- Returns:
this, for method chaining
-
setParameterList
Description copied from interface:CommonQueryContractBind multiple arguments to an ordinal query parameter using the givenClassreference to attempt to infer theBindableType. If unable to infer an appropriateBindableType, fall back toCommonQueryContract.setParameterList(String, Collection).- Specified by:
setParameterListin interfaceCommonQueryContract- Returns:
this, for method chaining- See Also:
-
setParameterList
Description copied from interface:CommonQueryContractBind multiple arguments to an ordinal query parameter using the givenBindableType.- Specified by:
setParameterListin interfaceCommonQueryContract- Returns:
this, for method chaining
-
setParameterList
Description copied from interface:CommonQueryContractBind multiple arguments to the query parameter represented by the givenQueryParameter.The type of the parameter is inferred from the context in which it occurs, and from the type of the first given argument.
- Specified by:
setParameterListin interfaceCommonQueryContract- Parameters:
parameter- the parameter mementovalues- a collection of arguments- Returns:
this, for method chaining
-
setParameterList
<P> MutationQuery setParameterList(QueryParameter<P> parameter, Collection<? extends P> values, Class<P> javaType) Description copied from interface:CommonQueryContractBind multiple arguments to the query parameter represented by the givenQueryParameterusing the givenClassreference to attempt to infer theBindableTypeto use. If unable to infer an appropriateBindableType, fall back to usingCommonQueryContract.setParameterList(String, Collection).- Specified by:
setParameterListin interfaceCommonQueryContract- Returns:
this, for method chaining- See Also:
-
setParameterList
<P> MutationQuery setParameterList(QueryParameter<P> parameter, Collection<? extends P> values, BindableType<P> type) Description copied from interface:CommonQueryContractBind multiple arguments to the query parameter represented by the givenQueryParameter, using the givenBindableType.- Specified by:
setParameterListin interfaceCommonQueryContract- Returns:
this, for method chaining
-
setParameterList
Description copied from interface:CommonQueryContractBind multiple arguments to the query parameter represented by the givenQueryParameter.The type of the parameter is inferred between the context in which it occurs, the type associated with the
QueryParameterand the type of the first given argument.- Specified by:
setParameterListin interfaceCommonQueryContract- Parameters:
parameter- the parameter mementovalues- a collection of arguments- Returns:
this, for method chaining
-
setParameterList
Description copied from interface:CommonQueryContractBind multiple arguments to the query parameter represented by the givenQueryParameterusing the givenClassreference to attempt to infer theBindableTypeto use. If unable to infer an appropriateBindableType, fall back to usingCommonQueryContract.setParameterList(String, Collection).- Specified by:
setParameterListin interfaceCommonQueryContract- Returns:
this, for method chaining- See Also:
-
setParameterList
Description copied from interface:CommonQueryContractBind multiple arguments to the query parameter represented by the givenQueryParameter, using the given theBindableType.- Specified by:
setParameterListin interfaceCommonQueryContract- Returns:
this, for method chaining
-
setProperties
Description copied from interface:CommonQueryContractBind the property values of the given bean to named parameters of the query, matching property names with parameter names and mapping property types to Hibernate types using heuristics.- Specified by:
setPropertiesin interfaceCommonQueryContract- Parameters:
bean- any JavaBean or POJO- Returns:
this, for method chaining
-
setProperties
Description copied from interface:CommonQueryContractBind the values of the givenMapto named parameters of the query, matching key names with parameter names and mapping value types to Hibernate types using heuristics.- Specified by:
setPropertiesin interfaceCommonQueryContract- Parameters:
bean- aMapof names to arguments- Returns:
this, for method chaining
-