Top Inners Fields Constructors Methods
org.hibernate.query.sql.internal

public Class NativeQueryImpl<R>

extends AbstractQuery<R>
implements NativeQueryImplementor<R>, DomainQueryExecutionContext, ResultSetMappingResolutionContext
Class Inheritance
All Implemented Interfaces
org.hibernate.query.internal.ResultSetMappingResolutionContext, org.hibernate.query.spi.DomainQueryExecutionContext, org.hibernate.query.sql.spi.NativeQueryImplementor, org.hibernate.query.named.NameableQuery, org.hibernate.query.NativeQuery, org.hibernate.query.SynchronizeableQuery, org.hibernate.query.Query, jakarta.persistence.TypedQuery, jakarta.persistence.Query, org.hibernate.query.MutationQuery, org.hibernate.query.CommonQueryContract, org.hibernate.query.SelectionQuery, org.hibernate.query.spi.QueryImplementor
Imports
java.io.Serializable, java.time.Instant, java.util.Calendar, .Collection, .Collections, .Date, .HashSet, .List, .Locale, .Map, .Set, java.util.function.Consumer, .Supplier, org.hibernate.CacheMode, .FlushMode, .HibernateException, .LockMode, .LockOptions, .MappingException, .ScrollMode, org.hibernate.dialect.Dialect, org.hibernate.engine.query.spi.NativeQueryInterpreter, org.hibernate.engine.spi.SessionFactoryImplementor, .SharedSessionContractImplementor, org.hibernate.graph.GraphSemantic, .RootGraph, org.hibernate.graph.spi.RootGraphImplementor, org.hibernate.internal.AbstractSharedSessionContract, org.hibernate.internal.util.MathHelper, .StringHelper, org.hibernate.internal.util.collections.CollectionHelper, org.hibernate.jpa.spi.NativeQueryTupleTransformer, org.hibernate.metamodel.model.domain.BasicDomainType, org.hibernate.persister.entity.EntityPersister, org.hibernate.query.BindableType, .NativeQuery, .Order, .ParameterMetadata, .PathException, .Query, .QueryParameter, .ResultListTransformer, .TupleTransformer, org.hibernate.query.internal.ParameterMetadataImpl, .QueryOptionsImpl, .QueryParameterBindingsImpl, .ResultSetMappingResolutionContext, org.hibernate.query.named.NamedResultSetMappingMemento, org.hibernate.query.results.Builders, .ResultBuilder, .ResultSetMapping, org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy, .DynamicResultBuilderEntityCalculated, .DynamicResultBuilderEntityStandard, .DynamicResultBuilderInstantiation, org.hibernate.query.results.implicit.ImplicitModelPartResultBuilderEntity, .ImplicitResultClassBuilder, org.hibernate.query.spi.AbstractQuery, .DomainQueryExecutionContext, .MutableQueryOptions, .NonSelectQueryPlan, .ParameterMetadataImplementor, .QueryEngine, .QueryInterpretationCache, .QueryParameterBinding, .QueryParameterBindings, .QueryParameterImplementor, .ScrollableResultsImplementor, .SelectQueryPlan, org.hibernate.query.sql.spi.NamedNativeQueryMemento, .NativeQueryImplementor, .NativeSelectQueryDefinition, .NativeSelectQueryPlan, .NonSelectInterpretationsKey, .ParameterInterpretation, .ParameterOccurrence, .SelectInterpretationsKey, org.hibernate.sql.exec.internal.CallbackImpl, org.hibernate.sql.exec.spi.Callback, org.hibernate.sql.results.jdbc.spi.JdbcValuesMappingProducer, org.hibernate.transform.ResultTransformer, org.hibernate.type.BasicType, .BasicTypeReference, jakarta.persistence.AttributeConverter, .CacheRetrieveMode, .CacheStoreMode, .EntityManager, .EntityManagerFactory, .FlushModeType, .LockModeType, .Parameter, .PersistenceException, .TemporalType, .Tuple, jakarta.persistence.metamodel.SingularAttribute

Author
Steve Ebersole

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static interface

Field Summary

