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>
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description AbstractSqmSelectQuery(Class<T> resultType, NodeBuilder builder)
protected
AbstractSqmSelectQuery(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
appendHqlString(StringBuilder sb)
protected Map<String,SqmCteStatement<?>>
copyCteStatements(SqmCopyContext context)
SqmSelectQuery<T>
distinct(boolean distinct)
<X> SqmDerivedRoot<X>
from(Subquery<X> subquery)
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)
<X> SqmRoot<X>
from(Class<X> entityClass)
<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<?>>
getCteCriterias()
Returns the CTEs that are registered on this container.SqmCteStatement<?>
getCteStatement(String cteLabel)
Collection<SqmCteStatement<?>>
getCteStatements()
List<Expression<?>>
getGroupList()
SqmPredicate
getGroupRestriction()
SqmQueryPart<T>
getQueryPart()
The query structure.SqmQuerySpec<T>
getQuerySpec()
The query structure.SqmPredicate
getRestriction()
protected Selection<? extends T>
getResultSelection(Selection<?>[] selections)
Class<T>
getResultType()
List<Root<?>>
getRootList()
Set<Root<?>>
getRoots()
JpaSelection<T>
getSelection()
SqmSelectQuery<T>
groupBy(Expression<?>... expressions)
SqmSelectQuery<T>
groupBy(List<Expression<?>> grouping)
SqmSelectQuery<T>
having(Expression<Boolean> booleanExpression)
SqmSelectQuery<T>
having(Predicate... predicates)
boolean
isDistinct()
void
setQueryPart(SqmQueryPart<T> sqmQueryPart)
protected void
setResultType(Class<T> resultType)
SqmSelectQuery<T>
where(Expression<Boolean> restriction)
SqmSelectQuery<T>
where(Predicate... restrictions)
<X> JpaCteCriteria<X>
with(AbstractQuery<X> criteria)
Registers the givenCriteriaQuery
and 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
nodeBuilder
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.query.criteria.JpaCriteriaBase
subquery
-
Methods inherited from interface org.hibernate.query.sqm.tree.SqmNode
asLoggableText, nodeBuilder
-
Methods inherited from interface org.hibernate.query.sqm.tree.select.SqmSelectQuery
copy
-
-
-
-
Constructor Detail
-
AbstractSqmSelectQuery
public AbstractSqmSelectQuery(Class<T> resultType, NodeBuilder builder)
-
AbstractSqmSelectQuery
public AbstractSqmSelectQuery(SqmQueryPart<T> queryPart, Class<T> resultType, NodeBuilder builder)
-
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 Detail
-
copyCteStatements
protected Map<String,SqmCteStatement<?>> copyCteStatements(SqmCopyContext context)
-
getCteStatements
public Collection<SqmCteStatement<?>> getCteStatements()
- Specified by:
getCteStatements
in interfaceSqmCteContainer
-
getCteStatement
public SqmCteStatement<?> getCteStatement(String cteLabel)
- Specified by:
getCteStatement
in interfaceSqmCteContainer
-
getCteCriterias
public Collection<? extends JpaCteCriteria<?>> getCteCriterias()
Description copied from interface:JpaCteContainer
Returns the CTEs that are registered on this container.- Specified by:
getCteCriterias
in interfaceJpaCteContainer
-
getCteCriteria
public <X> JpaCteCriteria<X> getCteCriteria(String cteName)
Description copied from interface:JpaCteContainer
Returns a CTE that is registered by the given name on this container, or any of its parents.- Specified by:
getCteCriteria
in interfaceJpaCteContainer
-
with
public <X> JpaCteCriteria<X> with(AbstractQuery<X> criteria)
Description copied from interface:JpaCteContainer
Registers the givenCriteriaQuery
and returns aJpaCteCriteria
, which can be used for querying.- Specified by:
with
in interfaceJpaCteContainer
- See Also:
JpaSelectCriteria.from(JpaCteCriteria)
,JpaFrom.join(JpaCteCriteria, SqmJoinType)
-
withRecursiveUnionAll
public <X> JpaCteCriteria<X> withRecursiveUnionAll(AbstractQuery<X> baseCriteria, Function<JpaCteCriteria<X>,AbstractQuery<X>> recursiveCriteriaProducer)
Description copied from interface:JpaCteContainer
Allows to register a recursive CTE. The baseCriteriaQuery
serves for the structure of theJpaCteCriteria
, which is made available in the recursive criteria producer function, so that the recursiveCriteriaQuery
is able to refer to the CTE again.- Specified by:
withRecursiveUnionAll
in interfaceJpaCteContainer
- See Also:
JpaSelectCriteria.from(JpaCteCriteria)
,JpaFrom.join(JpaCteCriteria, SqmJoinType)
-
withRecursiveUnionDistinct
public <X> JpaCteCriteria<X> withRecursiveUnionDistinct(AbstractQuery<X> baseCriteria, Function<JpaCteCriteria<X>,AbstractQuery<X>> recursiveCriteriaProducer)
Description copied from interface:JpaCteContainer
Allows to register a recursive CTE. The baseCriteriaQuery
serves for the structure of theJpaCteCriteria
, which is made available in the recursive criteria producer function, so that the recursiveCriteriaQuery
is able to refer to the CTE again.- Specified by:
withRecursiveUnionDistinct
in interfaceJpaCteContainer
- See Also:
JpaSelectCriteria.from(JpaCteCriteria)
,JpaFrom.join(JpaCteCriteria, SqmJoinType)
-
with
public <X> JpaCteCriteria<X> with(String name, AbstractQuery<X> criteria)
Description copied from interface:JpaCteContainer
LikeJpaCteContainer.with(AbstractQuery)
but assigns an explicit CTE name.- Specified by:
with
in interfaceJpaCteContainer
-
withRecursiveUnionAll
public <X> JpaCteCriteria<X> withRecursiveUnionAll(String name, AbstractQuery<X> baseCriteria, Function<JpaCteCriteria<X>,AbstractQuery<X>> recursiveCriteriaProducer)
Description copied from interface:JpaCteContainer
LikeJpaCteContainer.withRecursiveUnionAll(AbstractQuery, Function)
but assigns an explicit CTE name.- Specified by:
withRecursiveUnionAll
in interfaceJpaCteContainer
-
withRecursiveUnionDistinct
public <X> JpaCteCriteria<X> withRecursiveUnionDistinct(String name, AbstractQuery<X> baseCriteria, Function<JpaCteCriteria<X>,AbstractQuery<X>> recursiveCriteriaProducer)
Description copied from interface:JpaCteContainer
LikeJpaCteContainer.withRecursiveUnionDistinct(AbstractQuery, Function)
but assigns an explicit CTE name.- Specified by:
withRecursiveUnionDistinct
in interfaceJpaCteContainer
-
getResultType
public Class<T> getResultType()
- Specified by:
getResultType
in interfaceAbstractQuery<T>
-
getQuerySpec
public SqmQuerySpec<T> getQuerySpec()
Description copied from interface:JpaSelectCriteria
The query structure. SeeJpaQueryStructure
for details- Specified by:
getQuerySpec
in interfaceJpaSelectCriteria<T>
- Specified by:
getQuerySpec
in interfaceSqmSelectQuery<T>
-
getQueryPart
public SqmQueryPart<T> getQueryPart()
Description copied from interface:JpaSelectCriteria
The query structure. SeeJpaQueryStructure
for details- Specified by:
getQueryPart
in interfaceJpaSelectCriteria<T>
- Specified by:
getQueryPart
in interfaceSqmSelectQuery<T>
-
setQueryPart
public void setQueryPart(SqmQueryPart<T> sqmQueryPart)
-
getRoots
public Set<Root<?>> getRoots()
- Specified by:
getRoots
in interfaceAbstractQuery<T>
-
from
public <X> SqmRoot<X> from(Class<X> entityClass)
- Specified by:
from
in interfaceAbstractQuery<T>
- Specified by:
from
in interfaceJpaSelectCriteria<T>
-
from
public <X> SqmDerivedRoot<X> from(Subquery<X> subquery)
Description copied from interface:JpaSelectCriteria
Create and add a query root corresponding to the given subquery, forming a cartesian product with any existing roots.- Specified by:
from
in interfaceJpaSelectCriteria<T>
- Parameters:
subquery
- the subquery- Returns:
- query root corresponding to the given subquery
-
from
public <X> JpaRoot<X> from(JpaCteCriteria<X> cte)
Description copied from interface:JpaSelectCriteria
Create and add a query root corresponding to the given cte, forming a cartesian product with any existing roots.- Specified by:
from
in interfaceJpaSelectCriteria<T>
- Parameters:
cte
- the cte criteria- Returns:
- query root corresponding to the given cte
-
from
public <X> SqmRoot<X> from(EntityType<X> entityType)
- Specified by:
from
in interfaceAbstractQuery<T>
- Specified by:
from
in interfaceJpaSelectCriteria<T>
-
isDistinct
public boolean isDistinct()
- Specified by:
isDistinct
in interfaceAbstractQuery<T>
-
distinct
public SqmSelectQuery<T> distinct(boolean distinct)
- Specified by:
distinct
in interfaceAbstractQuery<T>
- Specified by:
distinct
in interfaceJpaSelectCriteria<T>
- Specified by:
distinct
in interfaceSqmSelectQuery<T>
-
getSelection
public JpaSelection<T> getSelection()
- Specified by:
getSelection
in interfaceAbstractQuery<T>
- Specified by:
getSelection
in interfaceJpaSelectCriteria<T>
-
getRestriction
public SqmPredicate getRestriction()
- Specified by:
getRestriction
in interfaceCommonAbstractCriteria
- Specified by:
getRestriction
in interfaceJpaCriteriaBase
- Specified by:
getRestriction
in interfaceJpaSelectCriteria<T>
-
where
public SqmSelectQuery<T> where(Expression<Boolean> restriction)
- Specified by:
where
in interfaceAbstractQuery<T>
- Specified by:
where
in interfaceJpaSelectCriteria<T>
-
where
public SqmSelectQuery<T> where(Predicate... restrictions)
- Specified by:
where
in interfaceAbstractQuery<T>
- Specified by:
where
in interfaceJpaSelectCriteria<T>
-
getGroupList
public List<Expression<?>> getGroupList()
- Specified by:
getGroupList
in interfaceAbstractQuery<T>
-
groupBy
public SqmSelectQuery<T> groupBy(Expression<?>... expressions)
- Specified by:
groupBy
in interfaceAbstractQuery<T>
- Specified by:
groupBy
in interfaceJpaSelectCriteria<T>
-
groupBy
public SqmSelectQuery<T> groupBy(List<Expression<?>> grouping)
- Specified by:
groupBy
in interfaceAbstractQuery<T>
- Specified by:
groupBy
in interfaceJpaSelectCriteria<T>
-
getGroupRestriction
public SqmPredicate getGroupRestriction()
- Specified by:
getGroupRestriction
in interfaceAbstractQuery<T>
- Specified by:
getGroupRestriction
in interfaceJpaSelectCriteria<T>
-
having
public SqmSelectQuery<T> having(Expression<Boolean> booleanExpression)
- Specified by:
having
in interfaceAbstractQuery<T>
- Specified by:
having
in interfaceJpaSelectCriteria<T>
-
having
public SqmSelectQuery<T> having(Predicate... predicates)
- Specified by:
having
in interfaceAbstractQuery<T>
- Specified by:
having
in interfaceJpaSelectCriteria<T>
-
appendHqlString
public void appendHqlString(StringBuilder sb)
-
-