Top Description Methods
org.hibernate.query.criteria

public Interface JpaSelectCriteria<T>

extends AbstractQuery<T>, JpaCriteriaBase
Known Direct Subinterfaces
org.hibernate.query.criteria.JpaSubQuery, org.hibernate.query.sqm.tree.select.SqmSelectQuery, org.hibernate.query.criteria.JpaCriteriaQuery
Imports
java.util.List, jakarta.persistence.criteria.AbstractQuery, .Expression, .Predicate, .Subquery, jakarta.persistence.metamodel.EntityType

Commonality between a JPA JpaCriteriaQuery and JpaSubQuery, mainly in the form of delegation to JpaQueryStructure
Author
Steve Ebersole

Method Summary

Modifier and TypeMethod and Description
public JpaSelectCriteria<T>
distinct(boolean
boolean value specifying whether duplicate results must be eliminated from the query result or whether they must be retained
distinct
)

Redeclares jakarta.persistence.criteria.AbstractQuery.distinct.

Specify whether duplicate query results will be eliminated.
public <X> JpaDerivedRoot<X>

Returns:

query root corresponding to the given subquery
from
(Subquery<X>
the subquery
subquery
)

Create and add a query root corresponding to the given subquery, forming a cartesian product with any existing roots.

public <X> JpaRoot<X>

Returns:

query root corresponding to the given cte
from
(JpaCteCriteria<X>
the cte criteria
cte
)

Create and add a query root corresponding to the given cte, forming a cartesian product with any existing roots.

public <X> JpaRoot<X>
from(Class<X>
the entity class
entityClass
)

Redeclares jakarta.persistence.criteria.AbstractQuery.from.

Create and add a query root corresponding to the given entity, forming a cartesian product with any existing roots.
public <X> JpaRoot<X>
from(EntityType<X>
metamodel entity representing the entity of type X
entity
)

Redeclares jakarta.persistence.criteria.AbstractQuery.from.

Create and add a query root corresponding to the given entity, forming a cartesian product with any existing roots.
public JpaPredicate
getGroupRestriction()

Redeclares jakarta.persistence.criteria.AbstractQuery.getGroupRestriction.

Return the predicate that corresponds to the restriction(s) over the grouping items, or null if no restrictions have been specified.
public JpaQueryPart<T>
getQueryPart()

The query structure.

public JpaQueryStructure<T>
getQuerySpec()

The query structure.

public JpaPredicate
getRestriction()

Redeclares jakarta.persistence.criteria.CommonAbstractCriteria.getRestriction, org.hibernate.query.criteria.JpaCriteriaBase.getRestriction.

Return the predicate that corresponds to the where clause restriction(s), or null if no restrictions have been specified.
public JpaSelection<T>
getSelection()

Redeclares jakarta.persistence.criteria.AbstractQuery.getSelection.

Return the selection of the query, or null if no selection has been set.
public JpaSelectCriteria<T>
groupBy(Expression<?>...
zero or more grouping expressions
grouping
)

Redeclares jakarta.persistence.criteria.AbstractQuery.groupBy.

Specify the expressions that are used to form groups over the query results.
public JpaSelectCriteria<T>
groupBy(List<Expression<?>>
list of zero or more grouping expressions
grouping
)

Redeclares jakarta.persistence.criteria.AbstractQuery.groupBy.

Specify the expressions that are used to form groups over the query results.
public JpaSelectCriteria<T>
having(Expression<Boolean>
a simple or compound boolean expression
restriction
)

Redeclares jakarta.persistence.criteria.AbstractQuery.having.

Specify a restriction over the groups of the query.
public JpaSelectCriteria<T>
having(Predicate...
zero or more restriction predicates
restrictions
)

Redeclares jakarta.persistence.criteria.AbstractQuery.having.

Specify restrictions over the groups of the query according the conjunction of the specified restriction predicates.
public JpaSelectCriteria<T>
where(Expression<Boolean>
a simple or compound boolean expression
restriction
)

Redeclares jakarta.persistence.criteria.AbstractQuery.where.

Modify the query to restrict the query results according to the specified boolean expression.
public JpaSelectCriteria<T>
where(Predicate...
zero or more restriction predicates
restrictions
)

Redeclares jakarta.persistence.criteria.AbstractQuery.where.

Modify the query to restrict the query results according to the conjunction of the specified restriction predicates.
Inherited from jakarta.persistence.criteria.AbstractQuery:
getGroupListgetResultTypegetRootsisDistinct
Inherited from org.hibernate.query.criteria.JpaCriteriaBase:
subquery

Method Detail

distinctback to summary
public JpaSelectCriteria<T> distinct(boolean distinct)

Redeclares jakarta.persistence.criteria.AbstractQuery.distinct.

Doc from jakarta.persistence.criteria.AbstractQuery.distinct.

Specify 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.

Parameters
distinct:boolean

boolean value specifying whether duplicate results must be eliminated from the query result or whether they must be retained

Returns:JpaSelectCriteria<T>

the modified query

Annotations
@Override
fromback to summary
public <X> JpaDerivedRoot<X> from(Subquery<X> subquery)

Create and add a query root corresponding to the given subquery, forming a cartesian product with any existing roots.

Parameters
subquery:Subquery<X>

the subquery

Returns:JpaDerivedRoot<X>

