Top Fields Constructors Methods
org.hibernate.query.spi

public abstract Class AbstractSelectionQuery<R>

extends AbstractCommonQueryContract
implements SelectionQuery<R>, DomainQueryExecutionContext
Class Inheritance
All Implemented Interfaces
org.hibernate.query.spi.DomainQueryExecutionContext, org.hibernate.query.SelectionQuery, org.hibernate.query.CommonQueryContract
Known Direct Subclasses
org.hibernate.query.sqm.internal.QuerySqmImpl, org.hibernate.query.sqm.internal.SqmSelectionQueryImpl, org.hibernate.query.spi.AbstractQuery
Imports
java.sql.Types, java.time.Instant, java.util.Calendar, .Collection, .Date, .HashSet, .List, .Map, .Optional, .Spliterator, .Spliterators, java.util.stream.Stream, .StreamSupport, jakarta.persistence.CacheRetrieveMode, .CacheStoreMode, .EntityGraph, .FlushModeType, .LockModeType, .NoResultException, .Parameter, .TemporalType, .Tuple, .TupleElement, jakarta.persistence.criteria.CompoundSelection, org.hibernate.CacheMode, .FlushMode, .HibernateException, .LockMode, .LockOptions, .NonUniqueResultException, .ScrollMode, .TypeMismatchException, .UnknownProfileException, org.hibernate.engine.spi.SessionFactoryImplementor, .SharedSessionContractImplementor, org.hibernate.graph.GraphSemantic, org.hibernate.graph.spi.AppliedGraph, .RootGraphImplementor, org.hibernate.jpa.internal.util.LockModeTypeHelper, org.hibernate.metamodel.model.domain.BasicDomainType, .DomainType, org.hibernate.query.BindableType, .IllegalQueryOperationException, .QueryParameter, .QueryTypeMismatchException, .SelectionQuery, org.hibernate.query.criteria.JpaSelection, org.hibernate.query.internal.ScrollableResultsIterator, org.hibernate.query.named.NamedQueryMemento, org.hibernate.query.sqm.SqmExpressible, .SqmPathSource, org.hibernate.query.sqm.spi.NamedSqmQueryMemento, org.hibernate.query.sqm.tree.SqmStatement, org.hibernate.query.sqm.tree.expression.SqmParameter, org.hibernate.query.sqm.tree.from.SqmRoot, org.hibernate.query.sqm.tree.select.SqmQueryGroup, .SqmQueryPart, .SqmQuerySpec, .SqmSelectStatement, .SqmSelectableNode, .SqmSelection, org.hibernate.sql.exec.internal.CallbackImpl, org.hibernate.sql.exec.spi.Callback, org.hibernate.sql.results.internal.TupleMetadata, org.hibernate.type.BasicType, .BasicTypeRegistry, org.hibernate.type.descriptor.java.JavaType, org.hibernate.type.descriptor.java.spi.PrimitiveJavaType, org.hibernate.type.descriptor.jdbc.JdbcType

Author
Steve Ebersole

Field Summary

Modifier and TypeField and Description
private Callback
public static final String
CRITERIA_HQL_STRING

The value used for getQueryString for Criteria-based queries

private CacheMode
private FlushMode

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
afterQuery(boolean success)

protected void
protected void
afterQueryHandlingFetchProfiles(boolean success, HashSet<String> fetchProfiles)

private void
protected void
protected void
protected void
protected HashSet<String>
private static String[]
private static TupleElement<?>[]
protected TupleMetadata
buildTupleMetadata(SqmStatement<?> statement, Class<R> resultType)

protected static <T> void
checkQueryReturnType(SqmQuerySpec<T> querySpec, Class<T> expectedResultClass, SessionFactoryImplementor sessionFactory)

Deprecated as a consequence of SessionFactoryImplementor being deprecated.
protected void
public SelectionQuery<R>
disableFetchProfile(String
the name of the fetch profile to be disabled
profileName
)

