FileDocCategorySizeDatePackage
SelectGenerationContext.javaAPI DocGlassfish v2 API7314Tue May 22 16:54:38 BST 2007oracle.toplink.essentials.internal.parsing

SelectGenerationContext

public class SelectGenerationContext extends GenerationContext
INTERNAL: An extension of GenerationContext the provides SELECT specfic behavior. Used when building the query features that are not usable in other types of queries

Fields Summary
private boolean
useParallelExpressions
private boolean
shouldCheckSelectNodeBeforeResolving
private boolean
isNotIndicatedInMemberOf
private MemberOfNode
memberOfNode
private boolean
shouldUseOuterJoins
private GenerationContext
outer
Constructors Summary
public SelectGenerationContext()


      
        super();
    
public SelectGenerationContext(GenerationContext outer, ParseTree newParseTree)
Constructor used to create the context for a subquery.

        this(outer.getParseTreeContext(), outer.getSession(), newParseTree);
        this.outer = outer;
    
public SelectGenerationContext(ParseTreeContext newContext, AbstractSession newSession, ParseTree newParseTree)

        super(newContext, newSession, newParseTree);

        //indicate if we want parallel expressions or not
        useParallelExpressions = this.computeUseParallelExpressions();
    
Methods Summary
public voidcheckSelectNodeBeforeResolving(boolean shouldCheck)

        shouldCheckSelectNodeBeforeResolving = shouldCheck;
    
private booleancomputeUseParallelExpressions()

        boolean computedUseParallelExpressions;

        //use parallel expressions if I have a 1:1 selected, and the same class isn't
        //declared in the FROM
        computedUseParallelExpressions = ((SelectNode)this.parseTree.getQueryNode()).hasOneToOneSelected(this);
        //check if they've SELECTed a variable declared in the IN clause in the FROM,
        //or they've mapped more than one variable to the same type in the FROM
        computedUseParallelExpressions = computedUseParallelExpressions || ((SelectNode)this.parseTree.getQueryNode()).isVariableInINClauseSelected(this) || this.parseTree.getContext().hasMoreThanOneVariablePerType() || this.parseTree.getContext().hasMoreThanOneAliasInFrom();
        return computedUseParallelExpressions;
    
public voiddontUseOuterJoins()

        shouldUseOuterJoins = false;
    
public oracle.toplink.essentials.internal.parsing.MemberOfNodegetMemberOfNode()

        return memberOfNode;
    
public oracle.toplink.essentials.internal.parsing.GenerationContextgetOuterContext()

        return outer;
    
public booleanhasMemberOfNode()

        return memberOfNode != null;
    
public oracle.toplink.essentials.expressions.ExpressionjoinVariables(java.util.Set variables)
Iterate the set of variables declared in an outer scope and connect the inner varaible expression with the outer one.

        if ((outer == null) || (variables == null) || variables.isEmpty()) {
            // not an inner query or no variables to join
            return null;
        }
        Expression expr = null;
        for (Iterator i = variables.iterator(); i.hasNext(); ) {
            String name = (String)i.next();
            VariableNode var = new VariableNode(name);
            Expression innerExpr = var.generateExpression(this);
            Expression outerExpr = var.generateExpression(outer);
            Expression join = innerExpr.equal(outerExpr);
            expr = var.appendExpression(expr, join);
        }
        return expr;
    
public voidsetMemberOfNode(oracle.toplink.essentials.internal.parsing.MemberOfNode newMemberOfNode)

        memberOfNode = newMemberOfNode;
    
public booleanshouldCheckSelectNodeBeforeResolving()

        return shouldCheckSelectNodeBeforeResolving;
    
public booleanshouldUseOuterJoins()

        return shouldUseOuterJoins;
    
public voiduseOuterJoins()

        shouldUseOuterJoins = true;
    
public booleanuseParallelExpressions()

        return useParallelExpressions;