Package jakarta.persistence.criteria
Interface Subquery<T>
- Type Parameters:
T
- the type of the selection item.
- All Superinterfaces:
AbstractQuery<T>
,CommonAbstractCriteria
,Expression<T>
,Selection<T>
,TupleElement<T>
The
Subquery
interface defines functionality that is
specific to subqueries.
A subquery has an expression as its selection item.
- Since:
- 2.0
-
Method Summary
Modifier and TypeMethodDescription<X,
Y> CollectionJoin <X, Y> correlate
(CollectionJoin<X, Y> parentCollection) Create a subquery collection join object correlated to a collection join object of the enclosing query.<X,
Y> Join <X, Y> Create a subquery join object correlated to a join object of the enclosing query.<X,
Y> ListJoin <X, Y> Create a subquery list join object correlated to a list join object of the enclosing query.<X,
K, V> MapJoin <X, K, V> Create a subquery map join object correlated to a map join object of the enclosing query.<Y> Root
<Y> Create a subquery root correlated to a root of the enclosing query.<X,
Y> SetJoin <X, Y> Create a subquery set join object correlated to a set join object of the enclosing query.distinct
(boolean distinct) Specify whether duplicate query results are eliminated.Return the query of which this is a subquery.Return the correlated joins of the subquery.Return the query of which this is a subquery.Return the selection expression.groupBy
(Expression<?>... grouping) Specify the expressions that are used to form groups over the subquery results.groupBy
(List<Expression<?>> grouping) Specify the expressions that are used to form groups over the subquery results.having
(Expression<Boolean> restriction) Specify a restriction over the groups of the subquery.Specify restrictions over the groups of the subquery according the conjunction of the specified restriction predicates.Specify restrictions over the groups of the query according the conjunction of the specified restriction predicates.select
(Expression<T> expression) Specify the item that is to be returned as the subquery result.where
(Expression<Boolean> restriction) Modify the subquery to restrict the result according to the specified boolean expression.Modify the subquery to restrict the result according to the conjunction of the specified restriction predicates.Modify the query to restrict the query result according to the conjunction of the specified restriction predicates.Methods inherited from interface jakarta.persistence.criteria.AbstractQuery
from, from, getGroupList, getGroupRestriction, getResultType, getRoots, isDistinct
Methods inherited from interface jakarta.persistence.criteria.CommonAbstractCriteria
getParameters, getRestriction, subquery, subquery
Methods inherited from interface jakarta.persistence.criteria.Expression
as, cast, equalTo, equalTo, in, in, in, in, isNotNull, isNull, notEqualTo, notEqualTo
Methods inherited from interface jakarta.persistence.criteria.Selection
alias, getCompoundSelectionItems, isCompoundSelection
Methods inherited from interface jakarta.persistence.TupleElement
getAlias, getJavaType
-
Method Details
-
select
Specify the item that is to be returned as the subquery result. Replaces the previously specified selection, if any.- Parameters:
expression
- expression specifying the item that is to be returned as the subquery result- Returns:
- the modified subquery
-
where
Modify the subquery to restrict the result according to the specified boolean expression. Replaces the previously added restriction(s), if any. This method only overrides the return type of the correspondingAbstractQuery
method.- Specified by:
where
in interfaceAbstractQuery<T>
- Parameters:
restriction
- a simple or compound boolean expression- Returns:
- the modified subquery
-
where
Modify the subquery to restrict the result 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. This method only overrides the return type of the correspondingAbstractQuery
method.- Specified by:
where
in interfaceAbstractQuery<T>
- Parameters:
restrictions
- zero or more restriction predicates- Returns:
- the modified subquery
-
where
Modify the query to restrict the query result 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. This method only overrides the return type of the correspondingAbstractQuery
method.- Specified by:
where
in interfaceAbstractQuery<T>
- Parameters:
restrictions
- a list of zero or more restriction predicates- Returns:
- the modified query
- Since:
- 3.2
-
groupBy
Specify the expressions that are used to form groups over the subquery results. Replaces the previous specified grouping expressions, if any. If no grouping expressions are specified, any previously added grouping expressions are simply removed. This method only overrides the return type of the correspondingAbstractQuery
method.- Specified by:
groupBy
in interfaceAbstractQuery<T>
- Parameters:
grouping
- zero or more grouping expressions- Returns:
- the modified subquery
-
groupBy
Specify the expressions that are used to form groups over the subquery results. Replaces the previous specified grouping expressions, if any. If no grouping expressions are specified, any previously added grouping expressions are simply removed. This method only overrides the return type of the correspondingAbstractQuery
method.- Specified by:
groupBy
in interfaceAbstractQuery<T>
- Parameters:
grouping
- list of zero or more grouping expressions- Returns:
- the modified subquery
-
having
Specify a restriction over the groups of the subquery. Replaces the previous having restriction(s), if any. This method only overrides the return type of the correspondingAbstractQuery
method.- Specified by:
having
in interfaceAbstractQuery<T>
- Parameters:
restriction
- a simple or compound boolean expression- Returns:
- the modified subquery
-
having
Specify restrictions over the groups of the subquery according the conjunction of the specified restriction predicates. Replaces the previously added having restriction(s), if any. If no restrictions are specified, any previously added restrictions are simply removed. This method only overrides the return type of the correspondingAbstractQuery
method.- Specified by:
having
in interfaceAbstractQuery<T>
- Parameters:
restrictions
- zero or more restriction predicates- Returns:
- the modified subquery
-
having
Specify restrictions over the groups of the query according the conjunction of the specified restriction predicates. Replaces the previously added having restriction(s), if any. If no restrictions are specified, any previously added restrictions are simply removed. This method only overrides the return type of the correspondingAbstractQuery
method.- Specified by:
having
in interfaceAbstractQuery<T>
- Parameters:
restrictions
- a list of zero or more restriction predicates- Returns:
- the modified query
- Since:
- 3.2
-
distinct
Specify whether duplicate query results are 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. This method only overrides the return type of the correspondingAbstractQuery
method.- Specified by:
distinct
in interfaceAbstractQuery<T>
- Parameters:
distinct
- boolean value specifying whether duplicate results must be eliminated from the subquery result or whether they must be retained- Returns:
- the modified subquery.
-
correlate
Create a subquery root correlated to a root of the enclosing query.- Parameters:
parentRoot
- a root of the containing query- Returns:
- subquery root
-
correlate
Create a subquery join object correlated to a join object of the enclosing query.- Parameters:
parentJoin
- join object of the containing query- Returns:
- subquery join
-
correlate
Create a subquery collection join object correlated to a collection join object of the enclosing query.- Parameters:
parentCollection
- join object of the containing query- Returns:
- subquery join
-
correlate
Create a subquery set join object correlated to a set join object of the enclosing query.- Parameters:
parentSet
- join object of the containing query- Returns:
- subquery join
-
correlate
Create a subquery list join object correlated to a list join object of the enclosing query.- Parameters:
parentList
- join object of the containing query- Returns:
- subquery join
-
correlate
Create a subquery map join object correlated to a map join object of the enclosing query.- Parameters:
parentMap
- join object of the containing query- Returns:
- subquery join
-
getParent
AbstractQuery<?> getParent()Return the query of which this is a subquery. This must be a CriteriaQuery or a Subquery.- Returns:
- the enclosing query or subquery
-
getContainingQuery
CommonAbstractCriteria getContainingQuery()Return the query of which this is a subquery. This may be a CriteriaQuery, CriteriaUpdate, CriteriaDelete, or a Subquery.- Returns:
- the enclosing query or subquery
- Since:
- 2.1
-
getSelection
Expression<T> getSelection()Return the selection expression.- Specified by:
getSelection
in interfaceAbstractQuery<T>
- Returns:
- the item to be returned in the subquery result
-