Module org.eclipse.persistence.jpa
Class SubQueryImpl<T>
java.lang.Object
org.eclipse.persistence.internal.jpa.querydef.CommonAbstractCriteriaImpl<T>
org.eclipse.persistence.internal.jpa.querydef.AbstractQueryImpl<T>
org.eclipse.persistence.internal.jpa.querydef.SubQueryImpl<T>
- All Implemented Interfaces:
AbstractQuery<T>
,CommonAbstractCriteria
,Expression<T>
,Selection<T>
,Subquery<T>
,TupleElement<T>
,Serializable
,InternalExpression
,InternalSelection
public class SubQueryImpl<T>
extends AbstractQueryImpl<T>
implements Subquery<T>, InternalExpression, InternalSelection
Purpose: Contains the implementation of the SubQuery interface of the JPA criteria API.
Description: This is the container class for the components that define a query to be used in a sub select expression.
- Since:
- EclipseLink 2.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.persistence.internal.jpa.querydef.AbstractQueryImpl
AbstractQueryImpl.ResultType
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
protected Set
<Expression> protected SubSelectExpression
protected CommonAbstractCriteria
protected SelectionImpl
<?> protected ReportQuery
Fields inherited from class org.eclipse.persistence.internal.jpa.querydef.AbstractQueryImpl
baseExpression, distinct, groupBy, havingClause, queryResult, roots
Fields inherited from class org.eclipse.persistence.internal.jpa.querydef.CommonAbstractCriteriaImpl
metamodel, parameters, queryBuilder, queryType, where
-
Constructor Summary
ConstructorDescriptionSubQueryImpl
(Metamodel metamodel, Class<T> result, CriteriaBuilderImpl queryBuilder, CommonAbstractCriteria parent) -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
addParameter
(ParameterExpression<?> parameter) Assign an alias to the selection.<X> Expression
<X> <X,
Y> CollectionJoin <X, Y> correlate
(CollectionJoin<X, Y> parentCollection) Correlates a join to a Collection-valued association or element collection in the enclosing query to a join object of the subquery and returns the subquery join object.<X,
Y> Join <X, Y> Correlates a join object of the enclosing query to a join object of the subquery and returns the subquery join object.<X,
Y> ListJoin <X, Y> Correlates a join to a List-valued association or element collection in the enclosing query to a join object of the subquery and returns the subquery join object.<X,
K, V> MapJoin <X, K, V> Correlates a join to a Map-valued association or element collection in the enclosing query to a join object of the subquery and returns the subquery join object.<Y> Root
<Y> Correlates a root of the enclosing query to a root of the subquery and returns the subquery root.<X,
Y> SetJoin <X, Y> Correlates a join to a Set-valued association or element collection in the enclosing query to a join object of the subquery and returns the subquery join object.distinct
(boolean distinct) Specify whether duplicate query results will be eliminated.void
getAlias()
protected Expression
Return selection items composing a compound selectionReturn the joins that have been made from the subquery.Returns the current EclipseLink expression at this node in the criteria expression treeReturn the parameters of the queryReturn the query of which this is a subquery.Return the selection item of the query.groupBy
(Expression<?>... grouping) 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> restriction) 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.in
(Expression<?>... values) Apply a predicate to test whether the expression is a member of the argument list.in
(Expression<Collection<?>> values) Apply a predicate to test whether the expression is a member of the collection.in
(Collection<?> values) Apply a predicate to test whether the expression is a member of the collection.protected void
integrateRoot
(RootImpl root) Used to use a root from a different query.protected Expression
internalCorrelate
(FromImpl from) boolean
boolean
Whether the selection item is a compound selectionboolean
boolean
boolean
isFrom()
boolean
boolean
isNull()
boolean
boolean
boolean
isRoot()
boolean
select
(Expression<T> selection) Specify the item that is to be returned in the query result.where
(Expression<Boolean> restriction) Modify the query to restrict the query result according to the specified boolean expression.Modify the query to restrict the query result according to the conjunction of the specified restriction predicates.Methods inherited from class org.eclipse.persistence.internal.jpa.querydef.AbstractQueryImpl
findJoins, from, from, getBaseExpression, getGroupList, getGroupRestriction, getRoots, isDistinct
Methods inherited from class org.eclipse.persistence.internal.jpa.querydef.CommonAbstractCriteriaImpl
findRootAndParameters, findRootAndParameters, getRestriction, getResultType, internalFrom, internalFrom, subquery, translate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface jakarta.persistence.criteria.AbstractQuery
from, from, getGroupList, getGroupRestriction, getResultType, getRoots, isDistinct
Methods inherited from interface jakarta.persistence.criteria.CommonAbstractCriteria
getRestriction, subquery
-
Field Details
-
selection
-
currentNode
-
alias
-
subQuery
-
parent
-
processedJoins
-
correlations
-
-
Constructor Details
-
SubQueryImpl
public SubQueryImpl(Metamodel metamodel, Class<T> result, CriteriaBuilderImpl queryBuilder, CommonAbstractCriteria parent)
-
-
Method Details
-
select
Specify the item that is to be returned in the query result. Replaces the previously specified selection, if any. -
where
Modify the query to restrict the query 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.- Specified by:
where
in interfaceAbstractQuery<T>
- Specified by:
where
in interfaceSubquery<T>
- Overrides:
where
in classAbstractQueryImpl<T>
- Parameters:
restriction
- a simple or compound boolean expression- Returns:
- the modified query
-
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 corresponding AbstractQuery method.- Specified by:
where
in interfaceAbstractQuery<T>
- Specified by:
where
in interfaceSubquery<T>
- Overrides:
where
in classAbstractQueryImpl<T>
- Parameters:
restrictions
- zero or more restriction predicates- Returns:
- the modified query
-
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. This method only overrides the return type of the corresponding AbstractQuery method.- Specified by:
groupBy
in interfaceAbstractQuery<T>
- Specified by:
groupBy
in interfaceSubquery<T>
- Overrides:
groupBy
in classAbstractQueryImpl<T>
- Parameters:
grouping
- zero or more grouping expressions- Returns:
- the modified query
-
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. This method only overrides the return type of the corresponding AbstractQuery method.- Specified by:
groupBy
in interfaceAbstractQuery<T>
- Specified by:
groupBy
in interfaceSubquery<T>
- Overrides:
groupBy
in classAbstractQueryImpl<T>
- Parameters:
grouping
- zero or more grouping expressions- Returns:
- the modified query
-
having
Specify a restriction over the groups of the query. Replaces the previous having restriction(s), if any. This method only overrides the return type of the corresponding AbstractQuery method.- Specified by:
having
in interfaceAbstractQuery<T>
- Specified by:
having
in interfaceSubquery<T>
- Overrides:
having
in classAbstractQueryImpl<T>
- Parameters:
restriction
- a simple or compound boolean expression- Returns:
- the modified query
-
having
Specify restrictions over the groups of the query according 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.- Specified by:
having
in interfaceAbstractQuery<T>
- Specified by:
having
in interfaceSubquery<T>
- Overrides:
having
in classAbstractQueryImpl<T>
- Parameters:
restrictions
- zero or more restriction predicates- Returns:
- the modified query
-
correlate
Correlates a root of the enclosing query to a root of the subquery and returns the subquery root. -
correlate
Correlates a join object of the enclosing query to a join object of the subquery and returns the subquery join object. -
correlate
Correlates a join to a Collection-valued association or element collection in the enclosing query to a join object of the subquery and returns the subquery join object. -
correlate
Correlates a join to a Set-valued association or element collection in the enclosing query to a join object of the subquery and returns the subquery join object. -
correlate
Correlates a join to a List-valued association or element collection in the enclosing query to a join object of the subquery and returns the subquery join object. -
correlate
Correlates a join to a Map-valued association or element collection in the enclosing query to a join object of the subquery and returns the subquery join object. -
internalCorrelate
-
getParameters
Description copied from class:CommonAbstractCriteriaImpl
Return the parameters of the query- Overrides:
getParameters
in classCommonAbstractCriteriaImpl<T>
- Returns:
- the query parameters
-
getParent
Return the query of which this is a subquery. -
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.- Specified by:
distinct
in interfaceAbstractQuery<T>
- Specified by:
distinct
in interfaceSubquery<T>
- Overrides:
distinct
in classAbstractQueryImpl<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.
-
getCurrentNode
Returns the current EclipseLink expression at this node in the criteria expression tree- Specified by:
getCurrentNode
in interfaceInternalSelection
- Returns:
- the currentNode
-
getSelection
Return the selection item of the query. This will correspond to the query type.- Specified by:
getSelection
in interfaceAbstractQuery<T>
- Specified by:
getSelection
in interfaceSubquery<T>
- Returns:
- the selection item of the query
-
addParameter
- Overrides:
addParameter
in classCommonAbstractCriteriaImpl<T>
-
addJoin
- Specified by:
addJoin
in classAbstractQueryImpl<T>
-
as
- Specified by:
as
in interfaceExpression<T>
-
in
- Specified by:
in
in interfaceExpression<T>
-
in
Apply a predicate to test whether the expression is a member of the argument list.- Specified by:
in
in interfaceExpression<T>
- Returns:
- predicate testing for membership
-
in
Apply a predicate to test whether the expression is a member of the collection.- Specified by:
in
in interfaceExpression<T>
- Parameters:
values
- collection- Returns:
- predicate testing for membership
-
in
Apply a predicate to test whether the expression is a member of the collection.- Specified by:
in
in interfaceExpression<T>
- Parameters:
values
- expression corresponding to collection- Returns:
- predicate testing for membership
-
isNotNull
- Specified by:
isNotNull
in interfaceExpression<T>
-
isNull
- Specified by:
isNull
in interfaceExpression<T>
-
alias
Assign an alias to the selection. -
getAlias
- Specified by:
getAlias
in interfaceTupleElement<T>
-
getJavaType
- Specified by:
getJavaType
in interfaceTupleElement<T>
-
getCompoundSelectionItems
Return selection items composing a compound selection- Specified by:
getCompoundSelectionItems
in interfaceSelection<T>
- Returns:
- list of selection items
- Throws:
IllegalStateException
- if selection is not a compound selection
-
isCompoundSelection
public boolean isCompoundSelection()Whether the selection item is a compound selection- Specified by:
isCompoundSelection
in interfaceSelection<T>
- Returns:
- boolean
-
isConstructor
public boolean isConstructor()- Specified by:
isConstructor
in interfaceInternalSelection
-
isJunction
public boolean isJunction()- Specified by:
isJunction
in interfaceInternalExpression
-
isPredicate
public boolean isPredicate()- Specified by:
isPredicate
in interfaceInternalExpression
-
isParameter
public boolean isParameter()- Specified by:
isParameter
in interfaceInternalExpression
-
isRoot
public boolean isRoot()- Specified by:
isRoot
in interfaceInternalSelection
-
isSubquery
public boolean isSubquery()- Specified by:
isSubquery
in interfaceInternalExpression
-
integrateRoot
Description copied from class:CommonAbstractCriteriaImpl
Used to use a root from a different query.- Overrides:
integrateRoot
in classAbstractQueryImpl<T>
-
isCompoundExpression
public boolean isCompoundExpression()- Specified by:
isCompoundExpression
in interfaceInternalExpression
-
isExpression
public boolean isExpression()- Specified by:
isExpression
in interfaceInternalExpression
-
isFrom
public boolean isFrom()- Specified by:
isFrom
in interfaceInternalSelection
-
isLiteral
public boolean isLiteral()- Specified by:
isLiteral
in interfaceInternalExpression
-
findRootAndParameters
- Specified by:
findRootAndParameters
in interfaceInternalSelection
-
getBaseExpression
- Overrides:
getBaseExpression
in classAbstractQueryImpl<T>
-
getContainingQuery
- Specified by:
getContainingQuery
in interfaceSubquery<T>
-
getDatabaseQuery
- Specified by:
getDatabaseQuery
in classCommonAbstractCriteriaImpl<T>
-