Modifier and TypeField and Description
private Callback
private final String
private final QueryParameterBindings
private final ParameterMetadataImplementor
private final List<ParameterOccurrence>
private final QueryOptionsImpl
private Set<String>
private final boolean
private final ResultSetMapping
private final String
private Boolean
Inherited from org.hibernate.query.spi.AbstractQuery:
log

Constructor Summary

AccessConstructor and Description
public
NativeQueryImpl(NamedNativeQueryMemento memento, SharedSessionContractImplementor session)

Constructs a NativeQueryImpl given a sql query defined in the mappings.

public
NativeQueryImpl(NamedNativeQueryMemento memento, Class<R> resultJavaType, SharedSessionContractImplementor session)

Constructs a NativeQueryImpl given a sql query defined in the mappings.

public
NativeQueryImpl(NamedNativeQueryMemento memento, String resultSetMappingName, SharedSessionContractImplementor session)

Constructs a NativeQueryImpl given a sql query defined in the mappings.

public
public
public

Method Summary

Modifier and TypeMethod and Description
public NativeQueryImplementor<R>
addAttributeResult(String columnAlias, Class<T> entityJavaType, String attributePath)

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.addAttributeResult.

Defines a result based on a specified attribute.
public NativeQueryImplementor<R>
addAttributeResult(String columnAlias, String entityName, String attributePath)

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.addAttributeResult.

Defines a result based on a specified attribute.
public NativeQueryImplementor<R>
addAttributeResult(String columnAlias, SingularAttribute<X, T> attribute)

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.addAttributeResult.

Defines a result based on a specified attribute.
public NativeQueryImplementor<R>
addEntity(String
The entity name that is the root return of the query
entityName
)

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.addEntity.

Declare a "root" entity, without specifying an alias.
public NativeQueryImplementor<R>
addEntity(String
The SQL table alias
tableAlias
,
String
The entity name
entityName
)

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.addEntity.

Declare a "root" entity.
public NativeQueryImplementor<R>
addEntity(String
The SQL table alias
tableAlias
,
String
The entity name
entityName
,
LockMode
The lock mode for this return.
lockMode
)

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.addEntity.

Declare a "root" entity, specifying a lock mode.
public NativeQueryImplementor<R>
addEntity(Class<T>
The java type of the entity to add as a root
entityType
)

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.addEntity.

Declare a "root" entity, without specifying an alias.
public NativeQueryImplementor<R>
public NativeQueryImplementor<R>
addEntity(String
The SQL table alias
tableAlias
,
Class<T>
The java type of the entity to add as a root
entityClass
)

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.addEntity.

Declare a "root" entity.
public NativeQueryImplementor<R>
addEntity(String
The SQL table alias
tableAlias
,
Class<T>
The entity Class
entityClass
,
LockMode
The lock mode for this return
lockMode
)

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.addEntity.

Declare a "root" entity, specifying a lock mode.
public NativeQuery.FetchReturn
addFetch(String
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
)

Implements org.hibernate.query.NativeQuery.addFetch.

Declare a join fetch result.
public <J> NativeQuery.InstantiationResultNode<J>
public NativeQueryImplementor<R>
addJoin(String
The SQL table alias for the data to be mapped to this fetch.
tableAlias
,
String
The association path of form [owner-alias].[property-name].
path
)

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.addJoin.

Declare a join fetch result.
public NativeQueryImplementor<R>
addJoin(String
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
)

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.addJoin.

Declare a join fetch result.
public NativeQueryImplementor<R>
addJoin(String
The SQL table alias for the data to be mapped to this fetch
tableAlias
,
String
The association path of form [owner-alias].[property-name].
path
,
LockMode
The lock mode for this return.
lockMode
)

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.addJoin.

Declare a join fetch result, specifying a lock mode.
public NativeQueryImplementor<R>
addQueryHint(String
The database specific query hint to add.
hint
)

Overrides org.hibernate.query.spi.AbstractQuery.addQueryHint.

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.addQueryHint, org.hibernate.query.Query.addQueryHint.

Add a database query hint to the SQL query.
protected void
protected void
public void
public DynamicResultBuilderEntityStandard
addRoot(String
The SQL table alias to map to this entity
tableAlias
,
String
The name of the entity
entityName
)

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.addRoot.

Add a new root return mapping, returning a RootReturn to allow further definition.
public DynamicResultBuilderEntityStandard
addRoot(String
The SQL table alias to map to this entity
tableAlias
,
Class<T>
The java type of the entity
entityType
)

