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:
jakarta.persistence.criteria.AbstractQuery<T>,jakarta.persistence.criteria.CommonAbstractCriteria,jakarta.persistence.criteria.Expression<T>,jakarta.persistence.criteria.Selection<T>,jakarta.persistence.criteria.Subquery<T>,jakarta.persistence.TupleElement<T>,Serializable,InternalExpression,InternalSelection
public class SubQueryImpl<T> extends AbstractQueryImpl<T> implements jakarta.persistence.criteria.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
- Author:
- gyorke
- See Also:
CriteriaQuery,SubQuery, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.persistence.internal.jpa.querydef.AbstractQueryImpl
AbstractQueryImpl.ResultType
-
-
Field Summary
Fields Modifier and Type Field Description protected Stringaliasprotected Set<jakarta.persistence.criteria.Join<?,?>>correlatedJoinsprotected Set<Expression>correlationsprotected SubSelectExpressioncurrentNodeprotected jakarta.persistence.criteria.CommonAbstractCriteriaparentprotected Set<FromImpl>processedJoinsprotected SelectionImpl<?>selectionprotected ReportQuerysubQuery-
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
Constructors Constructor Description SubQueryImpl(jakarta.persistence.metamodel.Metamodel metamodel, Class result, CriteriaBuilderImpl queryBuilder, jakarta.persistence.criteria.CommonAbstractCriteria parent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddJoin(FromImpl join)voidaddParameter(jakarta.persistence.criteria.ParameterExpression<?> parameter)jakarta.persistence.criteria.Selection<T>alias(String name)Assign an alias to the selection.<X> jakarta.persistence.criteria.Expression<X>as(Class<X> type)<X,Y>
jakarta.persistence.criteria.CollectionJoin<X,Y>correlate(jakarta.persistence.criteria.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>
jakarta.persistence.criteria.Join<X,Y>correlate(jakarta.persistence.criteria.Join<X,Y> parentJoin)Correlates a join object of the enclosing query to a join object of the subquery and returns the subquery join object.<X,Y>
jakarta.persistence.criteria.ListJoin<X,Y>correlate(jakarta.persistence.criteria.ListJoin<X,Y> parentList)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>
jakarta.persistence.criteria.MapJoin<X,K,V>correlate(jakarta.persistence.criteria.MapJoin<X,K,V> parentMap)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> jakarta.persistence.criteria.Root<Y>correlate(jakarta.persistence.criteria.Root<Y> parentRoot)Correlates a root of the enclosing query to a root of the subquery and returns the subquery root.<X,Y>
jakarta.persistence.criteria.SetJoin<X,Y>correlate(jakarta.persistence.criteria.SetJoin<X,Y> parentSet)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.jakarta.persistence.criteria.Subquery<T>distinct(boolean distinct)Specify whether duplicate query results will be eliminated.voidfindRootAndParameters(CommonAbstractCriteriaImpl query)StringgetAlias()protected ExpressiongetBaseExpression()List<jakarta.persistence.criteria.Selection<?>>getCompoundSelectionItems()Return selection items composing a compound selectionjakarta.persistence.criteria.CommonAbstractCriteriagetContainingQuery()Set<jakarta.persistence.criteria.Join<?,?>>getCorrelatedJoins()Return the joins that have been made from the subquery.ExpressiongetCurrentNode()Returns the current EclipseLink expression at this node in the criteria expression treeDatabaseQuerygetDatabaseQuery()Class<T>getJavaType()Set<jakarta.persistence.criteria.ParameterExpression<?>>getParameters()Return the parameters of the queryjakarta.persistence.criteria.AbstractQuery<?>getParent()Return the query of which this is a subquery.jakarta.persistence.criteria.Expression<T>getSelection()Return the selection item of the query.jakarta.persistence.criteria.Subquery<T>groupBy(jakarta.persistence.criteria.Expression<?>... grouping)Specify the expressions that are used to form groups over the query results.jakarta.persistence.criteria.Subquery<T>groupBy(List<jakarta.persistence.criteria.Expression<?>> grouping)Specify the expressions that are used to form groups over the query results.jakarta.persistence.criteria.Subquery<T>having(jakarta.persistence.criteria.Expression<Boolean> restriction)Specify a restriction over the groups of the query.jakarta.persistence.criteria.Subquery<T>having(jakarta.persistence.criteria.Predicate... restrictions)Specify restrictions over the groups of the query according the conjunction of the specified restriction predicates.jakarta.persistence.criteria.Predicatein(jakarta.persistence.criteria.Expression<?>... values)Apply a predicate to test whether the expression is a member of the argument list.jakarta.persistence.criteria.Predicatein(jakarta.persistence.criteria.Expression<Collection<?>> values)Apply a predicate to test whether the expression is a member of the collection.jakarta.persistence.criteria.Predicatein(Object... values)jakarta.persistence.criteria.Predicatein(Collection<?> values)Apply a predicate to test whether the expression is a member of the collection.protected voidintegrateRoot(RootImpl root)Used to use a root from a different query.protected ExpressioninternalCorrelate(FromImpl from)booleanisCompoundExpression()booleanisCompoundSelection()Whether the selection item is a compound selectionbooleanisConstructor()booleanisExpression()booleanisFrom()booleanisJunction()booleanisLiteral()jakarta.persistence.criteria.PredicateisNotNull()jakarta.persistence.criteria.PredicateisNull()booleanisParameter()booleanisPredicate()booleanisRoot()booleanisSubquery()jakarta.persistence.criteria.Subquery<T>select(jakarta.persistence.criteria.Expression<T> selection)Specify the item that is to be returned in the query result.jakarta.persistence.criteria.Subquery<T>where(jakarta.persistence.criteria.Expression<Boolean> restriction)Modify the query to restrict the query result according to the specified boolean expression.jakarta.persistence.criteria.Subquery<T>where(jakarta.persistence.criteria.Predicate... restrictions)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
-
-
-
-
Field Detail
-
selection
protected SelectionImpl<?> selection
-
currentNode
protected SubSelectExpression currentNode
-
alias
protected String alias
-
subQuery
protected ReportQuery subQuery
-
correlatedJoins
protected Set<jakarta.persistence.criteria.Join<?,?>> correlatedJoins
-
parent
protected jakarta.persistence.criteria.CommonAbstractCriteria parent
-
correlations
protected Set<Expression> correlations
-
-
Constructor Detail
-
SubQueryImpl
public SubQueryImpl(jakarta.persistence.metamodel.Metamodel metamodel, Class result, CriteriaBuilderImpl queryBuilder, jakarta.persistence.criteria.CommonAbstractCriteria parent)
-
-
Method Detail
-
select
public jakarta.persistence.criteria.Subquery<T> select(jakarta.persistence.criteria.Expression<T> selection)
Specify the item that is to be returned in the query result. Replaces the previously specified selection, if any.- Specified by:
selectin interfacejakarta.persistence.criteria.Subquery<T>- Parameters:
selection- selection specifying the item that is to be returned in the query result- Returns:
- the modified query
-
where
public jakarta.persistence.criteria.Subquery<T> where(jakarta.persistence.criteria.Expression<Boolean> restriction)
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:
wherein interfacejakarta.persistence.criteria.AbstractQuery<T>- Specified by:
wherein interfacejakarta.persistence.criteria.Subquery<T>- Overrides:
wherein classAbstractQueryImpl<T>- Parameters:
restriction- a simple or compound boolean expression- Returns:
- the modified query
-
where
public jakarta.persistence.criteria.Subquery<T> where(jakarta.persistence.criteria.Predicate... restrictions)
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:
wherein interfacejakarta.persistence.criteria.AbstractQuery<T>- Specified by:
wherein interfacejakarta.persistence.criteria.Subquery<T>- Overrides:
wherein classAbstractQueryImpl<T>- Parameters:
restrictions- zero or more restriction predicates- Returns:
- the modified query
-
groupBy
public jakarta.persistence.criteria.Subquery<T> groupBy(jakarta.persistence.criteria.Expression<?>... grouping)
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:
groupByin interfacejakarta.persistence.criteria.AbstractQuery<T>- Specified by:
groupByin interfacejakarta.persistence.criteria.Subquery<T>- Overrides:
groupByin classAbstractQueryImpl<T>- Parameters:
grouping- zero or more grouping expressions- Returns:
- the modified query
-
groupBy
public jakarta.persistence.criteria.Subquery<T> groupBy(List<jakarta.persistence.criteria.Expression<?>> grouping)
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:
groupByin interfacejakarta.persistence.criteria.AbstractQuery<T>- Specified by:
groupByin interfacejakarta.persistence.criteria.Subquery<T>- Overrides:
groupByin classAbstractQueryImpl<T>- Parameters:
grouping- zero or more grouping expressions- Returns:
- the modified query
-
having
public jakarta.persistence.criteria.Subquery<T> having(jakarta.persistence.criteria.Expression<Boolean> restriction)
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:
havingin interfacejakarta.persistence.criteria.AbstractQuery<T>- Specified by:
havingin interfacejakarta.persistence.criteria.Subquery<T>- Overrides:
havingin classAbstractQueryImpl<T>- Parameters:
restriction- a simple or compound boolean expression- Returns:
- the modified query
-
having
public jakarta.persistence.criteria.Subquery<T> having(jakarta.persistence.criteria.Predicate... restrictions)
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:
havingin interfacejakarta.persistence.criteria.AbstractQuery<T>- Specified by:
havingin interfacejakarta.persistence.criteria.Subquery<T>- Overrides:
havingin classAbstractQueryImpl<T>- Parameters:
restrictions- zero or more restriction predicates- Returns:
- the modified query
-
correlate
public <Y> jakarta.persistence.criteria.Root<Y> correlate(jakarta.persistence.criteria.Root<Y> parentRoot)
Correlates a root of the enclosing query to a root of the subquery and returns the subquery root.- Specified by:
correlatein interfacejakarta.persistence.criteria.Subquery<T>- Parameters:
parentRoot- a root of the containing query- Returns:
- subquery root
-
correlate
public <X,Y> jakarta.persistence.criteria.Join<X,Y> correlate(jakarta.persistence.criteria.Join<X,Y> parentJoin)
Correlates a join object of the enclosing query to a join object of the subquery and returns the subquery join object.- Specified by:
correlatein interfacejakarta.persistence.criteria.Subquery<T>- Parameters:
parentJoin- join target of the containing query- Returns:
- subquery join
-
correlate
public <X,Y> jakarta.persistence.criteria.CollectionJoin<X,Y> correlate(jakarta.persistence.criteria.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.- Specified by:
correlatein interfacejakarta.persistence.criteria.Subquery<T>- Parameters:
parentCollection- join target of the containing query- Returns:
- subquery join
-
correlate
public <X,Y> jakarta.persistence.criteria.SetJoin<X,Y> correlate(jakarta.persistence.criteria.SetJoin<X,Y> parentSet)
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.- Specified by:
correlatein interfacejakarta.persistence.criteria.Subquery<T>- Parameters:
parentSet- join target of the containing query- Returns:
- subquery join
-
correlate
public <X,Y> jakarta.persistence.criteria.ListJoin<X,Y> correlate(jakarta.persistence.criteria.ListJoin<X,Y> parentList)
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.- Specified by:
correlatein interfacejakarta.persistence.criteria.Subquery<T>- Parameters:
parentList- join target of the containing query- Returns:
- subquery join
-
correlate
public <X,K,V> jakarta.persistence.criteria.MapJoin<X,K,V> correlate(jakarta.persistence.criteria.MapJoin<X,K,V> parentMap)
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.- Specified by:
correlatein interfacejakarta.persistence.criteria.Subquery<T>- Parameters:
parentMap- join target of the containing query- Returns:
- subquery join
-
internalCorrelate
protected Expression internalCorrelate(FromImpl from)
-
getParameters
public Set<jakarta.persistence.criteria.ParameterExpression<?>> getParameters()
Description copied from class:CommonAbstractCriteriaImplReturn the parameters of the query- Overrides:
getParametersin classCommonAbstractCriteriaImpl<T>- Returns:
- the query parameters
-
getParent
public jakarta.persistence.criteria.AbstractQuery<?> getParent()
Return the query of which this is a subquery.- Specified by:
getParentin interfacejakarta.persistence.criteria.Subquery<T>- Returns:
- the enclosing query or subquery
-
distinct
public jakarta.persistence.criteria.Subquery<T> distinct(boolean 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:
distinctin interfacejakarta.persistence.criteria.AbstractQuery<T>- Specified by:
distinctin interfacejakarta.persistence.criteria.Subquery<T>- Overrides:
distinctin 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
public Expression getCurrentNode()
Returns the current EclipseLink expression at this node in the criteria expression tree- Specified by:
getCurrentNodein interfaceInternalSelection- Returns:
- the currentNode
-
getSelection
public jakarta.persistence.criteria.Expression<T> getSelection()
Return the selection item of the query. This will correspond to the query type.
-
getCorrelatedJoins
public Set<jakarta.persistence.criteria.Join<?,?>> getCorrelatedJoins()
Return the joins that have been made from the subquery.- Specified by:
getCorrelatedJoinsin interfacejakarta.persistence.criteria.Subquery<T>- Returns:
- joins made from this type
-
addParameter
public void addParameter(jakarta.persistence.criteria.ParameterExpression<?> parameter)
- Overrides:
addParameterin classCommonAbstractCriteriaImpl<T>
-
addJoin
public void addJoin(FromImpl join)
- Specified by:
addJoinin classAbstractQueryImpl<T>
-
as
public <X> jakarta.persistence.criteria.Expression<X> as(Class<X> type)
- Specified by:
asin interfacejakarta.persistence.criteria.Expression<T>
-
in
public jakarta.persistence.criteria.Predicate in(Object... values)
- Specified by:
inin interfacejakarta.persistence.criteria.Expression<T>
-
in
public jakarta.persistence.criteria.Predicate in(jakarta.persistence.criteria.Expression<?>... values)
Apply a predicate to test whether the expression is a member of the argument list.- Specified by:
inin interfacejakarta.persistence.criteria.Expression<T>- Parameters:
values-- Returns:
- predicate testing for membership
-
in
public jakarta.persistence.criteria.Predicate in(Collection<?> values)
Apply a predicate to test whether the expression is a member of the collection.- Specified by:
inin interfacejakarta.persistence.criteria.Expression<T>- Parameters:
values- collection- Returns:
- predicate testing for membership
-
in
public jakarta.persistence.criteria.Predicate in(jakarta.persistence.criteria.Expression<Collection<?>> values)
Apply a predicate to test whether the expression is a member of the collection.- Specified by:
inin interfacejakarta.persistence.criteria.Expression<T>- Parameters:
values- expression corresponding to collection- Returns:
- predicate testing for membership
-
isNotNull
public jakarta.persistence.criteria.Predicate isNotNull()
- Specified by:
isNotNullin interfacejakarta.persistence.criteria.Expression<T>
-
isNull
public jakarta.persistence.criteria.Predicate isNull()
- Specified by:
isNullin interfacejakarta.persistence.criteria.Expression<T>
-
alias
public jakarta.persistence.criteria.Selection<T> alias(String name)
Assign an alias to the selection.- Specified by:
aliasin interfacejakarta.persistence.criteria.Selection<T>- Parameters:
name- alias
-
getAlias
public String getAlias()
- Specified by:
getAliasin interfacejakarta.persistence.TupleElement<T>
-
getJavaType
public Class<T> getJavaType()
- Specified by:
getJavaTypein interfacejakarta.persistence.TupleElement<T>
-
getCompoundSelectionItems
public List<jakarta.persistence.criteria.Selection<?>> getCompoundSelectionItems()
Return selection items composing a compound selection- Specified by:
getCompoundSelectionItemsin interfacejakarta.persistence.criteria.Selection<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:
isCompoundSelectionin interfacejakarta.persistence.criteria.Selection<T>- Returns:
- boolean
-
isConstructor
public boolean isConstructor()
- Specified by:
isConstructorin interfaceInternalSelection
-
isJunction
public boolean isJunction()
- Specified by:
isJunctionin interfaceInternalExpression
-
isPredicate
public boolean isPredicate()
- Specified by:
isPredicatein interfaceInternalExpression
-
isParameter
public boolean isParameter()
- Specified by:
isParameterin interfaceInternalExpression
-
isRoot
public boolean isRoot()
- Specified by:
isRootin interfaceInternalSelection
-
isSubquery
public boolean isSubquery()
- Specified by:
isSubqueryin interfaceInternalExpression
-
integrateRoot
protected void integrateRoot(RootImpl root)
Description copied from class:CommonAbstractCriteriaImplUsed to use a root from a different query.- Overrides:
integrateRootin classAbstractQueryImpl<T>
-
isCompoundExpression
public boolean isCompoundExpression()
- Specified by:
isCompoundExpressionin interfaceInternalExpression
-
isExpression
public boolean isExpression()
- Specified by:
isExpressionin interfaceInternalExpression
-
isFrom
public boolean isFrom()
- Specified by:
isFromin interfaceInternalSelection
-
isLiteral
public boolean isLiteral()
- Specified by:
isLiteralin interfaceInternalExpression
-
findRootAndParameters
public void findRootAndParameters(CommonAbstractCriteriaImpl query)
- Specified by:
findRootAndParametersin interfaceInternalSelection
-
getBaseExpression
protected Expression getBaseExpression()
- Overrides:
getBaseExpressionin classAbstractQueryImpl<T>
-
getContainingQuery
public jakarta.persistence.criteria.CommonAbstractCriteria getContainingQuery()
- Specified by:
getContainingQueryin interfacejakarta.persistence.criteria.Subquery<T>
-
getDatabaseQuery
public DatabaseQuery getDatabaseQuery()
- Specified by:
getDatabaseQueryin classCommonAbstractCriteriaImpl<T>
-
-