Top Description Methods
javax.persistence.criteria

public Interface Subquery<T>

extends AbstractQuery<T>, Expression<T>
Type Parameters
<T>
the type of the selection item.
Imports
java.util.List, .Set

The Subquery interface defines functionality that is specific to subqueries. A subquery has an expression as its selection item.
Since
Java Persistence 2.0

Method Summary

Modifier and TypeMethod and Description
public <Y> Root<Y>

Returns:

subquery root
correlate
(Root<Y>
a root of the containing query
parentRoot
)

Create a subquery root correlated to a root of the enclosing query.

public <X, Y> Join<X, Y>

Returns:

subquery join
correlate
(Join<X, Y>
join object of the containing query
parentJoin
)

Create a subquery join object correlated to a join object of the enclosing query.

public <X, Y> CollectionJoin<X, Y>

Returns:

subquery join
correlate
(CollectionJoin<X, Y>
join object of the containing query
parentCollection
)

Create a subquery collection join object correlated to a collection join object of the enclosing query.

public <X, Y> SetJoin<X, Y>

Returns:

subquery join
correlate
(SetJoin<X, Y>
join object of the containing query
parentSet
)

Create a subquery set join object correlated to a set join object of the enclosing query.

public <X, Y> ListJoin<X, Y>

Returns:

subquery join
correlate
(ListJoin<X, Y>
join object of the containing query
parentList
)

Create a subquery list join object correlated to a list join object of the enclosing query.

public <X, K, V> MapJoin<X, K, V>

Returns:

subquery join
correlate
(MapJoin<X, K, V>
join object of the containing query
parentMap
)

Create a subquery map join object correlated to a map join object of the enclosing query.

public Subquery<T>

Returns:

the modified subquery.
distinct
(boolean
boolean value specifying whether duplicate results must be eliminated from the subquery result or whether they must be retained
distinct
)

Redeclares javax.persistence.criteria.AbstractQuery.distinct.

Specify whether duplicate query results will be eliminated.
public CommonAbstractCriteria

Returns:

the enclosing query or subquery
getContainingQuery
()

Return the query of which this is a subquery.

public Set<Join<?, ?>>

Returns:

the correlated joins of the subquery
getCorrelatedJoins
()

Return the correlated joins of the subquery.

public AbstractQuery<?>

Returns:

the enclosing query or subquery
getParent
()

Return the query of which this is a subquery.

public Expression<T>

Returns:

the item to be returned in the subquery result
getSelection
()

Redeclares javax.persistence.criteria.AbstractQuery.getSelection.

Return the selection expression.
public Subquery<T>

Returns:

the modified subquery
groupBy
(Expression<?>...
zero or more grouping expressions
grouping
)

Redeclares javax.persistence.criteria.AbstractQuery.groupBy.

Specify the expressions that are used to form groups over the subquery results.
public Subquery<T>

Returns:

the modified subquery
groupBy
(List<Expression<?>>
list of zero or more grouping expressions
grouping
)

Redeclares javax.persistence.criteria.AbstractQuery.groupBy.

Specify the expressions that are used to form groups over the subquery results.
public Subquery<T>

Returns:

the modified subquery
having
(Expression<Boolean>
a simple or compound boolean expression
restriction
)

Redeclares javax.persistence.criteria.AbstractQuery.having.

Specify a restriction over the groups of the subquery.
public Subquery<T>

Returns:

the modified subquery
having
(Predicate...
zero or more restriction predicates
restrictions
)

Redeclares javax.persistence.criteria.AbstractQuery.having.

Specify restrictions over the groups of the subquery according the conjunction of the specified restriction predicates.
public Subquery<T>

Returns:

the modified subquery
select
(Expression<T>
expression specifying the item that is to be returned as the subquery result
expression
)

Specify the item that is to be returned as the subquery result.

public Subquery<T>

Returns:

the modified subquery
where
(Expression<Boolean>
a simple or compound boolean expression
restriction
)

Redeclares javax.persistence.criteria.AbstractQuery.where.

Modify the subquery to restrict the result according to the specified boolean expression.
public Subquery<T>

Returns:

the modified subquery
where
(Predicate...
zero or more restriction predicates
restrictions
)

Redeclares javax.persistence.criteria.AbstractQuery.where.

Modify the subquery to restrict the result according to the conjunction of the specified restriction predicates.
Inherited from javax.persistence.criteria.AbstractQuery:
fromfromgetGroupListgetGroupRestrictiongetResultTypegetRootsisDistinct
Inherited from javax.persistence.criteria.Expression:
asininininisNotNullisNull

Method Detail

correlateback to summary
public <Y> Root<Y> correlate(Root<Y> parentRoot)

Create a subquery root correlated to a root of the enclosing query.

Parameters
parentRoot:Root<Y>