Implements org.hibernate.query.SelectionQuery.disableFetchProfile.

Disable the fetch profile with the given name in this session.
protected abstract List<R>
protected abstract ScrollableResultsImplementor<R>
doScroll(ScrollMode scrollMode)

public SelectionQuery<R>
enableFetchProfile(String
the name of the fetch profile to be enabled
profileName
)

Implements org.hibernate.query.SelectionQuery.enableFetchProfile.

Enable the fetch profile for this query.
public CacheMode
getCacheMode()

Implements org.hibernate.query.SelectionQuery.getCacheMode.

Obtain the CacheMode in effect for this query.
public String
getCacheRegion()

Implements org.hibernate.query.SelectionQuery.getCacheRegion.

Obtain the name of the second level query cache region in which query results will be stored (if they are cached, see the discussion on isCacheable() for more information).
public CacheRetrieveMode
public CacheStoreMode
public Callback
public Integer
getFetchSize()

Implements org.hibernate.query.SelectionQuery.getFetchSize.

Obtain the JDBC fetch size hint in effect for this query.
public FlushModeType
public LockMode
getHibernateLockMode()

Implements org.hibernate.query.SelectionQuery.getHibernateLockMode.

Get the root LockMode for the query
private static JdbcType
getJdbcType(SqmExpressible<?> sqmExpressible)

public LockModeType
public LockOptions
getLockOptions()

Implements org.hibernate.query.SelectionQuery.getLockOptions.

The LockOptions currently in effect for the query
protected abstract String
public Stream<R>
getResultStream()

Overrides default org.hibernate.query.SelectionQuery.getResultStream.

Execute the query and return the query results as a Stream.
public SessionFactoryImplementor
getSessionFactory()

Deprecated as a consequence of SessionFactoryImplementor being deprecated.
public R
getSingleResult()

Implements org.hibernate.query.SelectionQuery.getSingleResult.

Execute the query and return the single result of the query, throwing an exception if the query returns no results.
public R
getSingleResultOrNull()

Implements org.hibernate.query.SelectionQuery.getSingleResultOrNull.

Execute the query and return the single result of the query, or null if the query returns no results.
private TupleMetadata
protected static boolean
public boolean
protected static boolean
public boolean
isCacheable()

Implements org.hibernate.query.SelectionQuery.isCacheable.

Should the results of the query be stored in the second level cache?
private static boolean
private static <T> boolean
isMatchingDateJdbcType(Class<T> resultClass, JdbcType jdbcType)

private static <T> boolean
isMatchingDateType(Class<?> javaTypeClass, Class<T> resultClass, SqmExpressible<?> sqmExpressible)

public boolean
isQueryPlanCacheable()

Implements org.hibernate.query.SelectionQuery.isQueryPlanCacheable.

Should the query plan of the query be stored in the query plan cache?
public boolean
isReadOnly()

Implements org.hibernate.query.SelectionQuery.isReadOnly.

Should entities and proxies loaded by this Query be put in read-only mode?
private static <T> boolean
isResultTypeAlwaysAllowed(Class<T> expectedResultClass)

public List<R>
list()

Implements org.hibernate.query.SelectionQuery.list.

Execute the query and return the query results as a List.
protected abstract void
protected boolean
protected void
private void
public ScrollableResultsImplementor<R>
scroll()

Implements org.hibernate.query.SelectionQuery.scroll.

Returns scrollable access to the query results.
public ScrollableResultsImplementor<R>
scroll(ScrollMode scrollMode)

Implements org.hibernate.query.SelectionQuery.scroll.

Returns scrollable access to the query results.
public SelectionQuery<R>
setAliasSpecificLockMode(String alias, LockMode lockMode)

Implements org.hibernate.query.SelectionQuery.setAliasSpecificLockMode.

Specify a LockMode to apply to a specific alias defined in the query
public SelectionQuery<R>
setCacheable(boolean cacheable)