Implements org.hibernate.query.NativeQuery.addRoot.

Add a new root return mapping, returning a RootReturn to allow further definition.
public NativeQueryImplementor<R>
addScalar(String
The column alias in the result set to be processed as a scalar result
columnAlias
)

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.addScalar.

Declare a scalar query result.
public NativeQueryImplementor<R>
addScalar(int position, Class<?> type)

public NativeQuery<R>
addScalar(String
The 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
)

Implements org.hibernate.query.NativeQuery.addScalar.

Declare a scalar query result.
public NativeQueryImplementor<R>
addScalar(String
The 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
)

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.addScalar.

Declare a scalar query result.
public NativeQueryImplementor<R>
addScalar(String columnAlias, Class<T> javaType)

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.addScalar.

Declare a scalar query result using the specified result type.
public <C> NativeQueryImplementor<R>
addScalar(String columnAlias, Class<C>
The Java type expected by the converter as its "relational" type.
jdbcJavaType
,
AttributeConverter<?, C>
The conversion to apply. Consumes the JDBC value based on relationalJavaType.
converter
)

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.addScalar.

Declare a scalar query result with an explicit conversion.
public <O, J> NativeQueryImplementor<R>
addScalar(String columnAlias, Class<O>
The Java type expected by the converter as its "object model" type.
domainJavaType
,
Class<J>
The Java type expected by the converter as its "relational model" type.
jdbcJavaType
,
AttributeConverter<O, J>
The conversion to apply. Consumes the JDBC value based on relationalJavaType.
converter
)

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.addScalar.

Declare a scalar query result with an explicit conversion.
public <C> NativeQueryImplementor<R>
addScalar(String columnAlias, Class<C>
The 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 relationalJavaType.
converter
)

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.addScalar.

Declare a scalar query result with an explicit conversion.
public <O, J> NativeQueryImplementor<R>
addScalar(String columnAlias, Class<O>
The Java type expected by the converter as its "object model" type.
domainJavaType
,
Class<J>
The Java type expected by the converter as its "relational model" type.
jdbcJavaType
,
Class<? extends AttributeConverter<O, J>>
The conversion to apply. Consumes the JDBC value based on relationalJavaType.
converterJavaType
)

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.addScalar.

Declare a scalar query result with an explicit conversion.
public NativeQueryImplementor<R>
addSynchronizedEntityClass(Class<T>
The class of the entity.
entityClass
)

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.addSynchronizedEntityClass.

Add all query spaces associated with the entity with the given type.
public NativeQueryImplementor<R>
addSynchronizedEntityName(String
The name of an entity.
entityName
)

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.addSynchronizedEntityName.

Add all query spaces associated with the entity with the given names.
public NativeQueryImplementor<R>
addSynchronizedQuerySpace(String
The name of the query space, usually the name of a database table.
querySpace
)

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.addSynchronizedQuerySpace.

Add a query space.
protected void
protected void
protected void
public Query<R>
applyGraph(RootGraph<J>
The graph to apply.
graph
,
GraphSemantic
The semantic to use when applying the graph
semantic
)

Implements org.hibernate.query.Query.applyGraph.

Apply the given graph using the given semantic
protected void
protected void
protected void
private IllegalArgumentException
buildIncompatibleException(Class<?> resultClass, Class<?> actualResultClass)

private static ResultSetMapping
buildResultSetMapping(String registeredName, boolean isDynamic, SharedSessionContractImplementor session)

protected void
private NativeQuery.FetchReturn
createFetchJoin(String tableAlias, String path)

private NativeSelectQueryPlan<R>
public static int
determineBindValueMaxCount(boolean paddingEnabled, int inExprLimit, int bindValueCount)

protected int
protected List<R>
protected ScrollableResultsImplementor<R>
protected String
private Class<?>
protected NonSelectInterpretationsKey
private SelectInterpretationsKey
public Callback
public LockModeType
getLockMode()

Overrides org.hibernate.query.spi.AbstractQuery.getLockMode.

Implements org.hibernate.query.SelectionQuery.getLockMode, jakarta.persistence.Query.getLockMode, org.hibernate.query.NativeQuery.getLockMode.