a root of the containing query

Returns:Root<Y>

subquery root

correlateback to summary
public <X, Y> Join<X, Y> correlate(Join<X, Y> parentJoin)

Create a subquery join object correlated to a join object of the enclosing query.

Parameters
parentJoin:Join<X, Y>

join object of the containing query

Returns:Join<X, Y>

subquery join

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

Parameters
parentCollection:CollectionJoin<X, Y>

join object of the containing query

Returns:CollectionJoin<X, Y>

subquery join

correlateback to summary
public <X, Y> SetJoin<X, Y> correlate(SetJoin<X, Y> parentSet)

Create a subquery set join object correlated to a set join object of the enclosing query.

Parameters
parentSet:SetJoin<X, Y>

join object of the containing query

Returns:SetJoin<X, Y>

subquery join

correlateback to summary
public <X, Y> ListJoin<X, Y> correlate(ListJoin<X, Y> parentList)

Create a subquery list join object correlated to a list join object of the enclosing query.

Parameters
parentList:ListJoin<X, Y>

join object of the containing query

Returns:ListJoin<X, Y>

subquery join

correlateback to summary
public <X, K, V> MapJoin<X, K, V> correlate(MapJoin<X, K, V> parentMap)

Create a subquery map join object correlated to a map join object of the enclosing query.

Parameters
parentMap:MapJoin<X, K, V>

join object of the containing query

Returns:MapJoin<X, K, V>

subquery join

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

Redeclares javax.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. This method only overrides the return type of the corresponding AbstractQuery method.

Parameters
distinct:boolean

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

Returns:Subquery<T>

the modified subquery.

getContainingQueryback to summary
public CommonAbstractCriteria getContainingQuery()

Return the query of which this is a subquery. This may be a CriteriaQuery, CriteriaUpdate, CriteriaDelete, or a Subquery.

Returns:CommonAbstractCriteria

the enclosing query or subquery

Since
Java Persistence 2.1
getCorrelatedJoinsback to summary
public Set<Join<?, ?>> getCorrelatedJoins()

Return the correlated joins of the subquery. Returns empty set if the subquery has no correlated joins. Modifications to the set do not affect the query.

Returns:Set<Join<?, ?>>

the correlated joins of the subquery

getParentback to summary
public AbstractQuery<?> getParent()

Return the query of which this is a subquery. This must be a CriteriaQuery or a Subquery.

Returns:AbstractQuery<?>

the enclosing query or subquery

getSelectionback to summary
public Expression<T> getSelection()

Redeclares javax.persistence.criteria.AbstractQuery.getSelection.

Return the selection expression.

Returns:Expression<T>

the item to be returned in the subquery result

groupByback to summary
public Subquery<T> groupBy(Expression<?>... grouping)

Redeclares javax.persistence.criteria.AbstractQuery.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 corresponding AbstractQuery method.

Parameters
grouping:Expression<?>[]

zero or more grouping expressions

Returns:Subquery<T>

the modified subquery

groupByback to summary
public Subquery<T> groupBy(List<Expression<?>> grouping)

Redeclares javax.persistence.criteria.AbstractQuery.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 corresponding AbstractQuery method.

Parameters
grouping:List<Expression<?>>

list of zero or more grouping expressions

Returns:Subquery<T>

the modified subquery

havingback to summary
public Subquery<T> having(Expression<Boolean> restriction)

Redeclares javax.persistence.criteria.AbstractQuery.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 corresponding AbstractQuery method.

Parameters
restriction:Expression<Boolean>

a simple or compound boolean expression

Returns:Subquery<T>

the modified subquery

havingback to summary
public Subquery<T> having(Predicate... restrictions)

Redeclares javax.persistence.criteria.AbstractQuery.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 corresponding AbstractQuery method.

Parameters
restrictions:Predicate[]

zero or more restriction predicates

Returns:Subquery<T>

the modified subquery

selectback to summary
public Subquery<T> select(Expression<T> expression)

Specify the item that is to be returned as the subquery result. Replaces the previously specified selection, if any.

Parameters
expression:Expression<T>

expression specifying the item that is to be returned as the subquery result

Returns:Subquery<T>

the modified subquery

whereback to summary
public Subquery<T> where(Expression<Boolean> restriction)

Redeclares javax.persistence.criteria.AbstractQuery.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 corresponding AbstractQuery method.

Parameters
restriction:Expression<Boolean>

a simple or compound boolean expression

Returns:Subquery<T>

the modified subquery

whereback to summary
public Subquery<T> where(Predicate... restrictions)

Redeclares javax.persistence.criteria.AbstractQuery.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 corresponding AbstractQuery method.

Parameters
restrictions:Predicate[]

zero or more restriction predicates

Returns:Subquery<T>

the modified subquery