Along with the operations inherited from Query, this interface
provides control over:
A NativeQuery may be obtained from the org.
by calling:
QueryProducer#createNativeQuery(String, Class), passing
native SQL as a string, or
QueryProducer#createNativeQuery(String, String, Class)
passing the native SQL string and the name of a result set mapping
defined using jakarta.persistence.SqlResultSetMapping .
A result set mapping may be specified by:
jakarta.persistence.SqlResultSetMapping passed to
QueryProducer#createNativeQuery(String, String, Class),
jakarta.persistence.SqlResultSetMapping specified
using jakarta.persistence.NamedNativeQuery#resultSetMapping
for a named query, or
addEntity, addRoot,
addJoin, addFetch and addScalar methods
of this object.
The third option is a legacy of much older versions of Hibernate and is currently disfavored.
To determine if an automatic flush is required before execution of the query, Hibernate must know which tables affect the query result set. JPA provides no standard way to do this. Instead, this information may be provided via:
org.hibernate.annotations.NamedNativeQuery#querySpaces for
a named query, or
addSynchronizedEntityClass,
addSynchronizedEntityName, or
addSynchronizedQuerySpace.
Query, SynchronizeableQuery, QueryProducer
| Modifier and Type | Class and Description |
|---|---|
| public static interface | NativeQuery.CollectionReturn
Allows access to further control how collection returns are mapped back from result sets. |
| public static interface | NativeQuery.FetchReturn
Allows access to further control how join fetch returns are mapped back from result sets. |
| public static interface | |
| public static interface | NativeQuery.ResultNode
Simple unification interface for all returns from the various |
| public static interface | NativeQuery.ReturnableResultNode
A |
| public static interface | NativeQuery.ReturnProperty
Allows access to further control how properties within a root or join fetch are mapped back from the result set. |
| public static interface | NativeQuery.RootReturn
Allows access to further control how root returns are mapped back from result sets. |
| Modifier and Type | Method and Description |
|---|---|
| public NativeQuery | Returns: this, for method chainingDefines a result based on a specified attribute. |
| public NativeQuery | Returns: this, for method chainingDefines a result based on a specified attribute. |
| public NativeQuery | Returns: this, for method chainingDefines a result based on a specified attribute. |
| public NativeQuery | |
| public NativeQuery | |
| public NativeQuery | |
| public NativeQuery | |
| public NativeQuery | |
| public NativeQuery | |
| public NativeQuery. | Returns: The return config object for further control.The SQL table alias for the data to be mapped to this fetch. tableAlias, String Identify the table alias of the owner of this association.
Should match the alias of a previously added root or fetch. ownerTableAlias, String The name of the property being join fetched. joinPropertyName)Declare a join fetch result. |
| public <J> NativeQuery. | |
| public NativeQuery | |
| public NativeQuery | Returns: this, for method chainingThe SQL table alias for the data to be mapped to this fetch tableAlias, String Identify the table alias of the owner of this association.
Should match the alias of a previously added root or fetch. ownerTableAlias, String The name of the property being join fetched. joinPropertyName)Declare a join fetch result. |
| public NativeQuery | |
| public NativeQuery | addQueryHint(String
The database specific query hint to add. hint)Redeclares org. |
| public NativeQuery. | Returns: The return config object for further control.The SQL table alias to map to this entity tableAlias, String The name of the entity entityName)Add a new root return mapping, returning a |
| public NativeQuery. | Returns: The return config object for further control.The SQL table alias to map to this entity tableAlias, Class<T> The java type of the entity entityType)Add a new root return mapping, returning a |
| public NativeQuery | |
| public NativeQuery | Returns: this, for method chainingThe column alias in the result set to be
processed as a scalar result columnAlias, BasicTypeReference<T> The Hibernate type as which to treat the value. type)Declare a scalar query result. |
| public NativeQuery | Returns: this, for method chainingThe column alias in the result set to be
processed as a scalar result columnAlias, BasicDomainType<J> The Hibernate type as which to treat the value. type)Declare a scalar query result. |
| public NativeQuery | |
| public <C> NativeQuery | Returns: this, for method chainingThe Java type expected by the converter as its
"relational" type. relationalJavaType, AttributeConverter<?, C> The conversion to apply. Consumes the JDBC value based
on converter)relationalJavaType.Declare a scalar query result with an explicit conversion. |
| public <O, R> NativeQuery | Returns: this, for method chainingThe Java type expected by the converter as its
"object model" type. domainJavaType, Class<R> The Java type expected by the converter as its
"relational model" type. jdbcJavaType, AttributeConverter<O, R> The conversion to apply. Consumes the JDBC value based
on converter)relationalJavaType.Declare a scalar query result with an explicit conversion. |
| public <C> NativeQuery | Returns: this, for method chainingThe Java type expected by the converter as its
"relational" type. relationalJavaType, Class<? extends AttributeConverter<?, C>> The conversion to apply. Consumes the JDBC value based
on converter)relationalJavaType.Declare a scalar query result with an explicit conversion. |
| public <O, R> NativeQuery | Returns: this, for method chainingThe Java type expected by the converter as its
"object model" type. domainJavaType, Class<R> The Java type expected by the converter as its
"relational model" type. jdbcJavaType, Class<? extends AttributeConverter<O, R>> The conversion to apply. Consumes the JDBC value
based on converter)relationalJavaType.Declare a scalar query result with an explicit conversion. |
| public NativeQuery | addSynchronizedEntityClass(Class<T>
The class of the entity. entityClass)Redeclares org. |
| public NativeQuery | addSynchronizedEntityName(String
The name of an entity. entityName)Redeclares org. |
| public NativeQuery | addSynchronizedQuerySpace(String
The name of the query space, usually the name of a database table. querySpace)Redeclares org. |
| public LockMode | getHibernateLockMode()
Redeclares org. LockMode for the query
|
| public LockModeType | getLockMode()
Redeclares org. |
| public LockOptions | getLockOptions()
Redeclares org. LockOptions in effect for this query.
|
| public NativeQuery | setCacheable(boolean cacheable)
Redeclares org. |
| public NativeQuery | setCacheMode(CacheMode cacheMode)
Redeclares org. CacheMode in effect for this query.
|
| public NativeQuery | setCacheRegion(String cacheRegion)
Redeclares org. isCacheable).
|
| public NativeQuery | setCacheRetrieveMode(CacheRetrieveMode cacheRetrieveMode)
Redeclares org. |
| public NativeQuery | setCacheStoreMode(CacheStoreMode cacheStoreMode)
Redeclares org. |
| public NativeQuery | setComment(String
The human-readable comment comment)Redeclares org. |
| public NativeQuery | setFetchSize(int
the fetch size hint fetchSize)Redeclares org. |
| public NativeQuery | setFirstResult(int
position of the first result,
numbered from 0 startPosition)Redeclares org. |
| public NativeQuery | setFlushMode(FlushModeType
flush mode flushMode)Redeclares org. |
| public NativeQuery | setHibernateFlushMode(FlushMode flushMode)
Redeclares org. FlushMode in effect for this query.
|
| public NativeQuery | setHibernateLockMode(LockMode lockMode)
Redeclares org. LockMode for the query
|
| public NativeQuery | setHint(String
name of property or hint hintName, Object value for the property or hint value)Redeclares org. |
| public NativeQuery | setLockMode(String
A query alias alias, LockMode The lock mode to apply lockMode)Redeclares org. |
| public NativeQuery | setLockMode(LockModeType
lock mode lockMode)Redeclares org. |
| public NativeQuery | setLockOptions(LockOptions
The lock options to apply to the query. lockOptions)Redeclares org. |
| public NativeQuery | setMaxResults(int
maximum number of results to retrieve maxResult)Redeclares org. |
| public NativeQuery | setParameter(String
parameter name name, Object parameter value value)Redeclares org. |
| public <P> NativeQuery | setParameter(String name, P val, Class<P> type)
Redeclares org. BindableType
to use.
|
| public <P> NativeQuery | setParameter(String name, P val, BindableType<P> type)
Redeclares org. BindableType.
|
| public NativeQuery | setParameter(String name, Instant value, TemporalType temporalType)
Redeclares org. Instant value to the named query parameter using
just the portion indicated by the given TemporalType.
|
| public NativeQuery | setParameter(String
parameter name name, Calendar parameter value value, TemporalType temporal type temporalType)Redeclares org. jakarta. override
|
| public NativeQuery | setParameter(String
parameter name name, Date parameter value value, TemporalType temporal type temporalType)Redeclares org. jakarta. override
|
| public NativeQuery | setParameter(int
position position, Object parameter value value)Redeclares org. |
| public <P> NativeQuery | setParameter(int position, P val, Class<P> type)
Redeclares org. BindableType
to use.
|
| public <P> NativeQuery | setParameter(int position, P val, BindableType<P> type)
Redeclares org. BindableType.
|
| public NativeQuery | setParameter(int position, Instant value, TemporalType temporalType)
Redeclares org. Instant value to the ordinal query parameter using
just the portion indicated by the given TemporalType.
|
| public NativeQuery | setParameter(int
position position, Calendar parameter value value, TemporalType temporal type temporalType)Redeclares org. jakarta. override
|
| public NativeQuery | setParameter(int
position position, Date parameter value value, TemporalType temporal type temporalType)Redeclares org. jakarta. override
|
| public <P> NativeQuery | setParameter(QueryParameter<P>
the query parameter memento parameter, P the argument, which might be null val)Redeclares org. QueryParameter.
|
| public <P> NativeQuery | setParameter(QueryParameter<P>
the query parameter memento parameter, P the argument, which might be null val, Class<P> a type)BindableType representing the type of the parameterRedeclares org. QueryParameter using the given Class reference to attempt to
determine the BindableType to use.
|
| public <P> NativeQuery | setParameter(QueryParameter<P>
the query parameter memento parameter, P the argument, which might be null val, BindableType<P> an type)BindableType representing the type of the parameterRedeclares org. QueryParameter using the given BindableType.
|
| public <P> NativeQuery | setParameter(Parameter<P>
parameter object param, P parameter value value)Redeclares org. jakarta. override
|
| public NativeQuery | setParameter(Parameter<Calendar>
parameter object param, Calendar parameter value value, TemporalType temporal type temporalType)Redeclares org. jakarta. override
|
| public NativeQuery | setParameter(Parameter<Date>
parameter object param, Date parameter value value, TemporalType temporal type temporalType)Redeclares org. jakarta. override
|
| public NativeQuery | setParameterList(String name, Collection<E> values)
Redeclares org. |
| public <P> NativeQuery | setParameterList(String name, Collection<? extends P> values, Class<P> type)
Redeclares org. BindableType
to use.
|
| public <P> NativeQuery | setParameterList(String name, Collection<? extends P> values, BindableType<P> type)
Redeclares org. BindableType.
|
| public NativeQuery | setParameterList(String name, Object[] values)
Redeclares org. |
| public <P> NativeQuery | setParameterList(String name, P[] values, Class<P> type)
Redeclares org. BindableType
to use.
|
| public <P> NativeQuery | setParameterList(String name, P[] values, BindableType<P> type)
Redeclares org. BindableType.
|
| public NativeQuery | setParameterList(int position, Collection<E> values)
Redeclares org. |
| public <P> NativeQuery | setParameterList(int position, Collection<? extends P> values, Class<P> type)
Redeclares org. BindableType
to use.
|
| public <P> NativeQuery | setParameterList(int position, Collection<? extends P> values, BindableType<P> javaType)
Redeclares org. BindableType.
|
| public NativeQuery | setParameterList(int position, Object[] values)
Redeclares org. |
| public <P> NativeQuery | setParameterList(int position, P[] values, Class<P> javaType)
Redeclares org. Class reference to attempt to determine the BindableType
to use.
|
| public <P> NativeQuery | setParameterList(int position, P[] values, BindableType<P> javaType)
Redeclares org. BindableType.
|
| public <P> NativeQuery | setParameterList(QueryParameter<P>
the parameter memento parameter, Collection<? extends P> a collection of arguments values)Redeclares org. QueryParameter.
|
| public <P> NativeQuery | setParameterList(QueryParameter<P> parameter, Collection<? extends P> values, Class<P> javaType)
Redeclares org. QueryParameter using the given Class reference to attempt to
determine the BindableType to use.
|
| public <P> NativeQuery | setParameterList(QueryParameter<P> parameter, Collection<? extends P> values, BindableType<P> type)
Redeclares org. QueryParameter, inferring the BindableType.
|
| public <P> NativeQuery | setParameterList(QueryParameter<P>
the parameter memento parameter, P[] a collection of arguments values)Redeclares org. QueryParameter.
|
| public <P> NativeQuery | setParameterList(QueryParameter<P> parameter, P[] values, Class<P> javaType)
Redeclares org. QueryParameter using the given Class reference
to attempt to determine the BindableType to use.
|
| public <P> NativeQuery | setParameterList(QueryParameter<P> parameter, P[] values, BindableType<P> type)
Redeclares org. QueryParameter, inferring the BindableType.
|
| public NativeQuery | setProperties(Object
any JavaBean or POJO bean)Redeclares org. |
| public NativeQuery | setProperties(Map<K, V>
a bean)Map of names to argumentsRedeclares org. Map for each named parameters of
the query, matching key names with parameter names and mapping value
types to Hibernate types using heuristics.
|
| public NativeQuery | setReadOnly(boolean
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 modeRedeclares org. Query.
|
| public NativeQuery | setResultListTransformer(ResultListTransformer<T> transformer)
Redeclares org. ResultListTransformer.
|
| public <S> NativeQuery | setResultTransformer(ResultTransformer<S> transformer)
Redeclares as abstract: org.
Deprecated
|
| public NativeQuery | setTimeout(int
the timeout in seconds timeout)Redeclares org. |
| public <R> NativeQuery | setTupleTransformer(TupleTransformer<R> transformer)
Redeclares org. TupleTransformer.
|