Implements org.hibernate.query.SelectionQuery.setCacheable.

Enable/disable second level query (result) caching for this query.
public SelectionQuery<R>
setCacheMode(CacheMode cacheMode)

Implements org.hibernate.query.SelectionQuery.setCacheMode.

Set the current CacheMode in effect for this query.
public SelectionQuery<R>
setCacheRegion(String regionName)

Implements org.hibernate.query.SelectionQuery.setCacheRegion.

Set the name of the cache region where query results should be cached (assuming isCacheable).
public SelectionQuery<R>
public SelectionQuery<R>
public SelectionQuery<R>
public SelectionQuery<R>
public SelectionQuery<R>
setFetchSize(int
the fetch size hint
fetchSize
)

Implements org.hibernate.query.SelectionQuery.setFetchSize.

Sets a JDBC fetch size hint for the query.
public SelectionQuery<R>
setFirstResult(int startPosition)

Implements org.hibernate.query.SelectionQuery.setFirstResult.

Set the first row position to return from the query results.
public SelectionQuery<R>
public SelectionQuery<R>
setFollowOnLocking(boolean enable)

Implements org.hibernate.query.SelectionQuery.setFollowOnLocking.

Specifies whether follow-on locking should be applied?
public SelectionQuery<R>
public SelectionQuery<R>
setHibernateLockMode(LockMode lockMode)

Implements org.hibernate.query.SelectionQuery.setHibernateLockMode.

Specify the root LockMode for the query
public SelectionQuery<R>
public SelectionQuery<R>
setLockMode(LockModeType lockMode)

Implements org.hibernate.query.SelectionQuery.setLockMode.

Specify the root LockModeType for the query
public SelectionQuery<R>
setLockMode(String alias, LockMode lockMode)

Implements org.hibernate.query.SelectionQuery.setLockMode.

Specify a LockMode to apply to a specific alias defined in the query
public SelectionQuery<R>
setMaxResults(int maxResult)

Implements org.hibernate.query.SelectionQuery.setMaxResults.

Set the max number of rows requested for the query results.
public SelectionQuery<R>
public <P> SelectionQuery<R>
setParameter(String name, P value, Class<P> javaType)

Overrides org.hibernate.query.spi.AbstractCommonQueryContract.setParameter.

Implements org.hibernate.query.SelectionQuery.setParameter, org.hibernate.query.CommonQueryContract.setParameter.

Bind the given argument to a named query parameter using the given Class reference to attempt to infer the BindableType.
public <P> SelectionQuery<R>
public SelectionQuery<R>
public SelectionQuery<R>
public <P> SelectionQuery<R>
setParameter(int position, P value, Class<P> javaType)

Overrides org.hibernate.query.spi.AbstractCommonQueryContract.setParameter.

Implements 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 infer the BindableType.
public <P> SelectionQuery<R>
public SelectionQuery<R>
setParameter(int position, Instant value, TemporalType temporalType)

Overrides org.hibernate.query.spi.AbstractCommonQueryContract.setParameter.

Implements org.hibernate.query.SelectionQuery.setParameter, org.hibernate.query.CommonQueryContract.setParameter.

Bind an Instant to an ordinal query parameter using just the portion indicated by the given TemporalType.
public <P> SelectionQuery<R>
setParameter(QueryParameter<P>
the query parameter memento
parameter
,
P
the argument, which might be null
value
)

Overrides org.hibernate.query.spi.AbstractCommonQueryContract.setParameter.

Implements org.hibernate.query.SelectionQuery.setParameter, org.hibernate.query.CommonQueryContract.setParameter.

Bind an argument to the query parameter represented by the given QueryParameter.
public <P> SelectionQuery<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
javaType
)

Overrides org.hibernate.query.spi.AbstractCommonQueryContract.setParameter.

Implements 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 infer the BindableType to use.
public <P> SelectionQuery<R>
setParameter(QueryParameter<P>
the query parameter memento
parameter
,
P
the argument, which might be null
value
,
BindableType<P>
a BindableType representing the type of the parameter
type
)