query root corresponding to the given subquery

fromback to summary
public <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.

Parameters
cte:JpaCteCriteria<X>

the cte criteria

Returns:JpaRoot<X>

query root corresponding to the given cte

fromback to summary
public <X> JpaRoot<X> from(Class<X> entityClass)

Redeclares jakarta.persistence.criteria.AbstractQuery.from.

Doc from jakarta.persistence.criteria.AbstractQuery.from.

Create and add a query root corresponding to the given entity, forming a cartesian product with any existing roots.

Parameters
entityClass:Class<X>

the entity class

Returns:JpaRoot<X>

query root corresponding to the given entity

Annotations
@Override
fromback to summary
public <X> JpaRoot<X> from(EntityType<X> entity)

Redeclares jakarta.persistence.criteria.AbstractQuery.from.

Doc from jakarta.persistence.criteria.AbstractQuery.from.

Create and add a query root corresponding to the given entity, forming a cartesian product with any existing roots.

Parameters
entity:EntityType<X>

metamodel entity representing the entity of type X

Returns:JpaRoot<X>

query root corresponding to the given entity

Annotations
@Override
getGroupRestrictionback to summary
public JpaPredicate getGroupRestriction()

Redeclares jakarta.persistence.criteria.AbstractQuery.getGroupRestriction.

Doc from jakarta.persistence.criteria.AbstractQuery.getGroupRestriction.

Return the predicate that corresponds to the restriction(s) over the grouping items, or null if no restrictions have been specified.

Returns:JpaPredicate

having clause predicate

Annotations
@Override
getQueryPartback to summary
public JpaQueryPart<T> getQueryPart()

The query structure. See JpaQueryStructure for details

getQuerySpecback to summary
public JpaQueryStructure<T> getQuerySpec()

The query structure. See JpaQueryStructure for details

getRestrictionback to summary
public JpaPredicate getRestriction()

Redeclares jakarta.persistence.criteria.CommonAbstractCriteria.getRestriction, org.hibernate.query.criteria.JpaCriteriaBase.getRestriction.

Doc from jakarta.persistence.criteria.CommonAbstractCriteria.getRestriction.

Return the predicate that corresponds to the where clause restriction(s), or null if no restrictions have been specified.

Returns:JpaPredicate

where clause predicate

Annotations
@Override
getSelectionback to summary
public JpaSelection<T> getSelection()

Redeclares jakarta.persistence.criteria.AbstractQuery.getSelection.

Doc from jakarta.persistence.criteria.AbstractQuery.getSelection.

Return the selection of the query, or null if no selection has been set.

Returns:JpaSelection<T>

selection item

Annotations
@Override
groupByback to summary
public JpaSelectCriteria<T> groupBy(Expression<?>... grouping)

Redeclares jakarta.persistence.criteria.AbstractQuery.groupBy.

Doc from jakarta.persistence.criteria.AbstractQuery.groupBy.

Specify 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.

Parameters
grouping:Expression<?>[]

zero or more grouping expressions

Returns:JpaSelectCriteria<T>

the modified query

Annotations
@Override
groupByback to summary
public JpaSelectCriteria<T> groupBy(List<Expression<?>> grouping)

Redeclares jakarta.persistence.criteria.AbstractQuery.groupBy.

Doc from jakarta.persistence.criteria.AbstractQuery.groupBy.

Specify 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.

Parameters
grouping:List<Expression<?>>

list of zero or more grouping expressions

Returns:JpaSelectCriteria<T>

the modified query

Annotations
@Override
havingback to summary
public JpaSelectCriteria<T> having(Expression<Boolean> restriction)

Redeclares jakarta.persistence.criteria.AbstractQuery.having.

Doc from jakarta.persistence.criteria.AbstractQuery.having.

Specify a restriction over the groups of the query. Replaces the previous having restriction(s), if any.

Parameters
restriction:Expression<Boolean>

a simple or compound boolean expression

Returns:JpaSelectCriteria<T>

the modified query

Annotations
@Override
havingback to summary
public JpaSelectCriteria<T> having(Predicate... restrictions)

Redeclares jakarta.persistence.criteria.AbstractQuery.having.

Doc from jakarta.persistence.criteria.AbstractQuery.having.

Specify 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.

Parameters
restrictions:Predicate[]

zero or more restriction predicates

Returns:JpaSelectCriteria<T>

the modified query

Annotations
@Override
whereback to summary
public JpaSelectCriteria<T> where(Expression<Boolean> restriction)

Redeclares jakarta.persistence.criteria.AbstractQuery.where.

Doc from jakarta.persistence.criteria.AbstractQuery.where.

Modify the query to restrict the query results according to the specified boolean expression. Replaces the previously added restriction(s), if any.

Parameters
restriction:Expression<Boolean>

a simple or compound boolean expression

Returns:JpaSelectCriteria<T>

the modified query

Annotations
@Override
whereback to summary
public JpaSelectCriteria<T> where(Predicate... restrictions)

Redeclares jakarta.persistence.criteria.AbstractQuery.where.

Doc from jakarta.persistence.criteria.AbstractQuery.where.

Modify 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.

Parameters
restrictions:Predicate[]

zero or more restriction predicates

Returns:JpaSelectCriteria<T>

the modified query

Annotations
@Override