Class 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
    • 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
      void addJoin​(FromImpl join)  
      void addParameter​(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.
      void findRootAndParameters​(CommonAbstractCriteriaImpl query)  
      java.lang.String getAlias()  
      protected org.eclipse.persistence.expressions.Expression getBaseExpression()  
      java.util.List<javax.persistence.criteria.Selection<?>> getCompoundSelectionItems()
      Return selection items composing a compound selection
      javax.persistence.criteria.CommonAbstractCriteria getContainingQuery()  
      java.util.Set<javax.persistence.criteria.Join<?,​?>> getCorrelatedJoins()
      Return the joins that have been made from the subquery.
      org.eclipse.persistence.expressions.Expression getCurrentNode()
      Returns the current EclipseLink expression at this node in the criteria expression tree
      org.eclipse.persistence.queries.DatabaseQuery getDatabaseQuery()  
      java.lang.Class<T> getJavaType()  
      java.util.Set<javax.persistence.criteria.ParameterExpression<?>> getParameters()
      Return the parameters of the query
      javax.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.Predicate in​(java.lang.Object... values)  
      javax.persistence.criteria.Predicate in​(java.util.Collection<?> values)
      Apply a predicate to test whether the expression is a member of the collection.
      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.
      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.
      protected void integrateRoot​(RootImpl root)
      Used to use a root from a different query.
      protected org.eclipse.persistence.expressions.Expression internalCorrelate​(FromImpl from)  
      boolean isCompoundExpression()  
      boolean isCompoundSelection()
      Whether the selection item is a compound selection
      boolean isConstructor()  
      boolean isExpression()  
      boolean isFrom()  
      boolean isJunction()  
      boolean isLiteral()  
      javax.persistence.criteria.Predicate isNotNull()  
      javax.persistence.criteria.Predicate isNull()  
      boolean isParameter()  
      boolean isPredicate()  
      boolean isRoot()  
      boolean isSubquery()  
      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 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface javax.persistence.criteria.AbstractQuery

        from, from, getGroupList, getGroupRestriction, getResultType, getRoots, isDistinct
      • Methods inherited from interface javax.persistence.criteria.CommonAbstractCriteria

        getRestriction, subquery
    • Field Detail

      • 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:
        select in interface javax.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:
        where in interface javax.persistence.criteria.AbstractQuery<T>
        Specified by:
        where in interface javax.persistence.criteria.Subquery<T>
        Overrides:
        where in class AbstractQueryImpl<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:
        where in interface javax.persistence.criteria.AbstractQuery<T>
        Specified by:
        where in interface javax.persistence.criteria.Subquery<T>
        Overrides:
        where in class AbstractQueryImpl<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:
        groupBy in interface javax.persistence.criteria.AbstractQuery<T>
        Specified by:
        groupBy in interface javax.persistence.criteria.Subquery<T>
        Overrides:
        groupBy in class AbstractQueryImpl<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:
        groupBy in interface javax.persistence.criteria.AbstractQuery<T>
        Specified by:
        groupBy in interface javax.persistence.criteria.Subquery<T>
        Overrides:
        groupBy in class AbstractQueryImpl<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:
        having in interface javax.persistence.criteria.AbstractQuery<T>
        Specified by:
        having in interface javax.persistence.criteria.Subquery<T>
        Overrides:
        having in class AbstractQueryImpl<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:
        having in interface javax.persistence.criteria.AbstractQuery<T>
        Specified by:
        having in interface javax.persistence.criteria.Subquery<T>
        Overrides:
        having in class AbstractQueryImpl<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:
        correlate in interface javax.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:
        correlate in interface javax.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:
        correlate in interface javax.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:
        correlate in interface javax.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:
        correlate in interface javax.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:
        correlate in interface javax.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)
      • getParent

        public javax.persistence.criteria.AbstractQuery<?> getParent()
        Return the query of which this is a subquery.
        Specified by:
        getParent in interface javax.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:
        distinct in interface javax.persistence.criteria.AbstractQuery<T>
        Specified by:
        distinct in interface javax.persistence.criteria.Subquery<T>
        Overrides:
        distinct in class AbstractQueryImpl<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:
        getCurrentNode in interface InternalSelection
        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.
        Specified by:
        getSelection in interface javax.persistence.criteria.AbstractQuery<T>
        Specified by:
        getSelection in interface javax.persistence.criteria.Subquery<T>
        Returns:
        the selection item of the query
      • getCorrelatedJoins

        public java.util.Set<javax.persistence.criteria.Join<?,​?>> getCorrelatedJoins()
        Return the joins that have been made from the subquery.
        Specified by:
        getCorrelatedJoins in interface javax.persistence.criteria.Subquery<T>
        Returns:
        joins made from this type
      • as

        public <X> javax.persistence.criteria.Expression<X> as​(java.lang.Class<X> type)
        Specified by:
        as in interface javax.persistence.criteria.Expression<T>
      • in

        public javax.persistence.criteria.Predicate in​(java.lang.Object... values)
        Specified by:
        in in interface javax.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:
        in in interface javax.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:
        in in interface javax.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:
        in in interface javax.persistence.criteria.Expression<T>
        Parameters:
        values - expression corresponding to collection
        Returns:
        predicate testing for membership
      • isNotNull

        public javax.persistence.criteria.Predicate isNotNull()
        Specified by:
        isNotNull in interface javax.persistence.criteria.Expression<T>
      • isNull

        public javax.persistence.criteria.Predicate isNull()
        Specified by:
        isNull in interface javax.persistence.criteria.Expression<T>
      • alias

        public javax.persistence.criteria.Selection<T> alias​(java.lang.String name)
        Assign an alias to the selection.
        Specified by:
        alias in interface javax.persistence.criteria.Selection<T>
        Parameters:
        name - alias
      • getAlias

        public java.lang.String getAlias()
        Specified by:
        getAlias in interface javax.persistence.TupleElement<T>
      • getJavaType

        public java.lang.Class<T> getJavaType()
        Specified by:
        getJavaType in interface javax.persistence.TupleElement<T>
      • getCompoundSelectionItems

        public java.util.List<javax.persistence.criteria.Selection<?>> getCompoundSelectionItems()
        Return selection items composing a compound selection
        Specified by:
        getCompoundSelectionItems in interface javax.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:
        isCompoundSelection in interface javax.persistence.criteria.Selection<T>
        Returns:
        boolean
      • getContainingQuery

        public javax.persistence.criteria.CommonAbstractCriteria getContainingQuery()
        Specified by:
        getContainingQuery in interface javax.persistence.criteria.Subquery<T>