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:
  • Field Details

  • Constructor Details

  • Method Details

    • select

      public Subquery<T> select(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 Subquery<T>
      Parameters:
      selection - selection specifying the item that is to be returned in the query result
      Returns:
      the modified query
    • where

      public Subquery<T> where(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:
      where in interface AbstractQuery<T>
      Specified by:
      where in interface Subquery<T>
      Overrides:
      where in class AbstractQueryImpl<T>
      Parameters:
      restriction - a simple or compound boolean expression
      Returns:
      the modified query
    • where

      public Subquery<T> where(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 AbstractQuery<T>
      Specified by:
      where in interface Subquery<T>
      Overrides:
      where in class AbstractQueryImpl<T>
      Parameters:
      restrictions - zero or more restriction predicates
      Returns:
      the modified query
    • groupBy

      public Subquery<T> groupBy(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 AbstractQuery<T>
      Specified by:
      groupBy in interface Subquery<T>
      Overrides:
      groupBy in class AbstractQueryImpl<T>
      Parameters:
      grouping - zero or more grouping expressions
      Returns:
      the modified query
    • groupBy

      public Subquery<T> groupBy(List<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 AbstractQuery<T>
      Specified by:
      groupBy in interface Subquery<T>
      Overrides:
      groupBy in class AbstractQueryImpl<T>
      Parameters:
      grouping - zero or more grouping expressions
      Returns:
      the modified query
    • having

      public Subquery<T> having(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:
      having in interface AbstractQuery<T>
      Specified by:
      having in interface Subquery<T>
      Overrides:
      having in class AbstractQueryImpl<T>
      Parameters:
      restriction - a simple or compound boolean expression
      Returns:
      the modified query
    • having

      public Subquery<T> having(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 AbstractQuery<T>
      Specified by:
      having in interface Subquery<T>
      Overrides:
      having in class AbstractQueryImpl<T>
      Parameters:
      restrictions - zero or more restriction predicates
      Returns:
      the modified query
    • correlate

      public <Y> Root<Y> correlate(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 Subquery<T>
      Parameters:
      parentRoot - a root of the containing query
      Returns:
      subquery root
    • correlate

      public <X, Y> Join<X,Y> correlate(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 Subquery<T>
      Parameters:
      parentJoin - join target of the containing query
      Returns:
      subquery join
    • correlate

      public <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.
      Specified by:
      correlate in interface Subquery<T>
      Parameters:
      parentCollection - join target of the containing query
      Returns:
      subquery join
    • correlate

      public <X, Y> SetJoin<X,Y> correlate(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 Subquery<T>
      Parameters:
      parentSet - join target of the containing query
      Returns:
      subquery join
    • correlate

      public <X, Y> ListJoin<X,Y> correlate(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 Subquery<T>
      Parameters:
      parentList - join target of the containing query
      Returns:
      subquery join
    • correlate

      public <X, K, V> MapJoin<X,K,V> correlate(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 Subquery<T>
      Parameters:
      parentMap - join target of the containing query
      Returns:
      subquery join
    • internalCorrelate

      protected Expression internalCorrelate(FromImpl from)
    • getParameters

      public Set<ParameterExpression<?>> getParameters()
      Description copied from class: CommonAbstractCriteriaImpl
      Return the parameters of the query
      Overrides:
      getParameters in class CommonAbstractCriteriaImpl<T>
      Returns:
      the query parameters
    • getParent

      public AbstractQuery<?> getParent()
      Return the query of which this is a subquery.
      Specified by:
      getParent in interface Subquery<T>
      Returns:
      the enclosing query or subquery
    • distinct

      public 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 AbstractQuery<T>
      Specified by:
      distinct in interface 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 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 Expression<T> getSelection()
      Return the selection item of the query. This will correspond to the query type.
      Specified by:
      getSelection in interface AbstractQuery<T>
      Specified by:
      getSelection in interface Subquery<T>
      Returns:
      the selection item of the query
    • getCorrelatedJoins

      public Set<Join<?,?>> getCorrelatedJoins()
      Return the joins that have been made from the subquery.
      Specified by:
      getCorrelatedJoins in interface Subquery<T>
      Returns:
      joins made from this type
    • addParameter

      public void addParameter(ParameterExpression<?> parameter)
      Overrides:
      addParameter in class CommonAbstractCriteriaImpl<T>
    • addJoin

      public void addJoin(FromImpl join)
      Specified by:
      addJoin in class AbstractQueryImpl<T>
    • as

      public <X> Expression<X> as(Class<X> type)
      Specified by:
      as in interface Expression<T>
    • in

      public Predicate in(Object... values)
      Specified by:
      in in interface Expression<T>
    • in

      public Predicate in(Expression<?>... values)
      Apply a predicate to test whether the expression is a member of the argument list.
      Specified by:
      in in interface Expression<T>
      Returns:
      predicate testing for membership
    • in

      public Predicate in(Collection<?> values)
      Apply a predicate to test whether the expression is a member of the collection.
      Specified by:
      in in interface Expression<T>
      Parameters:
      values - collection
      Returns:
      predicate testing for membership
    • in

      public Predicate in(Expression<Collection<?>> values)
      Apply a predicate to test whether the expression is a member of the collection.
      Specified by:
      in in interface Expression<T>
      Parameters:
      values - expression corresponding to collection
      Returns:
      predicate testing for membership
    • isNotNull

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

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

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

      public String getAlias()
      Specified by:
      getAlias in interface TupleElement<T>
    • getJavaType

      public Class<T> getJavaType()
      Specified by:
      getJavaType in interface TupleElement<T>
    • getCompoundSelectionItems

      public List<Selection<?>> getCompoundSelectionItems()
      Return selection items composing a compound selection
      Specified by:
      getCompoundSelectionItems in interface 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:
      isCompoundSelection in interface Selection<T>
      Returns:
      boolean
    • isConstructor

      public boolean isConstructor()
      Specified by:
      isConstructor in interface InternalSelection
    • isJunction

      public boolean isJunction()
      Specified by:
      isJunction in interface InternalExpression
    • isPredicate

      public boolean isPredicate()
      Specified by:
      isPredicate in interface InternalExpression
    • isParameter

      public boolean isParameter()
      Specified by:
      isParameter in interface InternalExpression
    • isRoot

      public boolean isRoot()
      Specified by:
      isRoot in interface InternalSelection
    • isSubquery

      public boolean isSubquery()
      Specified by:
      isSubquery in interface InternalExpression
    • integrateRoot

      protected void integrateRoot(RootImpl root)
      Description copied from class: CommonAbstractCriteriaImpl
      Used to use a root from a different query.
      Overrides:
      integrateRoot in class AbstractQueryImpl<T>
    • isCompoundExpression

      public boolean isCompoundExpression()
      Specified by:
      isCompoundExpression in interface InternalExpression
    • isExpression

      public boolean isExpression()
      Specified by:
      isExpression in interface InternalExpression
    • isFrom

      public boolean isFrom()
      Specified by:
      isFrom in interface InternalSelection
    • isLiteral

      public boolean isLiteral()
      Specified by:
      isLiteral in interface InternalExpression
    • findRootAndParameters

      public void findRootAndParameters(CommonAbstractCriteriaImpl query)
      Specified by:
      findRootAndParameters in interface InternalSelection
    • getBaseExpression

      protected Expression getBaseExpression()
      Overrides:
      getBaseExpression in class AbstractQueryImpl<T>
    • getContainingQuery

      public CommonAbstractCriteria getContainingQuery()
      Specified by:
      getContainingQuery in interface Subquery<T>
    • getDatabaseQuery

      public DatabaseQuery getDatabaseQuery()
      Specified by:
      getDatabaseQuery in class CommonAbstractCriteriaImpl<T>