FileDocCategorySizeDatePackage
SubqueryNode.javaAPI DocGlassfish v2 API5179Tue May 22 16:54:40 BST 2007oracle.toplink.essentials.internal.parsing

SubqueryNode

public class SubqueryNode extends Node
INTERNAL

Purpose: Represent a subquery.

Fields Summary
private EJBQLParseTree
subqueryParseTree
private Set
outerVars
Set of names of variables declared in an outer scope and used in teh subquery.
Constructors Summary
public SubqueryNode()
Return a new SubqueryNode.

        super();
    
Methods Summary
public oracle.toplink.essentials.expressions.ExpressiongenerateExpression(oracle.toplink.essentials.internal.parsing.GenerationContext context)
INTERNAL Generate the TopLink expression for this node

        Expression base = context.getBaseExpression();
        ReportQuery innerQuery = getReportQuery(context);
        return base.subQuery(innerQuery);
    
public oracle.toplink.essentials.internal.parsing.EJBQLParseTreegetParseTree()

        return subqueryParseTree;
    
public oracle.toplink.essentials.queryframework.ReportQuerygetReportQuery(oracle.toplink.essentials.internal.parsing.GenerationContext context)

        ReportQuery innerQuery = new ReportQuery();
        GenerationContext innerContext = 
            subqueryParseTree.populateSubquery(innerQuery, context);
        Expression joins = innerContext.joinVariables(outerVars);
        if (joins != null) {
            Expression where = innerQuery.getSelectionCriteria();
            where = appendExpression(where, joins);
            innerQuery.setSelectionCriteria(where);
        }
        return innerQuery;
    
public booleanisSubqueryNode()
INTERNAL Is this node a SubqueryNode

        return true;
    
public oracle.toplink.essentials.internal.parsing.NodequalifyAttributeAccess(oracle.toplink.essentials.internal.parsing.ParseTreeContext context)
INTERNAL If called the subquery is part of the WHERE clause of an UPDATE or DELETE statement that does not define an identification variable. The method checks the clauses of the subquery for unqualified fields accesses.

        subqueryParseTree.getFromNode().qualifyAttributeAccess(context);
        subqueryParseTree.getQueryNode().qualifyAttributeAccess(context);
        if (subqueryParseTree.getWhereNode() != null) {
            subqueryParseTree.getWhereNode().qualifyAttributeAccess(context);
        }
        if (subqueryParseTree.getGroupByNode() != null) {
            subqueryParseTree.getGroupByNode().qualifyAttributeAccess(context);
        }
        if (subqueryParseTree.getHavingNode() != null) {
            subqueryParseTree.getHavingNode().qualifyAttributeAccess(context);
        }
        return this;
    
public voidsetParseTree(oracle.toplink.essentials.internal.parsing.EJBQLParseTree parseTree)

        this.subqueryParseTree = parseTree;
    
public voidvalidate(oracle.toplink.essentials.internal.parsing.ParseTreeContext context)
INTERNAL Validate node and calculate its type.

        subqueryParseTree.validate(context);
        outerVars = context.getOuterScopeVariables();
        SelectNode selectNode = (SelectNode)subqueryParseTree.getQueryNode();
        // Get the select expression, subqueries only have one
        Node selectExpr = (Node)selectNode.getSelectExpressions().get(0);
        setType(selectExpr.getType());