Class AbstractSqmSelectQuery<T>
java.lang.Object
org.hibernate.query.sqm.tree.AbstractSqmNode
org.hibernate.query.sqm.tree.select.AbstractSqmSelectQuery<T>
- All Implemented Interfaces:
AbstractQuery<T>,CommonAbstractCriteria,Serializable,JpaCriteriaBase,JpaCriteriaNode,JpaCteContainer,JpaSelectCriteria<T>,SqmCteContainer,SqmSelectQuery<T>,SqmNode,SqmQuery<T>
- Direct Known Subclasses:
SqmSelectStatement,SqmSubQuery
public abstract class AbstractSqmSelectQuery<T>
extends AbstractSqmNode
implements SqmSelectQuery<T>
- Author:
- Steve Ebersole
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorsModifierConstructorDescriptionAbstractSqmSelectQuery(Class<T> resultType, NodeBuilder builder) protectedAbstractSqmSelectQuery(NodeBuilder builder, Map<String, SqmCteStatement<?>> cteStatements, Class<T> resultType) AbstractSqmSelectQuery(SqmQueryPart<T> queryPart, Class<T> resultType, NodeBuilder builder) AbstractSqmSelectQuery(SqmQueryPart<T> queryPart, Map<String, SqmCteStatement<?>> cteStatements, Class<T> resultType, NodeBuilder builder) -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected Map<String,SqmCteStatement<?>> copyCteStatements(SqmCopyContext context) distinct(boolean distinct) Specify whether duplicate query results will be eliminated.<X> SqmDerivedRoot<X>Create and add a query root corresponding to the given subquery, forming a cartesian product with any existing roots.<X> SqmRoot<X>from(EntityType<X> entityType) Create and add a query root corresponding to the given entity, forming a cartesian product with any existing roots.<X> SqmRoot<X>Create and add a query root corresponding to the given entity, forming a cartesian product with any existing roots.<X> JpaRoot<X>from(JpaCteCriteria<X> cte) Create and add a query root corresponding to the given cte, forming a cartesian product with any existing roots.<X> JpaCteCriteria<X>getCteCriteria(String cteName) Returns a CTE that is registered by the given name on this container, or any of its parents.Collection<? extends JpaCteCriteria<?>>Returns the CTEs that are registered on this container.getCteStatement(String cteLabel) List<Expression<?>>Return a list of the grouping expressions.Return the predicate that corresponds to the restriction(s) over the grouping items, or null if no restrictions have been specified.The query structure.The query structure.Return the predicate that corresponds to the where clause restriction(s), or null if no restrictions have been specified.getResultSelection(Selection<?>[] selections) Return the result type of the query or subquery.getRoots()Return the query roots.Return the selection of the query, or null if no selection has been set.groupBy(Expression<?>... expressions) Specify the expressions that are used to form groups over the query results.groupBy(List<Expression<?>> grouping) Specify the expressions that are used to form groups over the query results.having(Expression<Boolean> booleanExpression) Specify a restriction over the groups of the query.Specify restrictions over the groups of the query according the conjunction of the specified restriction predicates.booleanReturn whether duplicate query results must be eliminated or retained.voidsetQueryPart(SqmQueryPart<T> sqmQueryPart) protected voidsetResultType(Class<T> resultType) Deprecated, for removal: This API element is subject to removal in a future version.Don't use this method.where(Expression<Boolean> restriction) Modify the query to restrict the query results according to the specified boolean expression.Modify the query to restrict the query results according to the conjunction of the specified restriction predicates.<X> JpaCteCriteria<X>with(AbstractQuery<X> criteria) Registers the givenCriteriaQueryand returns aJpaCteCriteria, which can be used for querying.<X> JpaCteCriteria<X>with(String name, AbstractQuery<X> criteria) LikeJpaCteContainer.with(AbstractQuery)but assigns an explicit CTE name.<X> JpaCteCriteria<X>withRecursiveUnionAll(AbstractQuery<X> baseCriteria, Function<JpaCteCriteria<X>, AbstractQuery<X>> recursiveCriteriaProducer) Allows to register a recursive CTE.<X> JpaCteCriteria<X>withRecursiveUnionAll(String name, AbstractQuery<X> baseCriteria, Function<JpaCteCriteria<X>, AbstractQuery<X>> recursiveCriteriaProducer) LikeJpaCteContainer.withRecursiveUnionAll(AbstractQuery, Function)but assigns an explicit CTE name.<X> JpaCteCriteria<X>withRecursiveUnionDistinct(AbstractQuery<X> baseCriteria, Function<JpaCteCriteria<X>, AbstractQuery<X>> recursiveCriteriaProducer) Allows to register a recursive CTE.<X> JpaCteCriteria<X>withRecursiveUnionDistinct(String name, AbstractQuery<X> baseCriteria, Function<JpaCteCriteria<X>, AbstractQuery<X>> recursiveCriteriaProducer) LikeJpaCteContainer.withRecursiveUnionDistinct(AbstractQuery, Function)but assigns an explicit CTE name.Methods inherited from class org.hibernate.query.sqm.tree.AbstractSqmNode
nodeBuilderMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.hibernate.query.criteria.JpaCriteriaBase
subqueryMethods inherited from interface org.hibernate.query.sqm.tree.SqmNode
asLoggableText, nodeBuilderMethods inherited from interface org.hibernate.query.sqm.tree.select.SqmSelectQuery
copy
-
Constructor Details
-
AbstractSqmSelectQuery
-
AbstractSqmSelectQuery
-
AbstractSqmSelectQuery
protected AbstractSqmSelectQuery(NodeBuilder builder, Map<String, SqmCteStatement<?>> cteStatements, Class<T> resultType) -
AbstractSqmSelectQuery
public AbstractSqmSelectQuery(SqmQueryPart<T> queryPart, Map<String, SqmCteStatement<?>> cteStatements, Class<T> resultType, NodeBuilder builder)
-
-
Method Details
-
copyCteStatements
-
getCteStatements
- Specified by:
getCteStatementsin interfaceSqmCteContainer
-
getCteStatement
- Specified by:
getCteStatementin interfaceSqmCteContainer
-
getCteCriterias
Description copied from interface:JpaCteContainerReturns the CTEs that are registered on this container.- Specified by:
getCteCriteriasin interfaceJpaCteContainer
-
getCteCriteria
Description copied from interface:JpaCteContainerReturns a CTE that is registered by the given name on this container, or any of its parents.- Specified by:
getCteCriteriain interfaceJpaCteContainer
-
with
Description copied from interface:JpaCteContainerRegisters the givenCriteriaQueryand returns aJpaCteCriteria, which can be used for querying.- Specified by:
within interfaceJpaCteContainer- See Also:
-
withRecursiveUnionAll
public <X> JpaCteCriteria<X> withRecursiveUnionAll(AbstractQuery<X> baseCriteria, Function<JpaCteCriteria<X>, AbstractQuery<X>> recursiveCriteriaProducer) Description copied from interface:JpaCteContainerAllows to register a recursive CTE. The baseCriteriaQueryserves for the structure of theJpaCteCriteria, which is made available in the recursive criteria producer function, so that the recursiveCriteriaQueryis able to refer to the CTE again.- Specified by:
withRecursiveUnionAllin interfaceJpaCteContainer- See Also:
-
withRecursiveUnionDistinct
public <X> JpaCteCriteria<X> withRecursiveUnionDistinct(AbstractQuery<X> baseCriteria, Function<JpaCteCriteria<X>, AbstractQuery<X>> recursiveCriteriaProducer) Description copied from interface:JpaCteContainerAllows to register a recursive CTE. The baseCriteriaQueryserves for the structure of theJpaCteCriteria, which is made available in the recursive criteria producer function, so that the recursiveCriteriaQueryis able to refer to the CTE again.- Specified by:
withRecursiveUnionDistinctin interfaceJpaCteContainer- See Also:
-
with
Description copied from interface:JpaCteContainerLikeJpaCteContainer.with(AbstractQuery)but assigns an explicit CTE name.- Specified by:
within interfaceJpaCteContainer
-
withRecursiveUnionAll
public <X> JpaCteCriteria<X> withRecursiveUnionAll(String name, AbstractQuery<X> baseCriteria, Function<JpaCteCriteria<X>, AbstractQuery<X>> recursiveCriteriaProducer) Description copied from interface:JpaCteContainerLikeJpaCteContainer.withRecursiveUnionAll(AbstractQuery, Function)but assigns an explicit CTE name.- Specified by:
withRecursiveUnionAllin interfaceJpaCteContainer
-
withRecursiveUnionDistinct
public <X> JpaCteCriteria<X> withRecursiveUnionDistinct(String name, AbstractQuery<X> baseCriteria, Function<JpaCteCriteria<X>, AbstractQuery<X>> recursiveCriteriaProducer) Description copied from interface:JpaCteContainerLikeJpaCteContainer.withRecursiveUnionDistinct(AbstractQuery, Function)but assigns an explicit CTE name.- Specified by:
withRecursiveUnionDistinctin interfaceJpaCteContainer
-
getResultType
Description copied from interface:AbstractQueryReturn the result type of the query or subquery. If a result type was specified as an argument to thecreateQueryorsubquerymethod, that type will be returned. If the query was created using thecreateTupleQuerymethod, the result type isTuple. Otherwise, the result type isObject.- Specified by:
getResultTypein interfaceAbstractQuery<T>- Returns:
- result type
-
setResultType
Deprecated, for removal: This API element is subject to removal in a future version.Don't use this method. It has no effect. -
getQuerySpec
Description copied from interface:JpaSelectCriteriaThe query structure. SeeJpaQueryStructurefor details- Specified by:
getQuerySpecin interfaceJpaSelectCriteria<T>- Specified by:
getQuerySpecin interfaceSqmSelectQuery<T>
-
getQueryPart
Description copied from interface:JpaSelectCriteriaThe query structure. SeeJpaQueryStructurefor details- Specified by:
getQueryPartin interfaceJpaSelectCriteria<T>- Specified by:
getQueryPartin interfaceSqmSelectQuery<T>
-
setQueryPart
-
getRoots
Description copied from interface:AbstractQueryReturn the query roots. These are the roots that have been defined for theCriteriaQueryorSubqueryitself, including any subquery roots defined as a result of correlation. Returns empty set if no roots have been defined. Modifications to the set do not affect the query.- Specified by:
getRootsin interfaceAbstractQuery<T>- Returns:
- the set of query roots
-
getRootList
-
from
Description copied from interface:AbstractQueryCreate and add a query root corresponding to the given entity, forming a cartesian product with any existing roots.- Specified by:
fromin interfaceAbstractQuery<T>- Specified by:
fromin interfaceJpaSelectCriteria<T>- Parameters:
entityClass- the entity class- Returns:
- query root corresponding to the given entity
-
from
Description copied from interface:JpaSelectCriteriaCreate and add a query root corresponding to the given subquery, forming a cartesian product with any existing roots.- Specified by:
fromin interfaceJpaSelectCriteria<T>- Parameters:
subquery- the subquery- Returns:
- query root corresponding to the given subquery
-
from
Description copied from interface:JpaSelectCriteriaCreate and add a query root corresponding to the given cte, forming a cartesian product with any existing roots.- Specified by:
fromin interfaceJpaSelectCriteria<T>- Parameters:
cte- the cte criteria- Returns:
- query root corresponding to the given cte
-
from
Description copied from interface:AbstractQueryCreate and add a query root corresponding to the given entity, forming a cartesian product with any existing roots.- Specified by:
fromin interfaceAbstractQuery<T>- Specified by:
fromin interfaceJpaSelectCriteria<T>- Parameters:
entityType- metamodel entity representing the entity of type X- Returns:
- query root corresponding to the given entity
-
isDistinct
public boolean isDistinct()Description copied from interface:AbstractQueryReturn whether duplicate query results must be eliminated or retained.- Specified by:
isDistinctin interfaceAbstractQuery<T>- Returns:
- boolean indicating whether duplicate query results must be eliminated
-
distinct
Description copied from interface:AbstractQuerySpecify whether duplicate query results will be eliminated. A true value will cause duplicates to be eliminated. A false value will cause duplicates to be retained. If distinct has not been specified, duplicate results must be retained.- Specified by:
distinctin interfaceAbstractQuery<T>- Specified by:
distinctin interfaceJpaSelectCriteria<T>- Specified by:
distinctin interfaceSqmSelectQuery<T>- Parameters:
distinct- boolean value specifying whether duplicate results must be eliminated from the query result or whether they must be retained- Returns:
- the modified query
-
getSelection
Description copied from interface:AbstractQueryReturn the selection of the query, or null if no selection has been set.- Specified by:
getSelectionin interfaceAbstractQuery<T>- Specified by:
getSelectionin interfaceJpaSelectCriteria<T>- Returns:
- selection item
-
getRestriction
Description copied from interface:CommonAbstractCriteriaReturn the predicate that corresponds to the where clause restriction(s), or null if no restrictions have been specified.- Specified by:
getRestrictionin interfaceCommonAbstractCriteria- Specified by:
getRestrictionin interfaceJpaCriteriaBase- Specified by:
getRestrictionin interfaceJpaSelectCriteria<T>- Returns:
- where clause predicate
-
where
Description copied from interface:AbstractQueryModify the query to restrict the query results according to the specified boolean expression. Replaces the previously added restriction(s), if any.- Specified by:
wherein interfaceAbstractQuery<T>- Specified by:
wherein interfaceJpaSelectCriteria<T>- Parameters:
restriction- a simple or compound boolean expression- Returns:
- the modified query
-
where
Description copied from interface:AbstractQueryModify the query to restrict the query results according to the conjunction of the specified restriction predicates. Replaces the previously added restriction(s), if any. If no restrictions are specified, any previously added restrictions are simply removed.- Specified by:
wherein interfaceAbstractQuery<T>- Specified by:
wherein interfaceJpaSelectCriteria<T>- Parameters:
restrictions- zero or more restriction predicates- Returns:
- the modified query
-
getGroupList
Description copied from interface:AbstractQueryReturn a list of the grouping expressions. Returns empty list if no grouping expressions have been specified. Modifications to the list do not affect the query.- Specified by:
getGroupListin interfaceAbstractQuery<T>- Returns:
- the list of grouping expressions
-
groupBy
Description copied from interface:AbstractQuerySpecify the expressions that are used to form groups over the query results. Replaces the previous specified grouping expressions, if any. If no grouping expressions are specified, any previously added grouping expressions are simply removed.- Specified by:
groupByin interfaceAbstractQuery<T>- Specified by:
groupByin interfaceJpaSelectCriteria<T>- Parameters:
expressions- zero or more grouping expressions- Returns:
- the modified query
-
groupBy
Description copied from interface:AbstractQuerySpecify the expressions that are used to form groups over the query results. Replaces the previous specified grouping expressions, if any. If no grouping expressions are specified, any previously added grouping expressions are simply removed.- Specified by:
groupByin interfaceAbstractQuery<T>- Specified by:
groupByin interfaceJpaSelectCriteria<T>- Parameters:
grouping- list of zero or more grouping expressions- Returns:
- the modified query
-
getGroupRestriction
Description copied from interface:AbstractQueryReturn the predicate that corresponds to the restriction(s) over the grouping items, or null if no restrictions have been specified.- Specified by:
getGroupRestrictionin interfaceAbstractQuery<T>- Specified by:
getGroupRestrictionin interfaceJpaSelectCriteria<T>- Returns:
- having clause predicate
-
having
Description copied from interface:AbstractQuerySpecify a restriction over the groups of the query. Replaces the previous having restriction(s), if any.- Specified by:
havingin interfaceAbstractQuery<T>- Specified by:
havingin interfaceJpaSelectCriteria<T>- Parameters:
booleanExpression- a simple or compound boolean expression- Returns:
- the modified query
-
having
Description copied from interface:AbstractQuerySpecify restrictions over the groups of the query according the conjunction of the specified restriction predicates. Replaces the previously having added restriction(s), if any. If no restrictions are specified, any previously added restrictions are simply removed.- Specified by:
havingin interfaceAbstractQuery<T>- Specified by:
havingin interfaceJpaSelectCriteria<T>- Parameters:
predicates- zero or more restriction predicates- Returns:
- the modified query
-
appendHqlString
-
getResultSelection
-