Overrides org.hibernate.query.spi.AbstractCommonQueryContract.setParameter.

Implements 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> SelectionQuery<R>
public SelectionQuery<R>
public SelectionQuery<R>
public SelectionQuery<R>
public SelectionQuery<R>
public SelectionQuery<R>
public SelectionQuery<R>
public SelectionQuery<R>
public <P> SelectionQuery<R>
setParameterList(String name, Collection<? extends P> values, Class<P> javaType)

Overrides org.hibernate.query.spi.AbstractCommonQueryContract.setParameterList.

Implements org.hibernate.query.SelectionQuery.setParameterList, org.hibernate.query.CommonQueryContract.setParameterList.

Bind multiple arguments to a named query parameter using the given Class reference to attempt to infer the BindableType If unable to infer an appropriate BindableType, fall back to setParameterList(String, Collection).
public <P> SelectionQuery<R>
public SelectionQuery<R>
public <P> SelectionQuery<R>
setParameterList(String name, P[] values, Class<P> javaType)

Overrides org.hibernate.query.spi.AbstractCommonQueryContract.setParameterList.

Implements org.hibernate.query.SelectionQuery.setParameterList, org.hibernate.query.CommonQueryContract.setParameterList.

Bind multiple arguments to a named query parameter using the given Class reference to attempt to determine the BindableType to use.
public <P> SelectionQuery<R>
public SelectionQuery<R>
public <P> SelectionQuery<R>
setParameterList(int position, Collection<? extends P> values, Class<P> javaType)

Overrides org.hibernate.query.spi.AbstractCommonQueryContract.setParameterList.

Implements org.hibernate.query.SelectionQuery.setParameterList, org.hibernate.query.CommonQueryContract.setParameterList.

Bind multiple arguments to an ordinal query parameter using the given Class reference to attempt to infer the BindableType.
public <P> SelectionQuery<R>
public SelectionQuery<R>
public <P> SelectionQuery<R>
setParameterList(int position, P[] values, Class<P> javaType)

Overrides org.hibernate.query.spi.AbstractCommonQueryContract.setParameterList.

Implements org.hibernate.query.SelectionQuery.setParameterList, org.hibernate.query.CommonQueryContract.setParameterList.

Bind multiple arguments to an ordinal query parameter using the given Class reference to attempt to infer the BindableType.
public <P> SelectionQuery<R>
public <P> SelectionQuery<R>
setParameterList(QueryParameter<P>
the parameter memento
parameter
,
Collection<? extends P>
a collection of arguments
values
)

Overrides org.hibernate.query.spi.AbstractCommonQueryContract.setParameterList.

Implements org.hibernate.query.SelectionQuery.setParameterList, org.hibernate.query.CommonQueryContract.setParameterList.

Bind multiple arguments to the query parameter represented by the given QueryParameter.
public <P> SelectionQuery<R>
setParameterList(QueryParameter<P> parameter, Collection<? extends P> values, Class<P> javaType)

Overrides org.hibernate.query.spi.AbstractCommonQueryContract.setParameterList.

Implements org.hibernate.query.SelectionQuery.setParameterList, org.hibernate.query.CommonQueryContract.setParameterList.

Bind multiple arguments to the query parameter represented by the given QueryParameter using the given Class reference to attempt to infer the BindableType to use.
public <P> SelectionQuery<R>
public <P> SelectionQuery<R>
setParameterList(QueryParameter<P>
the parameter memento
parameter
,
P[]
a collection of arguments
values
)

Overrides org.hibernate.query.spi.AbstractCommonQueryContract.setParameterList.

Implements org.hibernate.query.SelectionQuery.setParameterList, org.hibernate.query.CommonQueryContract.setParameterList.

