Package org.hibernate.query
Interface NativeQuery<T>
-
- All Superinterfaces:
BasicQueryContract<CommonQueryContract>
,CommonQueryContract
,Query
,Query<T>
,Query<T>
,SQLQuery<T>
,SynchronizeableQuery<T>
,TypedQuery<T>
- All Known Subinterfaces:
NativeQueryImplementor<T>
public interface NativeQuery<T> extends Query<T>, SQLQuery<T>, SynchronizeableQuery<T>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.hibernate.SQLQuery
SQLQuery.FetchReturn, SQLQuery.ReturnProperty, SQLQuery.RootReturn
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description NativeQuery<T>
addEntity(java.lang.Class entityType)
Declare a "root" entity, without specifying an alias.NativeQuery<T>
addEntity(java.lang.String entityName)
Declare a "root" entity, without specifying an alias.NativeQuery<T>
addEntity(java.lang.String tableAlias, java.lang.Class entityType)
Declare a "root" entity.NativeQuery<T>
addEntity(java.lang.String tableAlias, java.lang.Class entityClass, LockMode lockMode)
Declare a "root" entity, specifying a lock mode.NativeQuery<T>
addEntity(java.lang.String tableAlias, java.lang.String entityName)
Declare a "root" entity.NativeQuery<T>
addEntity(java.lang.String tableAlias, java.lang.String entityName, LockMode lockMode)
Declare a "root" entity, specifying a lock mode.SQLQuery.FetchReturn
addFetch(java.lang.String tableAlias, java.lang.String ownerTableAlias, java.lang.String joinPropertyName)
Declare a join fetch result.NativeQuery<T>
addJoin(java.lang.String tableAlias, java.lang.String path)
Declare a join fetch result.NativeQuery<T>
addJoin(java.lang.String tableAlias, java.lang.String ownerTableAlias, java.lang.String joinPropertyName)
Declare a join fetch result.NativeQuery<T>
addJoin(java.lang.String tableAlias, java.lang.String path, LockMode lockMode)
Declare a join fetch result, specifying a lock mode.NativeQuery<T>
addQueryHint(java.lang.String hint)
Add a DB query hint to the SQL.SQLQuery.RootReturn
addRoot(java.lang.String tableAlias, java.lang.Class entityType)
Add a new root return mapping, returning aSQLQuery.RootReturn
to allow further definition.SQLQuery.RootReturn
addRoot(java.lang.String tableAlias, java.lang.String entityName)
Add a new root return mapping, returning aSQLQuery.RootReturn
to allow further definition.NativeQuery<T>
addScalar(java.lang.String columnAlias)
Declare a scalar query result.NativeQuery<T>
addScalar(java.lang.String columnAlias, Type type)
Declare a scalar query result.NativeQuery<T>
addSynchronizedEntityClass(java.lang.Class entityClass)
Adds an entity for (a) auto-flush checking and (b) query result cache invalidation checking.NativeQuery<T>
addSynchronizedEntityName(java.lang.String entityName)
Adds an entity name for (a) auto-flush checking and (b) query result cache invalidation checking.NativeQuery<T>
addSynchronizedQuerySpace(java.lang.String querySpace)
Adds a query space.boolean
isCallable()
Is this native-SQL query known to be callable?NativeQuery<T>
setCacheable(boolean cacheable)
Enable/disable second level query (result) caching for this query.NativeQuery<T>
setCacheMode(CacheMode cacheMode)
(Re)set the current CacheMode in effect for this query.NativeQuery<T>
setCacheRegion(java.lang.String cacheRegion)
Set the name of the cache region where query results should be cached (if cached at all).NativeQuery<T>
setComment(java.lang.String comment)
Set the comment for this query.NativeQuery<T>
setFetchSize(int fetchSize)
Sets a JDBC fetch size hint for the query.NativeQuery<T>
setFirstResult(int startPosition)
NativeQuery<T>
setFlushMode(FlushModeType flushMode)
NativeQuery<T>
setFlushMode(FlushMode flushMode)
(Re)set the current FlushMode in effect for this query.NativeQuery<T>
setHibernateFlushMode(FlushMode flushMode)
(Re)set the current FlushMode in effect for this query.NativeQuery<T>
setHint(java.lang.String hintName, java.lang.Object value)
NativeQuery<T>
setLockMode(java.lang.String alias, LockMode lockMode)
Set the LockMode to use for specific alias (as defined in the query's FROM clause).NativeQuery<T>
setLockMode(LockModeType lockMode)
NativeQuery<T>
setLockOptions(LockOptions lockOptions)
Set the lock options for the query.NativeQuery<T>
setMaxResults(int maxResult)
NativeQuery<T>
setParameter(int position, java.lang.Object value)
Bind a positional query parameter using its inferred Type.NativeQuery<T>
setParameter(int position, java.lang.Object val, TemporalType temporalType)
Bind a positional query parameter as some form of date/time using the indicated temporal-type.NativeQuery<T>
setParameter(int position, java.lang.Object val, Type type)
Bind a value to a JDBC-style query parameter.NativeQuery<T>
setParameter(int position, java.time.Instant value, TemporalType temporalType)
NativeQuery<T>
setParameter(int position, java.time.LocalDateTime value, TemporalType temporalType)
NativeQuery<T>
setParameter(int position, java.time.OffsetDateTime value, TemporalType temporalType)
NativeQuery<T>
setParameter(int position, java.time.ZonedDateTime value, TemporalType temporalType)
NativeQuery<T>
setParameter(int position, java.util.Calendar value, TemporalType temporalType)
NativeQuery<T>
setParameter(int position, java.util.Date value, TemporalType temporalType)
NativeQuery<T>
setParameter(java.lang.String name, java.lang.Object value)
Bind a named query parameter using its inferred Type.NativeQuery<T>
setParameter(java.lang.String name, java.lang.Object val, TemporalType temporalType)
Bind a named query parameter as some form of date/time using the indicated temporal-type.NativeQuery<T>
setParameter(java.lang.String name, java.lang.Object val, Type type)
Bind a named query parameter using the supplied TypeNativeQuery<T>
setParameter(java.lang.String name, java.time.Instant value, TemporalType temporalType)
NativeQuery<T>
setParameter(java.lang.String name, java.time.LocalDateTime value, TemporalType temporalType)
NativeQuery<T>
setParameter(java.lang.String name, java.time.OffsetDateTime value, TemporalType temporalType)
NativeQuery<T>
setParameter(java.lang.String name, java.time.ZonedDateTime value, TemporalType temporalType)
NativeQuery<T>
setParameter(java.lang.String name, java.util.Calendar value, TemporalType temporalType)
NativeQuery<T>
setParameter(java.lang.String name, java.util.Date value, TemporalType temporalType)
NativeQuery<T>
setParameter(Parameter<java.time.Instant> param, java.time.Instant value, TemporalType temporalType)
NativeQuery<T>
setParameter(Parameter<java.time.LocalDateTime> param, java.time.LocalDateTime value, TemporalType temporalType)
NativeQuery<T>
setParameter(Parameter<java.time.OffsetDateTime> param, java.time.OffsetDateTime value, TemporalType temporalType)
NativeQuery<T>
setParameter(Parameter<java.time.ZonedDateTime> param, java.time.ZonedDateTime value, TemporalType temporalType)
NativeQuery<T>
setParameter(Parameter<java.util.Calendar> param, java.util.Calendar value, TemporalType temporalType)
NativeQuery<T>
setParameter(Parameter<java.util.Date> param, java.util.Date value, TemporalType temporalType)
<P> NativeQuery<T>
setParameter(Parameter<P> param, P value)
<P> NativeQuery<T>
setParameter(QueryParameter<P> parameter, P val)
Bind a query parameter using its inferred Type.<P> NativeQuery<T>
setParameter(QueryParameter<P> parameter, P val, TemporalType temporalType)
Bind a query parameter as some form of date/time using the indicated temporal-type.<P> NativeQuery<T>
setParameter(QueryParameter<P> parameter, P val, Type type)
Bind a query parameter using the supplied TypeNativeQuery<T>
setParameterList(java.lang.String name, java.lang.Object[] values)
Bind multiple values to a named query parameter.NativeQuery<T>
setParameterList(java.lang.String name, java.lang.Object[] values, Type type)
Bind multiple values to a named query parameter.NativeQuery<T>
setParameterList(java.lang.String name, java.util.Collection values)
Bind multiple values to a named query parameter.NativeQuery<T>
setParameterList(java.lang.String name, java.util.Collection values, Type type)
Bind multiple values to a named query parameter.<P> NativeQuery<T>
setParameterList(QueryParameter<P> parameter, java.util.Collection<P> values)
Bind multiple values to a query parameter using its inferred Type.NativeQuery<T>
setProperties(java.lang.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.NativeQuery<T>
setProperties(java.util.Map bean)
Bind the values of the given Map for each named parameters of the query, matching key names with parameter names and mapping value types to Hibernate types using heuristics.NativeQuery<T>
setReadOnly(boolean readOnly)
Set the read-only/modifiable mode for entities and proxies loaded by this Query.NativeQuery<T>
setResultSetMapping(java.lang.String name)
Use a predefined named result-set mapping.NativeQuery<T>
setTimeout(int timeout)
Set the query timeout in seconds.-
Methods inherited from interface javax.persistence.Query
executeUpdate, getFirstResult, getHints, getLockMode, getMaxResults, getParameter, getParameter, getParameter, getParameter, getParameters, getParameterValue, getParameterValue, getParameterValue, isBound, unwrap
-
Methods inherited from interface org.hibernate.Query
determineProperBooleanType, determineProperBooleanType, getFlushMode, getHibernateFirstResult, getHibernateMaxResults, getNamedParameters, getQueryOptions, getReturnAliases, getReturnTypes, getTimeout, isCacheable, isReadOnly, iterate, setHibernateFirstResult, setHibernateMaxResults, setParameterList, setParameterList, setParameterList, setParameterList
-
Methods inherited from interface org.hibernate.query.Query
getCacheMode, getCacheRegion, getComment, getFetchSize, getHibernateFlushMode, getLockOptions, getParameterMetadata, getProducer, getQueryString, getResultList, getResultStream, getSingleResult, list, scroll, scroll, setBigDecimal, setBigDecimal, setBigInteger, setBigInteger, setBinary, setBinary, setBoolean, setBoolean, setByte, setByte, setCalendar, setCalendar, setCalendarDate, setCalendarDate, setCharacter, setCharacter, setDate, setDate, setDouble, setDouble, setEntity, setEntity, setFloat, setFloat, setInteger, setInteger, setLocale, setLocale, setLong, setLong, setParameters, setResultTransformer, setSerializable, setSerializable, setShort, setShort, setString, setString, setText, setText, setTime, setTime, setTimestamp, setTimestamp, stream, uniqueResult, uniqueResultOptional
-
Methods inherited from interface org.hibernate.SQLQuery
getQueryReturns
-
Methods inherited from interface org.hibernate.SynchronizeableQuery
addSynchronizedEntityClass, addSynchronizedEntityName, addSynchronizedQuerySpace, addSynchronizedTable, addSynchronizedTable, getSynchronizedQuerySpaces
-
-
-
-
Method Detail
-
setFlushMode
NativeQuery<T> setFlushMode(FlushMode flushMode)
Description copied from interface:Query
(Re)set the current FlushMode in effect for this query.- Specified by:
setFlushMode
in interfaceBasicQueryContract<T>
- Specified by:
setFlushMode
in interfaceQuery<T>
- Specified by:
setFlushMode
in interfaceQuery<T>
- Specified by:
setFlushMode
in interfaceSQLQuery<T>
- Parameters:
flushMode
- The new FlushMode to use.- Returns:
this
, for method chaining- See Also:
Query.getHibernateFlushMode()
-
setResultSetMapping
NativeQuery<T> setResultSetMapping(java.lang.String name)
Description copied from interface:SQLQuery
Use a predefined named result-set mapping. This might be defined by a<result-set/>
element in a Hibernate hbm.xml file or through aSqlResultSetMapping
annotation.- Specified by:
setResultSetMapping
in interfaceSQLQuery<T>
- Parameters:
name
- The name of the mapping to use.- Returns:
- this, for method chaining
-
setParameter
<P> NativeQuery<T> setParameter(QueryParameter<P> parameter, P val)
Description copied from interface:Query
Bind a query parameter using its inferred Type. If the parameter is defined in such a way that the Type cannot be inferred from its usage context then use of this form of binding is not allowed, andQuery.setParameter(QueryParameter, Object, Type)
should be used instead- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceSQLQuery<T>
- Parameters:
parameter
- The query parameter mementoval
- the possibly-null parameter value- Returns:
this
, for method chaining
-
setParameter
<P> NativeQuery<T> setParameter(Parameter<P> param, P value)
- Specified by:
setParameter
in interfaceQuery
- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceSQLQuery<T>
- Specified by:
setParameter
in interfaceTypedQuery<T>
-
setParameter
<P> NativeQuery<T> setParameter(QueryParameter<P> parameter, P val, Type type)
Description copied from interface:Query
Bind a query parameter using the supplied Type- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceSQLQuery<T>
- Parameters:
parameter
- The query parameter mementoval
- the possibly-null parameter valuetype
- the Hibernate type- Returns:
this
, for method chaining
-
setParameter
NativeQuery<T> setParameter(java.lang.String name, java.lang.Object val, Type type)
Description copied from interface:Query
Bind a named query parameter using the supplied Type- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceSQLQuery<T>
- Parameters:
name
- the name of the parameterval
- the possibly-null parameter valuetype
- the Hibernate type- Returns:
this
, for method chaining
-
setParameter
NativeQuery<T> setParameter(int position, java.lang.Object val, Type type)
Description copied from interface:Query
Bind a value to a JDBC-style query parameter.- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceSQLQuery<T>
- Parameters:
position
- the position of the parameter in the query string, numbered from 0.val
- the possibly-null parameter valuetype
- the Hibernate type- Returns:
this
, for method chaining
-
setParameter
<P> NativeQuery<T> setParameter(QueryParameter<P> parameter, P val, TemporalType temporalType)
Description copied from interface:Query
Bind a query parameter as some form of date/time using the indicated temporal-type.- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceSQLQuery<T>
- Parameters:
parameter
- The query parameter mementoval
- the possibly-null parameter valuetemporalType
- the temporal-type to use in binding the date/time- Returns:
this
, for method chaining
-
setParameter
NativeQuery<T> setParameter(java.lang.String name, java.lang.Object val, TemporalType temporalType)
Description copied from interface:Query
Bind a named query parameter as some form of date/time using the indicated temporal-type.- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceSQLQuery<T>
- Parameters:
name
- the parameter nameval
- the possibly-null parameter valuetemporalType
- the temporal-type to use in binding the date/time- Returns:
this
, for method chaining
-
setParameter
NativeQuery<T> setParameter(int position, java.lang.Object val, TemporalType temporalType)
Description copied from interface:Query
Bind a positional query parameter as some form of date/time using the indicated temporal-type.- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceSQLQuery<T>
- Parameters:
position
- the position of the parameter in the query string, numbered from 0.val
- the possibly-null parameter valuetemporalType
- the temporal-type to use in binding the date/time- Returns:
this
, for method chaining
-
setParameter
NativeQuery<T> setParameter(Parameter<java.util.Calendar> param, java.util.Calendar value, TemporalType temporalType)
- Specified by:
setParameter
in interfaceQuery
- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceSQLQuery<T>
- Specified by:
setParameter
in interfaceTypedQuery<T>
-
setParameter
NativeQuery<T> setParameter(Parameter<java.util.Date> param, java.util.Date value, TemporalType temporalType)
- Specified by:
setParameter
in interfaceQuery
- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceSQLQuery<T>
- Specified by:
setParameter
in interfaceTypedQuery<T>
-
setParameter
NativeQuery<T> setParameter(java.lang.String name, java.lang.Object value)
Description copied from interface:Query
Bind a named query parameter using its inferred Type. If the parameter is defined in such a way that the Type cannot be inferred from its usage context then use of this form of binding is not allowed, andQuery.setParameter(String, Object, Type)
should be used instead- Specified by:
setParameter
in interfaceQuery
- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceSQLQuery<T>
- Specified by:
setParameter
in interfaceTypedQuery<T>
- Parameters:
name
- the parameter namevalue
- the (possibly-null) parameter value- Returns:
this
, for method chaining
-
setParameter
NativeQuery<T> setParameter(java.lang.String name, java.util.Calendar value, TemporalType temporalType)
- Specified by:
setParameter
in interfaceQuery
- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceSQLQuery<T>
- Specified by:
setParameter
in interfaceTypedQuery<T>
-
setParameter
NativeQuery<T> setParameter(java.lang.String name, java.util.Date value, TemporalType temporalType)
- Specified by:
setParameter
in interfaceQuery
- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceSQLQuery<T>
- Specified by:
setParameter
in interfaceTypedQuery<T>
-
setParameter
NativeQuery<T> setParameter(int position, java.lang.Object value)
Description copied from interface:Query
Bind a positional query parameter using its inferred Type. If the parameter is defined in such a way that the Type cannot be inferred from its usage context then use of this form of binding is not allowed, andQuery.setParameter(int, Object, Type)
should be used instead- Specified by:
setParameter
in interfaceQuery
- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceSQLQuery<T>
- Specified by:
setParameter
in interfaceTypedQuery<T>
- Parameters:
position
- the position of the parameter in the query string, numbered from 0.value
- the possibly-null parameter value- Returns:
this
, for method chaining
-
setParameter
NativeQuery<T> setParameter(int position, java.util.Calendar value, TemporalType temporalType)
- Specified by:
setParameter
in interfaceQuery
- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceSQLQuery<T>
- Specified by:
setParameter
in interfaceTypedQuery<T>
-
setParameter
NativeQuery<T> setParameter(int position, java.util.Date value, TemporalType temporalType)
- Specified by:
setParameter
in interfaceQuery
- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceQuery<T>
- Specified by:
setParameter
in interfaceSQLQuery<T>
- Specified by:
setParameter
in interfaceTypedQuery<T>
-
setParameter
NativeQuery<T> setParameter(Parameter<java.time.Instant> param, java.time.Instant value, TemporalType temporalType)
- Specified by:
setParameter
in interfaceQuery<T>
-
setParameter
NativeQuery<T> setParameter(Parameter<java.time.LocalDateTime> param, java.time.LocalDateTime value, TemporalType temporalType)
- Specified by:
setParameter
in interfaceQuery<T>
-
setParameter
NativeQuery<T> setParameter(Parameter<java.time.ZonedDateTime> param, java.time.ZonedDateTime value, TemporalType temporalType)
- Specified by:
setParameter
in interfaceQuery<T>
-
setParameter
NativeQuery<T> setParameter(Parameter<java.time.OffsetDateTime> param, java.time.OffsetDateTime value, TemporalType temporalType)
- Specified by:
setParameter
in interfaceQuery<T>
-
setParameter
NativeQuery<T> setParameter(java.lang.String name, java.time.Instant value, TemporalType temporalType)
- Specified by:
setParameter
in interfaceQuery<T>
-
setParameter
NativeQuery<T> setParameter(java.lang.String name, java.time.LocalDateTime value, TemporalType temporalType)
- Specified by:
setParameter
in interfaceQuery<T>
-
setParameter
NativeQuery<T> setParameter(java.lang.String name, java.time.ZonedDateTime value, TemporalType temporalType)
- Specified by:
setParameter
in interfaceQuery<T>
-
setParameter
NativeQuery<T> setParameter(java.lang.String name, java.time.OffsetDateTime value, TemporalType temporalType)
- Specified by:
setParameter
in interfaceQuery<T>
-
setParameter
NativeQuery<T> setParameter(int position, java.time.Instant value, TemporalType temporalType)
- Specified by:
setParameter
in interfaceQuery<T>
-
setParameter
NativeQuery<T> setParameter(int position, java.time.LocalDateTime value, TemporalType temporalType)
- Specified by:
setParameter
in interfaceQuery<T>
-
setParameter
NativeQuery<T> setParameter(int position, java.time.ZonedDateTime value, TemporalType temporalType)
- Specified by:
setParameter
in interfaceQuery<T>
-
setParameter
NativeQuery<T> setParameter(int position, java.time.OffsetDateTime value, TemporalType temporalType)
- Specified by:
setParameter
in interfaceQuery<T>
-
setParameterList
<P> NativeQuery<T> setParameterList(QueryParameter<P> parameter, java.util.Collection<P> values)
Description copied from interface:Query
Bind multiple values to a query parameter using its inferred Type. The Hibernate type of the parameter values is first detected via the usage/position in the query and if not sufficient secondly guessed from the class of the first object in the collection. This is useful for binding a list of values to an expression such as foo.bar in (:value_list).- Specified by:
setParameterList
in interfaceQuery<T>
- Specified by:
setParameterList
in interfaceQuery<T>
- Specified by:
setParameterList
in interfaceSQLQuery<T>
- Parameters:
parameter
- the parameter mementovalues
- a collection of values to list- Returns:
this
, for method chaining
-
setParameterList
NativeQuery<T> setParameterList(java.lang.String name, java.util.Collection values)
Description copied from interface:Query
Bind multiple values to a named query parameter. The Hibernate type of the parameter is first detected via the usage/position in the query and if not sufficient secondly guessed from the class of the first object in the collection. This is useful for binding a list of values to an expression such as foo.bar in (:value_list).- Specified by:
setParameterList
in interfaceQuery<T>
- Specified by:
setParameterList
in interfaceQuery<T>
- Specified by:
setParameterList
in interfaceSQLQuery<T>
- Parameters:
name
- the name of the parametervalues
- a collection of values to list- Returns:
this
, for method chaining
-
setParameterList
NativeQuery<T> setParameterList(java.lang.String name, java.util.Collection values, Type type)
Description copied from interface:Query
Bind multiple values to a named query parameter. This is useful for binding a list of values to an expression such as foo.bar in (:value_list).- Specified by:
setParameterList
in interfaceQuery<T>
- Specified by:
setParameterList
in interfaceQuery<T>
- Specified by:
setParameterList
in interfaceSQLQuery<T>
- Parameters:
name
- the name of the parametervalues
- a collection of values to listtype
- the Hibernate type of the values- Returns:
this
, for method chaining
-
setParameterList
NativeQuery<T> setParameterList(java.lang.String name, java.lang.Object[] values, Type type)
Description copied from interface:Query
Bind multiple values to a named query parameter. This is useful for binding a list of values to an expression such as foo.bar in (:value_list).- Specified by:
setParameterList
in interfaceQuery<T>
- Specified by:
setParameterList
in interfaceQuery<T>
- Specified by:
setParameterList
in interfaceSQLQuery<T>
- Parameters:
name
- the name of the parametervalues
- a collection of values to listtype
- the Hibernate type of the values- Returns:
this
, for method chaining
-
setParameterList
NativeQuery<T> setParameterList(java.lang.String name, java.lang.Object[] values)
Description copied from interface:Query
Bind multiple values to a named query parameter. The Hibernate type of the parameter is first detected via the usage/position in the query and if not sufficient secondly guessed from the class of the first object in the array. This is useful for binding a list of values to an expression such as foo.bar in (:value_list).- Specified by:
setParameterList
in interfaceQuery<T>
- Specified by:
setParameterList
in interfaceQuery<T>
- Specified by:
setParameterList
in interfaceSQLQuery<T>
- Parameters:
name
- the name of the parametervalues
- a collection of values to list- Returns:
this
, for method chaining
-
setProperties
NativeQuery<T> setProperties(java.lang.Object bean)
Description copied from interface:Query
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.- Specified by:
setProperties
in interfaceQuery<T>
- Specified by:
setProperties
in interfaceQuery<T>
- Specified by:
setProperties
in interfaceSQLQuery<T>
- Parameters:
bean
- any JavaBean or POJO- Returns:
this
, for method chaining
-
setProperties
NativeQuery<T> setProperties(java.util.Map bean)
Description copied from interface:Query
Bind the values of the given Map for each named parameters of the query, matching key names with parameter names and mapping value types to Hibernate types using heuristics.- Specified by:
setProperties
in interfaceQuery<T>
- Specified by:
setProperties
in interfaceQuery<T>
- Specified by:
setProperties
in interfaceSQLQuery<T>
- Parameters:
bean
- a java.util.Map- Returns:
this
, for method chaining
-
addSynchronizedQuerySpace
NativeQuery<T> addSynchronizedQuerySpace(java.lang.String querySpace)
Description copied from interface:SynchronizeableQuery
Adds a query space.- Specified by:
addSynchronizedQuerySpace
in interfaceSQLQuery<T>
- Specified by:
addSynchronizedQuerySpace
in interfaceSynchronizeableQuery<T>
- Parameters:
querySpace
- The query space to be auto-flushed for this query.- Returns:
this
, for method chaining
-
addSynchronizedEntityName
NativeQuery<T> addSynchronizedEntityName(java.lang.String entityName) throws MappingException
Description copied from interface:SynchronizeableQuery
Adds an entity name for (a) auto-flush checking and (b) query result cache invalidation checking. Same asSynchronizeableQuery.addSynchronizedQuerySpace(java.lang.String)
for all tables associated with the given entity.- Specified by:
addSynchronizedEntityName
in interfaceSQLQuery<T>
- Specified by:
addSynchronizedEntityName
in interfaceSynchronizeableQuery<T>
- Parameters:
entityName
- The name of the entity upon whose defined query spaces we should additionally synchronize.- Returns:
this
, for method chaining- Throws:
MappingException
- Indicates the given name could not be resolved as an entity
-
addSynchronizedEntityClass
NativeQuery<T> addSynchronizedEntityClass(java.lang.Class entityClass) throws MappingException
Description copied from interface:SynchronizeableQuery
Adds an entity for (a) auto-flush checking and (b) query result cache invalidation checking. Same asSynchronizeableQuery.addSynchronizedQuerySpace(java.lang.String)
for all tables associated with the given entity.- Specified by:
addSynchronizedEntityClass
in interfaceSQLQuery<T>
- Specified by:
addSynchronizedEntityClass
in interfaceSynchronizeableQuery<T>
- Parameters:
entityClass
- The class of the entity upon whose defined query spaces we should additionally synchronize.- Returns:
this
, for method chaining- Throws:
MappingException
- Indicates the given class could not be resolved as an entity
-
isCallable
boolean isCallable()
Description copied from interface:SQLQuery
Is this native-SQL query known to be callable?- Specified by:
isCallable
in interfaceSQLQuery<T>
- Returns:
true
if the query is known to be callable;false
otherwise.
-
addScalar
NativeQuery<T> addScalar(java.lang.String columnAlias)
Description copied from interface:SQLQuery
Declare a scalar query result. Hibernate will attempt to automatically detect the underlying type. Functions like<return-scalar/>
inhbm.xml
orColumnResult
-
addScalar
NativeQuery<T> addScalar(java.lang.String columnAlias, Type type)
Description copied from interface:SQLQuery
-
addRoot
SQLQuery.RootReturn addRoot(java.lang.String tableAlias, java.lang.String entityName)
Description copied from interface:SQLQuery
Add a new root return mapping, returning aSQLQuery.RootReturn
to allow further definition.
-
addRoot
SQLQuery.RootReturn addRoot(java.lang.String tableAlias, java.lang.Class entityType)
Description copied from interface:SQLQuery
Add a new root return mapping, returning aSQLQuery.RootReturn
to allow further definition.
-
addEntity
NativeQuery<T> addEntity(java.lang.String entityName)
Description copied from interface:SQLQuery
Declare a "root" entity, without specifying an alias. The expectation here is that the table alias is the same as the unqualified entity name UseSQLQuery.addRoot(java.lang.String, java.lang.String)
if you need further control of the mapping
-
addEntity
NativeQuery<T> addEntity(java.lang.String tableAlias, java.lang.String entityName)
Description copied from interface:SQLQuery
Declare a "root" entity.
-
addEntity
NativeQuery<T> addEntity(java.lang.String tableAlias, java.lang.String entityName, LockMode lockMode)
Description copied from interface:SQLQuery
Declare a "root" entity, specifying a lock mode.
-
addEntity
NativeQuery<T> addEntity(java.lang.Class entityType)
Description copied from interface:SQLQuery
Declare a "root" entity, without specifying an alias. The expectation here is that the table alias is the same as the unqualified entity name
-
addEntity
NativeQuery<T> addEntity(java.lang.String tableAlias, java.lang.Class entityType)
Description copied from interface:SQLQuery
Declare a "root" entity.
-
addEntity
NativeQuery<T> addEntity(java.lang.String tableAlias, java.lang.Class entityClass, LockMode lockMode)
Description copied from interface:SQLQuery
Declare a "root" entity, specifying a lock mode.
-
addFetch
SQLQuery.FetchReturn addFetch(java.lang.String tableAlias, java.lang.String ownerTableAlias, java.lang.String joinPropertyName)
Description copied from interface:SQLQuery
Declare a join fetch result.- Specified by:
addFetch
in interfaceSQLQuery<T>
- Parameters:
tableAlias
- The SQL table alias for the data to be mapped to this fetchownerTableAlias
- Identify the table alias of the owner of this association. Should match the alias of a previously added root or fetchjoinPropertyName
- The name of the property being join fetched.- Returns:
- The return config object for further control.
-
addJoin
NativeQuery<T> addJoin(java.lang.String tableAlias, java.lang.String path)
Description copied from interface:SQLQuery
Declare a join fetch result.
-
addJoin
NativeQuery<T> addJoin(java.lang.String tableAlias, java.lang.String ownerTableAlias, java.lang.String joinPropertyName)
Description copied from interface:SQLQuery
Declare a join fetch result.- Specified by:
addJoin
in interfaceSQLQuery<T>
- Parameters:
tableAlias
- The SQL table alias for the data to be mapped to this fetchownerTableAlias
- Identify the table alias of the owner of this association. Should match the alias of a previously added root or fetchjoinPropertyName
- The name of the property being join fetched.- Returns:
this
, for method chaining
-
addJoin
NativeQuery<T> addJoin(java.lang.String tableAlias, java.lang.String path, LockMode lockMode)
Description copied from interface:SQLQuery
Declare a join fetch result, specifying a lock mode.
-
setHibernateFlushMode
NativeQuery<T> setHibernateFlushMode(FlushMode flushMode)
Description copied from interface:Query
(Re)set the current FlushMode in effect for this query.- Specified by:
setHibernateFlushMode
in interfaceBasicQueryContract<T>
- Specified by:
setHibernateFlushMode
in interfaceQuery<T>
- Specified by:
setHibernateFlushMode
in interfaceQuery<T>
- Specified by:
setHibernateFlushMode
in interfaceSQLQuery<T>
- Parameters:
flushMode
- The new FlushMode to use.- Returns:
this
, for method chaining- See Also:
Query.getHibernateFlushMode()
-
setFlushMode
NativeQuery<T> setFlushMode(FlushModeType flushMode)
- Specified by:
setFlushMode
in interfaceQuery
- Specified by:
setFlushMode
in interfaceQuery<T>
- Specified by:
setFlushMode
in interfaceQuery<T>
- Specified by:
setFlushMode
in interfaceSQLQuery<T>
- Specified by:
setFlushMode
in interfaceTypedQuery<T>
-
setCacheMode
NativeQuery<T> setCacheMode(CacheMode cacheMode)
Description copied from interface:Query
(Re)set the current CacheMode in effect for this query.- Specified by:
setCacheMode
in interfaceBasicQueryContract<T>
- Specified by:
setCacheMode
in interfaceQuery<T>
- Specified by:
setCacheMode
in interfaceQuery<T>
- Specified by:
setCacheMode
in interfaceSQLQuery<T>
- Parameters:
cacheMode
- The new CacheMode to use.- Returns:
this
, for method chaining- See Also:
Query.getCacheMode()
-
setCacheable
NativeQuery<T> setCacheable(boolean cacheable)
Description copied from interface:Query
Enable/disable second level query (result) caching for this query.- Specified by:
setCacheable
in interfaceBasicQueryContract<T>
- Specified by:
setCacheable
in interfaceQuery<T>
- Specified by:
setCacheable
in interfaceQuery<T>
- Specified by:
setCacheable
in interfaceSQLQuery<T>
- Parameters:
cacheable
- Should the query results be cacheable?- Returns:
this
, for method chaining- See Also:
Query.isCacheable()
-
setCacheRegion
NativeQuery<T> setCacheRegion(java.lang.String cacheRegion)
Description copied from interface:Query
Set the name of the cache region where query results should be cached (if cached at all).- Specified by:
setCacheRegion
in interfaceBasicQueryContract<T>
- Specified by:
setCacheRegion
in interfaceQuery<T>
- Specified by:
setCacheRegion
in interfaceQuery<T>
- Specified by:
setCacheRegion
in interfaceSQLQuery<T>
- Parameters:
cacheRegion
- the name of a query cache region, ornull
to indicate that the default region should be used.- Returns:
this
, for method chaining- See Also:
Query.getCacheRegion()
-
setTimeout
NativeQuery<T> setTimeout(int timeout)
Description copied from interface:Query
Set the query timeout in seconds. NOTE it is important to understand that any value set here is eventually passed directly through to the JDBC Statement which expressly disallows negative values. So negative values should be avoided as a general rule.- Specified by:
setTimeout
in interfaceBasicQueryContract<T>
- Specified by:
setTimeout
in interfaceQuery<T>
- Specified by:
setTimeout
in interfaceQuery<T>
- Specified by:
setTimeout
in interfaceSQLQuery<T>
- Parameters:
timeout
- the timeout in seconds- Returns:
this
, for method chaining- See Also:
Query.getTimeout()
-
setFetchSize
NativeQuery<T> setFetchSize(int fetchSize)
Description copied from interface:Query
Sets a JDBC fetch size hint for the query.- Specified by:
setFetchSize
in interfaceBasicQueryContract<T>
- Specified by:
setFetchSize
in interfaceQuery<T>
- Specified by:
setFetchSize
in interfaceQuery<T>
- Specified by:
setFetchSize
in interfaceSQLQuery<T>
- Parameters:
fetchSize
- the fetch size hint- Returns:
this
, for method chaining- See Also:
Query.getFetchSize()
-
setReadOnly
NativeQuery<T> setReadOnly(boolean readOnly)
Description copied from interface:Query
Set the read-only/modifiable mode for entities and proxies loaded by this Query. This setting overrides the default setting for the persistence context.- Specified by:
setReadOnly
in interfaceBasicQueryContract<T>
- Specified by:
setReadOnly
in interfaceQuery<T>
- Specified by:
setReadOnly
in interfaceQuery<T>
- Specified by:
setReadOnly
in interfaceSQLQuery<T>
- Parameters:
readOnly
-true
indicates that entities and proxies loaded by the query are to be put in read-only mode;false
indicates that entities and proxies loaded by the query will be put in modifiable mode- Returns:
this
, for method chaining- See Also:
To set the default read-only/modifiable setting used for entities and proxies that are loaded into the session:
,PersistenceContext.setDefaultReadOnly(boolean)
,Read-only entities are not dirty-checked and snapshots of persistent state are not maintained. Read-only entities can be modified, but changes are not persisted. When a proxy is initialized, the loaded entity will have the same read-only/modifiable setting as the uninitialized proxy has, regardless of the session's current setting. The read-only/modifiable setting has no impact on entities/proxies returned by the query that existed in the session before the query was executed.
-
setLockOptions
NativeQuery<T> setLockOptions(LockOptions lockOptions)
Description copied from interface:Query
Set the lock options for the query. Specifically only the following are taken into consideration: For alias-specific locking, useQuery.setLockMode(String, LockMode)
.- Specified by:
setLockOptions
in interfaceQuery<T>
- Specified by:
setLockOptions
in interfaceQuery<T>
- Specified by:
setLockOptions
in interfaceSQLQuery<T>
- Parameters:
lockOptions
- The lock options to apply to the query.- Returns:
this
, for method chaining- See Also:
Query.getLockOptions()
-
setLockMode
NativeQuery<T> setLockMode(java.lang.String alias, LockMode lockMode)
Description copied from interface:Query
Set the LockMode to use for specific alias (as defined in the query's FROM clause). The alias-specific lock modes specified here are added to the query's internalLockOptions
. 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 (LockMode.PESSIMISTIC_WRITE
).- Specified by:
setLockMode
in interfaceQuery<T>
- Specified by:
setLockMode
in interfaceQuery<T>
- Specified by:
setLockMode
in interfaceSQLQuery<T>
- Parameters:
alias
- a query alias, or"this"
for a collection filterlockMode
- The lock mode to apply.- Returns:
this
, for method chaining- See Also:
Query.getLockOptions()
-
setComment
NativeQuery<T> setComment(java.lang.String comment)
Description copied from interface:Query
Set the comment for this query.- Specified by:
setComment
in interfaceQuery<T>
- Specified by:
setComment
in interfaceQuery<T>
- Specified by:
setComment
in interfaceSQLQuery<T>
- Parameters:
comment
- The human-readable comment- Returns:
this
, for method chaining- See Also:
Query.getComment()
-
addQueryHint
NativeQuery<T> addQueryHint(java.lang.String hint)
Description copied from interface:Query
Add a DB query hint to the SQL. These differ from JPA'sQueryHint
, which is specific to the JPA implementation and ignores DB vendor-specific hints. Instead, these are intended solely for the vendor-specific hints, such as Oracle's optimizers. Multiple query hints are supported; the Dialect will determine concatenation and placement.- Specified by:
addQueryHint
in interfaceQuery<T>
- Specified by:
addQueryHint
in interfaceQuery<T>
- Specified by:
addQueryHint
in interfaceSQLQuery<T>
- Parameters:
hint
- The database specific query hint to add.
-
setMaxResults
NativeQuery<T> setMaxResults(int maxResult)
- Specified by:
setMaxResults
in interfaceQuery
- Specified by:
setMaxResults
in interfaceQuery<T>
- Specified by:
setMaxResults
in interfaceQuery<T>
- Specified by:
setMaxResults
in interfaceTypedQuery<T>
-
setFirstResult
NativeQuery<T> setFirstResult(int startPosition)
- Specified by:
setFirstResult
in interfaceQuery
- Specified by:
setFirstResult
in interfaceQuery<T>
- Specified by:
setFirstResult
in interfaceQuery<T>
- Specified by:
setFirstResult
in interfaceTypedQuery<T>
-
setHint
NativeQuery<T> setHint(java.lang.String hintName, java.lang.Object value)
-
setLockMode
NativeQuery<T> setLockMode(LockModeType lockMode)
- Specified by:
setLockMode
in interfaceQuery
- Specified by:
setLockMode
in interfaceQuery<T>
- Specified by:
setLockMode
in interfaceQuery<T>
- Specified by:
setLockMode
in interfaceTypedQuery<T>
-
-