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:
java.io.Serializable,javax.persistence.criteria.AbstractQuery<T>,javax.persistence.criteria.CommonAbstractCriteria,javax.persistence.criteria.Expression<T>,javax.persistence.criteria.Selection<T>,javax.persistence.criteria.Subquery<T>,javax.persistence.TupleElement<T>,InternalExpression,InternalSelection
public class SubQueryImpl<T> extends AbstractQueryImpl<T> implements javax.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 java.lang.Stringaliasprotected java.util.Set<javax.persistence.criteria.Join<?,?>>correlatedJoinsprotected java.util.Set<org.eclipse.persistence.expressions.Expression>correlationsprotected org.eclipse.persistence.internal.expressions.SubSelectExpressioncurrentNodeprotected javax.persistence.criteria.CommonAbstractCriteriaparentprotected java.util.Set<FromImpl>processedJoinsprotected SelectionImpl<?>selectionprotected org.eclipse.persistence.queries.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(javax.persistence.metamodel.Metamodel metamodel, java.lang.Class result, CriteriaBuilderImpl queryBuilder, javax.persistence.criteria.CommonAbstractCriteria parent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddJoin(FromImpl join)voidaddParameter(javax.persistence.criteria.ParameterExpression<?> parameter)javax.persistence.criteria.Selection<T>alias(java.lang.String name)Assign an alias to the selection.<X> javax.persistence.criteria.Expression<X>as(java.lang.Class<X> type)<X,Y>
javax.persistence.criteria.CollectionJoin<X,Y>correlate(javax.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>
javax.persistence.criteria.Join<X,Y>correlate(javax.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>
javax.persistence.criteria.ListJoin<X,Y>correlate(javax.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>
javax.persistence.criteria.MapJoin<X,K,V>correlate(javax.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> javax.persistence.criteria.Root<Y>correlate(javax.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>
javax.persistence.criteria.SetJoin<X,Y>correlate(javax.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.javax.persistence.criteria.Subquery<T>distinct(boolean distinct)Specify whether duplicate query results will be eliminated.voidfindRootAndParameters(CommonAbstractCriteriaImpl query)java.lang.StringgetAlias()protected org.eclipse.persistence.expressions.ExpressiongetBaseExpression()java.util.List<javax.persistence.criteria.Selection<?>>getCompoundSelectionItems()Return selection items composing a compound selectionjavax.persistence.criteria.CommonAbstractCriteriagetContainingQuery()java.util.Set<javax.persistence.criteria.Join<?,?>>getCorrelatedJoins()Return the joins that have been made from the subquery.org.eclipse.persistence.expressions.ExpressiongetCurrentNode()Returns the current EclipseLink expression at this node in the criteria expression treeorg.eclipse.persistence.queries.DatabaseQuerygetDatabaseQuery()java.lang.Class<T>getJavaType()java.util.Set<javax.persistence.criteria.ParameterExpression<?>>getParameters()Return the parameters of the queryjavax.persistence.criteria.AbstractQuery<?>getParent()Return the query of which this is a subquery.javax.persistence.criteria.Expression<T>getSelection()Return the selection item of the query.javax.persistence.criteria.Subquery<T>groupBy(java.util.List<javax.persistence.criteria.Expression<?>> grouping)Specify the expressions that are used to form groups over the query results.javax.persistence.criteria.Subquery<T>groupBy(javax.persistence.criteria.Expression<?>... grouping)Specify the expressions that are used to form groups over the query results.javax.persistence.criteria.Subquery<T>having(javax.persistence.criteria.Expression<java.lang.Boolean> restriction)Specify a restriction over the groups of the query.javax.persistence.criteria.Subquery<T>having(javax.persistence.criteria.Predicate... restrictions)Specify restrictions over the groups of the query according the conjunction of the specified restriction predicates.javax.persistence.criteria.Predicatein(java.lang.Object... values)javax.persistence.criteria.Predicatein(java.util.Collection<?> values)Apply a predicate to test whether the expression is a member of the collection.javax.persistence.criteria.Predicatein(javax.persistence.criteria.Expression<?>... values)Apply a predicate to test whether the expression is a member of the argument list.javax.persistence.criteria.Predicatein(javax.persistence.criteria.Expression<java.util.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 org.eclipse.persistence.expressions.ExpressioninternalCorrelate(FromImpl from)booleanisCompoundExpression()booleanisCompoundSelection()Whether the selection item is a compound selectionbooleanisConstructor()booleanisExpression()booleanisFrom()booleanisJunction()booleanisLiteral()javax.persistence.criteria.PredicateisNotNull()javax.persistence.criteria.PredicateisNull()booleanisParameter()booleanisPredicate()booleanisRoot()booleanisSubquery()javax.persistence.criteria.Subquery<T>select(javax.persistence.criteria.Expression<T> selection)Specify the item that is to be returned in the query result.javax.persistence.criteria.Subquery<T>where(javax.persistence.criteria.Expression<java.lang.Boolean> restriction)Modify the query to restrict the query result according to the specified boolean expression.javax.persistence.criteria.Subquery<T>where(javax.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 org.eclipse.persistence.internal.expressions.SubSelectExpression currentNode
-
alias
protected java.lang.String alias
-
subQuery
protected org.eclipse.persistence.queries.ReportQuery subQuery
-
correlatedJoins
protected java.util.Set<javax.persistence.criteria.Join<?,?>> correlatedJoins
-
parent
protected javax.persistence.criteria.CommonAbstractCriteria parent
-
processedJoins
protected java.util.Set<FromImpl> processedJoins
-
correlations
protected java.util.Set<org.eclipse.persistence.expressions.Expression> correlations
-
-
Constructor Detail
-
SubQueryImpl
public SubQueryImpl(javax.persistence.metamodel.Metamodel metamodel, java.lang.Class result, CriteriaBuilderImpl queryBuilder, javax.persistence.criteria.CommonAbstractCriteria parent)
-
-
Method Detail
-
select
public javax.persistence.criteria.Subquery<T> select(javax.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 interfacejavax.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 javax.persistence.criteria.Subquery<T> where(javax.persistence.criteria.Expression<java.lang.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 interfacejavax.persistence.criteria.AbstractQuery<T>- Specified by:
wherein interfacejavax.persistence.criteria.Subquery<T>- Overrides:
wherein classAbstractQueryImpl<T>- Parameters:
restriction- a simple or compound boolean expression- Returns:
- the modified query
-
where
public javax.persistence.criteria.Subquery<T> where(javax.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 interfacejavax.persistence.criteria.AbstractQuery<T>- Specified by:
wherein interfacejavax.persistence.criteria.Subquery<T>- Overrides:
wherein classAbstractQueryImpl<T>- Parameters:
restrictions- zero or more restriction predicates- Returns:
- the modified query
-
groupBy
public javax.persistence.criteria.Subquery<T> groupBy(javax.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 interfacejavax.persistence.criteria.AbstractQuery<T>- Specified by:
groupByin interfacejavax.persistence.criteria.Subquery<T>- Overrides:
groupByin classAbstractQueryImpl<T>- Parameters:
grouping- zero or more grouping expressions- Returns:
- the modified query
-
groupBy
public javax.persistence.criteria.Subquery<T> groupBy(java.util.List<javax.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 interfacejavax.persistence.criteria.AbstractQuery<T>- Specified by:
groupByin interfacejavax.persistence.criteria.Subquery<T>- Overrides:
groupByin classAbstractQueryImpl<T>- Parameters:
grouping- zero or more grouping expressions- Returns:
- the modified query
-
having
public javax.persistence.criteria.Subquery<T> having(javax.persistence.criteria.Expression<java.lang.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 interfacejavax.persistence.criteria.AbstractQuery<T>- Specified by:
havingin interfacejavax.persistence.criteria.Subquery<T>- Overrides:
havingin classAbstractQueryImpl<T>- Parameters:
restriction- a simple or compound boolean expression- Returns:
- the modified query
-
having
public javax.persistence.criteria.Subquery<T> having(javax.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 interfacejavax.persistence.criteria.AbstractQuery<T>- Specified by:
havingin interfacejavax.persistence.criteria.Subquery<T>- Overrides:
havingin classAbstractQueryImpl<T>- Parameters:
restrictions- zero or more restriction predicates- Returns:
- the modified query
-
correlate
public <Y> javax.persistence.criteria.Root<Y> correlate(javax.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 interfacejavax.persistence.criteria.Subquery<T>- Parameters:
parentRoot- a root of the containing query- Returns:
- subquery root
-
correlate
public <X,Y> javax.persistence.criteria.Join<X,Y> correlate(javax.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 interfacejavax.persistence.criteria.Subquery<T>- Parameters:
parentJoin- join target of the containing query- Returns:
- subquery join
-
correlate
public <X,Y> javax.persistence.criteria.CollectionJoin<X,Y> correlate(javax.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 interfacejavax.persistence.criteria.Subquery<T>- Parameters:
parentCollection- join target of the containing query- Returns:
- subquery join
-
correlate
public <X,Y> javax.persistence.criteria.SetJoin<X,Y> correlate(javax.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 interfacejavax.persistence.criteria.Subquery<T>- Parameters:
parentSet- join target of the containing query- Returns:
- subquery join
-
correlate
public <X,Y> javax.persistence.criteria.ListJoin<X,Y> correlate(javax.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 interfacejavax.persistence.criteria.Subquery<T>- Parameters:
parentList- join target of the containing query- Returns:
- subquery join
-
correlate
public <X,K,V> javax.persistence.criteria.MapJoin<X,K,V> correlate(javax.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 interfacejavax.persistence.criteria.Subquery<T>- Parameters:
parentMap- join target of the containing query- Returns:
- subquery join
-
internalCorrelate
protected org.eclipse.persistence.expressions.Expression internalCorrelate(FromImpl from)
-
getParameters
public java.util.Set<javax.persistence.criteria.ParameterExpression<?>> getParameters()
Description copied from class:CommonAbstractCriteriaImplReturn the parameters of the query- Overrides:
getParametersin classCommonAbstractCriteriaImpl<T>- Returns:
- the query parameters
-
getParent
public javax.persistence.criteria.AbstractQuery<?> getParent()
Return the query of which this is a subquery.- Specified by:
getParentin interfacejavax.persistence.criteria.Subquery<T>- Returns:
- the enclosing query or subquery
-
distinct
public javax.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 interfacejavax.persistence.criteria.AbstractQuery<T>- Specified by:
distinctin interfacejavax.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 org.eclipse.persistence.expressions.Expression getCurrentNode()
Returns the current EclipseLink expression at this node in the criteria expression tree- Specified by:
getCurrentNodein interfaceInternalSelection- Returns:
- the currentNode
-
getSelection
public javax.persistence.criteria.Expression<T> getSelection()
Return the selection item of the query. This will correspond to the query type.
-
getCorrelatedJoins
public java.util.Set<javax.persistence.criteria.Join<?,?>> getCorrelatedJoins()
Return the joins that have been made from the subquery.- Specified by:
getCorrelatedJoinsin interfacejavax.persistence.criteria.Subquery<T>- Returns:
- joins made from this type
-
addParameter
public void addParameter(javax.persistence.criteria.ParameterExpression<?> parameter)
- Overrides:
addParameterin classCommonAbstractCriteriaImpl<T>
-
addJoin
public void addJoin(FromImpl join)
- Specified by:
addJoinin classAbstractQueryImpl<T>
-
as
public <X> javax.persistence.criteria.Expression<X> as(java.lang.Class<X> type)
- Specified by:
asin interfacejavax.persistence.criteria.Expression<T>
-
in
public javax.persistence.criteria.Predicate in(java.lang.Object... values)
- Specified by:
inin interfacejavax.persistence.criteria.Expression<T>
-
in
public javax.persistence.criteria.Predicate in(javax.persistence.criteria.Expression<?>... values)
Apply a predicate to test whether the expression is a member of the argument list.- Specified by:
inin interfacejavax.persistence.criteria.Expression<T>- Parameters:
values-- Returns:
- predicate testing for membership
-
in
public javax.persistence.criteria.Predicate in(java.util.Collection<?> values)
Apply a predicate to test whether the expression is a member of the collection.- Specified by:
inin interfacejavax.persistence.criteria.Expression<T>- Parameters:
values- collection- Returns:
- predicate testing for membership
-
in
public javax.persistence.criteria.Predicate in(javax.persistence.criteria.Expression<java.util.Collection<?>> values)
Apply a predicate to test whether the expression is a member of the collection.- Specified by:
inin interfacejavax.persistence.criteria.Expression<T>- Parameters:
values- expression corresponding to collection- Returns:
- predicate testing for membership
-
isNotNull
public javax.persistence.criteria.Predicate isNotNull()
- Specified by:
isNotNullin interfacejavax.persistence.criteria.Expression<T>
-
isNull
public javax.persistence.criteria.Predicate isNull()
- Specified by:
isNullin interfacejavax.persistence.criteria.Expression<T>
-
alias
public javax.persistence.criteria.Selection<T> alias(java.lang.String name)
Assign an alias to the selection.- Specified by:
aliasin interfacejavax.persistence.criteria.Selection<T>- Parameters:
name- alias
-
getAlias
public java.lang.String getAlias()
- Specified by:
getAliasin interfacejavax.persistence.TupleElement<T>
-
getJavaType
public java.lang.Class<T> getJavaType()
- Specified by:
getJavaTypein interfacejavax.persistence.TupleElement<T>
-
getCompoundSelectionItems
public java.util.List<javax.persistence.criteria.Selection<?>> getCompoundSelectionItems()
Return selection items composing a compound selection- Specified by:
getCompoundSelectionItemsin interfacejavax.persistence.criteria.Selection<T>- Returns:
- list of selection items
- Throws:
java.lang.IllegalStateException- if selection is not a compound selection
-
isCompoundSelection
public boolean isCompoundSelection()
Whether the selection item is a compound selection- Specified by:
isCompoundSelectionin interfacejavax.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 org.eclipse.persistence.expressions.Expression getBaseExpression()
- Overrides:
getBaseExpressionin classAbstractQueryImpl<T>
-
getContainingQuery
public javax.persistence.criteria.CommonAbstractCriteria getContainingQuery()
- Specified by:
getContainingQueryin interfacejavax.persistence.criteria.Subquery<T>
-
getDatabaseQuery
public org.eclipse.persistence.queries.DatabaseQuery getDatabaseQuery()
- Specified by:
getDatabaseQueryin classCommonAbstractCriteriaImpl<T>
-
-