Bind multiple arguments to the query parameter represented by the given QueryParameter.
public <P> SelectionQuery<R>
setParameterList(QueryParameter<P> parameter, P[] values, Class<P> javaType)

Overrides org.hibernate.query.spi.AbstractCommonQueryContract.setParameterList.

Implements org.hibernate.query.SelectionQuery.setParameterList, org.hibernate.query.CommonQueryContract.setParameterList.

Bind multiple arguments to the query parameter represented by the given QueryParameter using the given Class reference to attempt to infer the BindableType to use.
public <P> SelectionQuery<R>
public SelectionQuery<R>
setProperties(Map<K, V>
a Map of names to arguments
map
)

Overrides org.hibernate.query.spi.AbstractCommonQueryContract.setProperties.

Implements org.hibernate.query.SelectionQuery.setProperties, org.hibernate.query.CommonQueryContract.setProperties.

Bind the values of the given Map to named parameters of the query, matching key names with parameter names and mapping value types to Hibernate types using heuristics.
public SelectionQuery<R>
setProperties(Object
any JavaBean or POJO
bean
)

Overrides org.hibernate.query.spi.AbstractCommonQueryContract.setProperties.

Implements 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 SelectionQuery<R>
setQueryPlanCacheable(boolean queryPlanCacheable)

Implements org.hibernate.query.SelectionQuery.setQueryPlanCacheable.

Enable/disable query plan caching for this query.
public SelectionQuery<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
)

Implements org.hibernate.query.SelectionQuery.setReadOnly.

Set the read-only/modifiable mode for entities and proxies loaded by this Query.
public SelectionQuery<R>
public Stream<T>
stream()

Overrides default org.hibernate.query.SelectionQuery.stream.

Execute the query and return the query results as a Stream.
private static <T> void
throwQueryTypeMismatchException(Class<T> resultClass, SqmExpressible<?> sqmExpressible)

protected static <T> T
public R
uniqueResult()

Implements org.hibernate.query.SelectionQuery.uniqueResult.

Execute the query and return the single result of the query, or null if the query returns no results.
public Optional<R>
uniqueResultOptional()

Implements org.hibernate.query.SelectionQuery.uniqueResultOptional.

Execute the query and return the single result of the query, as an Optional.
protected static <T> void
verifyResultType(Class<T> resultClass, SqmExpressible<?> sqmExpressible)

protected void
visitQueryReturnType(SqmQueryPart<R> queryPart, Class<R> expectedResultType, SessionFactoryImplementor factory)

Deprecated as a consequence of SessionFactoryImplementor being deprecated.
Used during handling of Criteria queries
Inherited from org.hibernate.query.spi.AbstractCommonQueryContract:
applyAdditionalPossibleHintsapplyAliasSpecificLockModeHintapplyCacheableHintapplyCacheModeHintapplyCacheRegionHintapplyCommentHintapplyEntityGraphHintapplyFetchSizeHintapplyFirstResultapplyFlushModeHintapplyFollowOnLockingHintapplyGraphapplyGraphapplyHibernateLockModeapplyHintapplyJpaCacheRetrieveModeHintapplyJpaCacheStoreModeHintapplyJpaFlushModeapplyLockModeHintapplyLockModeTypeapplyLockTimeoutHintapplyLockTimeoutHintapplyMaxResultsapplyQueryPlanCacheableHintapplyResultListTransformerapplySelectionHintapplySynchronizeSpacesHintapplyTimeoutHintapplyTupleTransformerdetermineTypegetCommentgetFirstResultgetHibernateFlushModegetHintsgetIntegerLiteralgetJpaFlushModegetMaxResultsgetMaxRowsgetParametergetParametergetParametergetParametergetParameterMetadatagetParametersgetParameterValuegetParameterValuegetParameterValuegetQueryOptionsgetQueryParameterBindingsgetSessiongetTimeoutisBoundlocateBindinglocateBindinglocateBindinglocateBindingputIfNotNullputIfNotNullresolveJdbcParameterTypeIfNecessary