Class SqmSelectStatement<T>
java.lang.Object
org.hibernate.query.sqm.tree.AbstractSqmNode
org.hibernate.query.sqm.tree.select.AbstractSqmSelectQuery<T>
org.hibernate.query.sqm.tree.select.SqmSelectStatement<T>
- All Implemented Interfaces:
AbstractQuery<T>,CommonAbstractCriteria,CriteriaQuery<T>,Serializable,JpaCriteriaBase,JpaCriteriaNode,JpaCriteriaQuery<T>,JpaCteContainer,JpaQueryableCriteria<T>,JpaSelectCriteria<T>,ParameterCollector,SqmCteContainer,SqmSelectQuery<T>,SqmNode,SqmQuery<T>,SqmStatement<T>,SqmVisitableNode
public class SqmSelectStatement<T>
extends AbstractSqmSelectQuery<T>
implements JpaCriteriaQuery<T>, SqmStatement<T>, ParameterCollector
- Author:
- Steve Ebersole
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.hibernate.query.sqm.tree.SqmStatement
SqmStatement.ParameterResolutions -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionSqmSelectStatement(Class<T> resultJavaType, NodeBuilder nodeBuilder) SqmSelectStatement(Class<T> resultJavaType, SqmQuerySource querySource, NodeBuilder nodeBuilder) SqmSelectStatement(NodeBuilder nodeBuilder) SqmSelectStatement(SqmQuerySource querySource, NodeBuilder nodeBuilder) SqmSelectStatement(SqmQueryPart<T> queryPart, Class<T> resultType, Map<String, SqmCteStatement<?>> cteStatements, SqmQuerySource querySource, NodeBuilder builder) SqmSelectStatement(SqmQueryPart<T> queryPart, Class<T> resultType, SqmQuerySource querySource, NodeBuilder builder) SqmSelectStatement(SqmSelectStatement<T> original) -
Method Summary
Modifier and TypeMethodDescription<X> Xaccept(SemanticQueryWalker<X> walker) Accept the walker per visitationvoidaddParameter(SqmParameter<?> parameter) booleancopy(SqmCopyContext context) A query that returns the number of results of this query.distinct(boolean distinct) Specify whether duplicate query results will be eliminated.fetch(Number fetch, FetchClauseType fetchClauseType) fetch(JpaExpression<? extends Number> fetch) fetch(JpaExpression<? extends Number> fetch, FetchClauseType fetchClauseType) getFetch()Return the parameters of the query.The query structure.Set<SqmParameter<?>>Access to the (potentially still growing) collection of parameters for the statement.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.multiselect(Selection<?>... selections) Specify the selection items that are to be returned in the query result.multiselect(List<Selection<?>> selectionList) Specify the selection items that are to be returned in the query result.offset(JpaExpression<? extends Number> offset) Specify the ordering expressions that are used to order the query results.Specify the ordering expressions that are used to order the query results.booleanSpecify the item that is to be returned in the query result.<U> SqmSubQuery<U>Create a subquery of the query.booleanvoidvalidateResultType(Class<?> resultType) 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.Methods inherited from class org.hibernate.query.sqm.tree.select.AbstractSqmSelectQuery
appendHqlString, copyCteStatements, from, from, from, from, getCteCriteria, getCteCriterias, getCteStatement, getCteStatements, getGroupList, getGroupRestriction, getQueryPart, getRestriction, getResultSelection, getResultType, getRootList, getRoots, getSelection, isDistinct, setQueryPart, setResultType, with, with, withRecursiveUnionAll, withRecursiveUnionAll, withRecursiveUnionDistinct, withRecursiveUnionDistinctMethods 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 jakarta.persistence.criteria.AbstractQuery
getGroupList, getResultType, getRoots, isDistinctMethods inherited from interface org.hibernate.query.criteria.JpaCriteriaQuery
from, from, getOrderList, getRootListMethods inherited from interface org.hibernate.query.criteria.JpaCteContainer
getCteCriteria, getCteCriterias, with, with, withRecursiveUnionAll, withRecursiveUnionAll, withRecursiveUnionDistinct, withRecursiveUnionDistinctMethods inherited from interface org.hibernate.query.criteria.JpaSelectCriteria
from, from, getGroupRestriction, getRestriction, getSelectionMethods inherited from interface org.hibernate.query.sqm.tree.SqmNode
asLoggableText, nodeBuilderMethods inherited from interface org.hibernate.query.sqm.tree.SqmVisitableNode
appendHqlString, toHqlString
-
Constructor Details
-
SqmSelectStatement
-
SqmSelectStatement
-
SqmSelectStatement
public SqmSelectStatement(Class<T> resultJavaType, SqmQuerySource querySource, NodeBuilder nodeBuilder) -
SqmSelectStatement
public SqmSelectStatement(SqmQueryPart<T> queryPart, Class<T> resultType, SqmQuerySource querySource, NodeBuilder builder) -
SqmSelectStatement
public SqmSelectStatement(SqmQueryPart<T> queryPart, Class<T> resultType, Map<String, SqmCteStatement<?>> cteStatements, SqmQuerySource querySource, NodeBuilder builder) -
SqmSelectStatement
-
SqmSelectStatement
-
-
Method Details
-
copy
-
validateResultType
-
getQuerySource
- Specified by:
getQuerySourcein interfaceSqmStatement<T>
-
getQuerySpec
Description copied from interface:JpaSelectCriteriaThe query structure. SeeJpaQueryStructurefor details- Specified by:
getQuerySpecin interfaceJpaSelectCriteria<T>- Specified by:
getQuerySpecin interfaceSqmSelectQuery<T>- Overrides:
getQuerySpecin classAbstractSqmSelectQuery<T>
-
producesUniqueResults
public boolean producesUniqueResults() -
containsCollectionFetches
public boolean containsCollectionFetches() -
usesDistinct
public boolean usesDistinct() -
getSqmParameters
Description copied from interface:SqmStatementAccess to the (potentially still growing) collection of parameters for the statement.- Specified by:
getSqmParametersin interfaceSqmStatement<T>
-
resolveParameters
- Specified by:
resolveParametersin interfaceSqmStatement<T>
-
accept
Description copied from interface:SqmVisitableNodeAccept the walker per visitation- Specified by:
acceptin interfaceSqmVisitableNode
-
addParameter
- Specified by:
addParameterin interfaceParameterCollector
-
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 interfaceCriteriaQuery<T>- Specified by:
distinctin interfaceJpaCriteriaQuery<T>- Specified by:
distinctin interfaceJpaSelectCriteria<T>- Specified by:
distinctin interfaceSqmSelectQuery<T>- Overrides:
distinctin classAbstractSqmSelectQuery<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
-
getParameters
Description copied from interface:JpaCriteriaQueryReturn the parameters of the query. Returns empty set if there are no parameters. Modifications to the set do not affect the query.- Specified by:
getParametersin interfaceCriteriaQuery<T>- Specified by:
getParametersin interfaceJpaCriteriaQuery<T>- Returns:
- the query parameters
-
select
Description copied from interface:CriteriaQuerySpecify the item that is to be returned in the query result. Replaces the previously specified selection(s), if any.Note: Applications using the string-based API may need to specify the type of the select item when it results from a get or join operation and the query result type is specified.
For example: CriteriaQuery<String> q = cb.createQuery(String.class); Root<Order> order = q.from(Order.class); q.select(order.get("shippingAddress").<String>get("state")); CriteriaQuery<Product> q2 = cb.createQuery(Product.class); q2.select(q2.from(Order.class) .join("items") .<Item,Product>join("product"));- Specified by:
selectin interfaceCriteriaQuery<T>- Specified by:
selectin interfaceJpaCriteriaQuery<T>- Parameters:
selection- selection specifying the item that is to be returned in the query result- Returns:
- the modified query
-
multiselect
Description copied from interface:CriteriaQuerySpecify the selection items that are to be returned in the query result. Replaces the previously specified selection(s), if any. The type of the result of the query execution depends on the specification of the type of the criteria query object created as well as the arguments to the multiselect method.An argument to the multiselect method must not be a tuple- or array-valued compound selection item.
The semantics of this method are as follows:
-
If the type of the criteria query is
CriteriaQuery<Tuple>(i.e., a criteria query object created by either thecreateTupleQuerymethod or by passing aTupleclass argument to thecreateQuerymethod), aTupleobject corresponding to the arguments of themultiselectmethod, in the specified order, will be instantiated and returned for each row that results from the query execution. - If the type of the criteria query is
CriteriaQuery<X>for some user-defined class X (i.e., a criteria query object created by passing a X class argument to thecreateQuerymethod), the arguments to themultiselectmethod will be passed to the X constructor and an instance of type X will be returned for each row. - If the type of the criteria query is
CriteriaQuery<X[]>for some class X, an instance of type X[] will be returned for each row. The elements of the array will correspond to the arguments of themultiselectmethod, in the specified order. - If the type of the criteria query is
CriteriaQuery<Object>or if the criteria query was created without specifying a type, and only a single argument is passed to themultiselectmethod, an instance of typeObjectwill be returned for each row. - If the type of the criteria query is
CriteriaQuery<Object>or if the criteria query was created without specifying a type, and more than one argument is passed to themultiselectmethod, an instance of typeObject[]will be instantiated and returned for each row. The elements of the array will correspond to the arguments to themultiselectmethod, in the specified order.
- Specified by:
multiselectin interfaceCriteriaQuery<T>- Specified by:
multiselectin interfaceJpaCriteriaQuery<T>- Parameters:
selections- selection items corresponding to the results to be returned by the query- Returns:
- the modified query
-
If the type of the criteria query is
-
multiselect
Description copied from interface:CriteriaQuerySpecify the selection items that are to be returned in the query result. Replaces the previously specified selection(s), if any.The type of the result of the query execution depends on the specification of the type of the criteria query object created as well as the argument to the
multiselectmethod. An element of the list passed to themultiselectmethod must not be a tuple- or array-valued compound selection item.The semantics of this method are as follows:
- If the type of the criteria query is
CriteriaQuery<Tuple>(i.e., a criteria query object created by either thecreateTupleQuerymethod or by passing aTupleclass argument to thecreateQuerymethod), aTupleobject corresponding to the elements of the list passed to themultiselectmethod, in the specified order, will be instantiated and returned for each row that results from the query execution. - If the type of the criteria query is
CriteriaQuery<X>for some user-defined class X (i.e., a criteria query object created by passing a X class argument to thecreateQuerymethod), the elements of the list passed to themultiselectmethod will be passed to the X constructor and an instance of type X will be returned for each row. - If the type of the criteria query is
CriteriaQuery<X[]>for some class X, an instance of type X[] will be returned for each row. The elements of the array will correspond to the elements of the list passed to themultiselectmethod, in the specified order. - If the type of the criteria query is
CriteriaQuery<Object>or if the criteria query was created without specifying a type, and the list passed to themultiselectmethod contains only a single element, an instance of typeObjectwill be returned for each row. - If the type of the criteria query is
CriteriaQuery<Object>or if the criteria query was created without specifying a type, and the list passed to themultiselectmethod contains more than one element, an instance of typeObject[]will be instantiated and returned for each row. The elements of the array will correspond to the elements of the list passed to themultiselectmethod, in the specified order.
- Specified by:
multiselectin interfaceCriteriaQuery<T>- Specified by:
multiselectin interfaceJpaCriteriaQuery<T>- Parameters:
selectionList- list of selection items corresponding to the results to be returned by the query- Returns:
- the modified query
- If the type of the criteria query is
-
orderBy
Description copied from interface:CriteriaQuerySpecify the ordering expressions that are used to order the query results. Replaces the previous ordering expressions, if any. If no ordering expressions are specified, the previous ordering, if any, is simply removed, and results will be returned in no particular order. The left-to-right sequence of the ordering expressions determines the precedence, whereby the leftmost has highest precedence.- Specified by:
orderByin interfaceCriteriaQuery<T>- Specified by:
orderByin interfaceJpaCriteriaQuery<T>- Parameters:
orders- zero or more ordering expressions- Returns:
- the modified query
-
orderBy
Description copied from interface:CriteriaQuerySpecify the ordering expressions that are used to order the query results. Replaces the previous ordering expressions, if any. If no ordering expressions are specified, the previous ordering, if any, is simply removed, and results will be returned in no particular order. The order of the ordering expressions in the list determines the precedence, whereby the first element in the list has highest precedence.- Specified by:
orderByin interfaceCriteriaQuery<T>- Specified by:
orderByin interfaceJpaCriteriaQuery<T>- Parameters:
orders- list of zero or more ordering expressions- Returns:
- the modified query
-
subquery
Description copied from interface:CommonAbstractCriteriaCreate a subquery of the query.- Specified by:
subqueryin interfaceCommonAbstractCriteria- Specified by:
subqueryin interfaceJpaCriteriaBase- Parameters:
type- the subquery result type- Returns:
- subquery
-
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 interfaceCriteriaQuery<T>- Specified by:
wherein interfaceJpaCriteriaQuery<T>- Specified by:
wherein interfaceJpaSelectCriteria<T>- Overrides:
wherein classAbstractSqmSelectQuery<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 interfaceCriteriaQuery<T>- Specified by:
wherein interfaceJpaCriteriaQuery<T>- Specified by:
wherein interfaceJpaSelectCriteria<T>- Overrides:
wherein classAbstractSqmSelectQuery<T>- Parameters:
restrictions- zero or more restriction predicates- 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 interfaceCriteriaQuery<T>- Specified by:
groupByin interfaceJpaCriteriaQuery<T>- Specified by:
groupByin interfaceJpaSelectCriteria<T>- Overrides:
groupByin classAbstractSqmSelectQuery<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 interfaceCriteriaQuery<T>- Specified by:
groupByin interfaceJpaCriteriaQuery<T>- Specified by:
groupByin interfaceJpaSelectCriteria<T>- Overrides:
groupByin classAbstractSqmSelectQuery<T>- Parameters:
grouping- list of zero or more grouping expressions- Returns:
- the modified query
-
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 interfaceCriteriaQuery<T>- Specified by:
havingin interfaceJpaCriteriaQuery<T>- Specified by:
havingin interfaceJpaSelectCriteria<T>- Overrides:
havingin classAbstractSqmSelectQuery<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 interfaceCriteriaQuery<T>- Specified by:
havingin interfaceJpaCriteriaQuery<T>- Specified by:
havingin interfaceJpaSelectCriteria<T>- Overrides:
havingin classAbstractSqmSelectQuery<T>- Parameters:
predicates- zero or more restriction predicates- Returns:
- the modified query
-
getOffset
- Specified by:
getOffsetin interfaceJpaCriteriaQuery<T>
-
offset
- Specified by:
offsetin interfaceJpaCriteriaQuery<T>
-
offset
- Specified by:
offsetin interfaceJpaCriteriaQuery<T>
-
getFetch
- Specified by:
getFetchin interfaceJpaCriteriaQuery<T>
-
fetch
- Specified by:
fetchin interfaceJpaCriteriaQuery<T>
-
fetch
public JpaCriteriaQuery<T> fetch(JpaExpression<? extends Number> fetch, FetchClauseType fetchClauseType) - Specified by:
fetchin interfaceJpaCriteriaQuery<T>
-
fetch
- Specified by:
fetchin interfaceJpaCriteriaQuery<T>
-
fetch
- Specified by:
fetchin interfaceJpaCriteriaQuery<T>
-
getFetchClauseType
- Specified by:
getFetchClauseTypein interfaceJpaCriteriaQuery<T>
-
createCountQuery
Description copied from interface:JpaCriteriaQueryA query that returns the number of results of this query.- Specified by:
createCountQueryin interfaceJpaCriteriaQuery<T>- See Also:
-