Not applicable to native SQL queries, due to an unfortunate requirement of the JPA specification.
public QueryParameterBindings
public ParameterMetadataImplementor
public List<ParameterOccurrence>
public MutableQueryOptions
public QueryParameterBindings
public String
getQueryString()

Implements abstract org.hibernate.query.spi.AbstractSelectionQuery.getQueryString.

Implements org.hibernate.query.Query.getQueryString.

The query as a string, or null in the case of a criteria query.
public Collection<String>
getSynchronizedQuerySpaces()

Implements org.hibernate.query.SynchronizeableQuery.getSynchronizedQuerySpaces.

Obtain the list of query spaces this query is synchronized with.
public boolean
private boolean
public Boolean
isSelectQuery()

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.isSelectQuery.

Best guess whether this is a select query.
protected void
protected NativeQueryImplementor<R>
private NonSelectQueryPlan
private ParameterInterpretation
protected SelectQueryPlan<R>
public NativeQueryImplementor<R>
public NativeQueryImplementor<R>
public NativeQueryImplementor<R>
public NativeQueryImplementor<R>
public NativeQueryImplementor<R>
public NativeQueryImplementor<R>
public NativeQueryImplementor<R>
public NativeQueryImplementor<R>
setFirstResult(int
position of the first result, numbered from 0
startPosition
)

Overrides org.hibernate.query.spi.AbstractQuery.setFirstResult.

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.setFirstResult, org.hibernate.query.Query.setFirstResult, org.hibernate.query.SelectionQuery.setFirstResult.

Set the first row position to return from the query results.
public NativeQueryImplementor<R>
public NativeQueryImplementor<R>
public NativeQueryImplementor<R>
public NativeQueryImplementor<R>
public NativeQueryImplementor<R>
public NativeQueryImplementor<R>
setLockMode(LockModeType
lock mode
lockModeType
)

Overrides org.hibernate.query.spi.AbstractQuery.setLockMode.

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.setLockMode, org.hibernate.query.Query.setLockMode, org.hibernate.query.SelectionQuery.setLockMode.

Not applicable to native SQL queries, due to an unfortunate requirement of the JPA specification.
public NativeQueryImplementor<R>
public NativeQueryImplementor<R>
public Query<R>
setOrder(List<Order<? super R>>
one or more instances of Order
orderList
)

Overrides org.hibernate.query.spi.AbstractQuery.setOrder.

Implements org.hibernate.query.Query.setOrder, org.hibernate.query.SelectionQuery.setOrder.

If the result type of this query is an entity class, add one or more rules for ordering the query results.
public Query<R>
setOrder(Order<? super R>
an instance of Order
order
)

Overrides org.hibernate.query.spi.AbstractQuery.setOrder.

Implements org.hibernate.query.Query.setOrder, org.hibernate.query.SelectionQuery.setOrder.

If the result type of this query is an entity class, add a rule for ordering the query results.
public NativeQueryImplementor<R>
public <P> NativeQueryImplementor<R>
public <P> NativeQueryImplementor<R>
public NativeQueryImplementor<R>
public NativeQueryImplementor<R>
public NativeQueryImplementor<R>
public NativeQueryImplementor<R>
public <P> NativeQueryImplementor<R>
setParameter(int position, P value, Class<P> javaTypeClass)

Overrides org.hibernate.query.spi.AbstractQuery.setParameter.

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.setParameter, org.hibernate.query.spi.QueryImplementor.setParameter, org.hibernate.query.SelectionQuery.setParameter, org.hibernate.query.CommonQueryContract.setParameter.

Bind the given argument to an ordinal query parameter using the given Class reference to attempt to determine the BindableType to use.
public <P> NativeQueryImplementor<R>
public NativeQueryImplementor<R>
public NativeQueryImplementor<R>
public NativeQueryImplementor<R>
public <P> NativeQueryImplementor<R>
public <P> NativeQueryImplementor<R>
setParameter(QueryParameter<P>
the query parameter memento
parameter
,
P
the argument, which might be null
value
,
Class<P>
a BindableType representing the type of the parameter
javaTypeClass
)

Overrides org.hibernate.query.spi.AbstractQuery.setParameter.

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.setParameter, org.hibernate.query.spi.QueryImplementor.setParameter, org.hibernate.query.SelectionQuery.setParameter, org.hibernate.query.CommonQueryContract.setParameter.

Bind an argument to the query parameter represented by the given QueryParameter using the given Class reference to attempt to determine the BindableType to use.
public <P> NativeQueryImplementor<R>
setParameter(QueryParameter<P>
the query parameter memento
parameter
,
P
the argument, which might be null
value
,
BindableType<P>
an BindableType representing the type of the parameter
type
)

Overrides org.hibernate.query.spi.AbstractQuery.setParameter.

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.setParameter, org.hibernate.query.spi.QueryImplementor.setParameter, org.hibernate.query.SelectionQuery.setParameter, org.hibernate.query.CommonQueryContract.setParameter.

Bind an argument to the query parameter represented by the given QueryParameter using the given BindableType.
public <P> NativeQueryImplementor<R>
public NativeQueryImplementor<R>
public NativeQueryImplementor<R>
public NativeQueryImplementor<R>
public <P> NativeQueryImplementor<R>
public <P> NativeQueryImplementor<R>
public NativeQueryImplementor<R>
public <P> NativeQueryImplementor<R>
public <P> NativeQueryImplementor<R>
public NativeQueryImplementor<R>
public <P> NativeQueryImplementor<R>
public <P> NativeQueryImplementor<R>
public NativeQueryImplementor<R>
public <P> NativeQueryImplementor<R>
public <P> NativeQueryImplementor<R>
public <P> NativeQueryImplementor<R>
public <P> NativeQueryImplementor<R>
public <P> NativeQueryImplementor<R>
public <P> NativeQueryImplementor<R>
public <P> NativeQueryImplementor<R>
public <P> NativeQueryImplementor<R>
public NativeQueryImplementor<R>
setProperties(Map<K, V>
a Map of names to arguments
map
)

Overrides org.hibernate.query.spi.AbstractQuery.setProperties.

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.setProperties, org.hibernate.query.spi.QueryImplementor.setProperties, org.hibernate.query.SelectionQuery.setProperties, org.hibernate.query.CommonQueryContract.setProperties.

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.
public NativeQueryImplementor<R>
setProperties(Object
any JavaBean or POJO
bean
)

Overrides org.hibernate.query.spi.AbstractQuery.setProperties.

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.setProperties, org.hibernate.query.spi.QueryImplementor.setProperties, org.hibernate.query.SelectionQuery.setProperties, org.hibernate.query.CommonQueryContract.setProperties.

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.
public NativeQueryImplementor<R>
setQueryPlanCacheable(boolean queryPlanCacheable)

Overrides org.hibernate.query.spi.AbstractQuery.setQueryPlanCacheable.

Implements org.hibernate.query.SelectionQuery.setQueryPlanCacheable.

Enable/disable query plan caching for this query.
public NativeQueryImplementor<R>
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 mode
readOnly
)

Overrides org.hibernate.query.spi.AbstractQuery.setReadOnly.

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.setReadOnly, org.hibernate.query.Query.setReadOnly, org.hibernate.query.SelectionQuery.setReadOnly.

Set the read-only/modifiable mode for entities and proxies loaded by this Query.
public NativeQueryImplementor<R>
public <S> NativeQueryImplementor<S>
public NativeQueryImplementor<R>
public <T> NativeQueryImplementor<T>
private boolean
private boolean
public NamedNativeQueryMemento
toMemento(String name)

Implements org.hibernate.query.sql.spi.NativeQueryImplementor.toMemento.

Convert the query into the memento
public <T> T
unwrap(Class<T>
the class of the object to be returned. This is normally either the underlying query implementation class or an interface that it implements.
javaType
)

Implements jakarta.persistence.Query.unwrap.

Return an object of the specified type to allow access to the provider-specific API.
Inherited from org.hibernate.query.spi.AbstractQuery:
applyOptionsdisableFetchProfileenableFetchProfileexecuteUpdategetCommentgetFirstResultgetFlushModegetLockOptionsgetMaxResultsgetParametersgetSupportedHintsisCacheableresolveJdbcParameterTypeIfNecessarysetEntityGraphsetOptionalEntityNamesetOptionalIdsetOptionalObject