FileDocCategorySizeDatePackage
CorrelatedSelectPlan.javaAPI DocGlassfish v2 API4830Fri May 04 22:35:16 BST 2007com.sun.jdo.spi.persistence.support.sqlstore.sql.generator

CorrelatedSelectPlan

public abstract class CorrelatedSelectPlan extends SelectQueryPlan
Implements the select plan for correlated subqueries.
author
Mitesh Meswani
author
Markus Fuchs

Fields Summary
protected SelectQueryPlan
parentPlan
The parent plan for this subquery
Constructors Summary
public CorrelatedSelectPlan(com.sun.jdo.spi.persistence.support.sqlstore.RetrieveDesc desc, com.sun.jdo.spi.persistence.support.sqlstore.SQLStoreManager store, com.sun.jdo.spi.persistence.support.sqlstore.model.ForeignFieldDesc parentField, SelectQueryPlan parentPlan)


        super(desc, store, null);
        this.parentField = parentField;
        this.parentPlan = parentPlan;
    
Methods Summary
protected voidaddQueryTables(java.util.ArrayList columnList, com.sun.jdo.spi.persistence.support.sqlstore.model.ClassDesc config)
Adds the query tables corresponding to the columns in columnList.

param
columnList List of columns.
param
config Class configuration corresponding to columns.

        for (int i = 0; i < columnList.size(); i++) {
            ColumnElement col = (ColumnElement) columnList.get(i);
            addQueryTable(col.getDeclaringTable(), config);
        }
    
protected abstract voiddoCorrelatedJoin()
Must be implemented by the sub classes.

protected voidprocessConstraints()
The constraints for correlated subqueries are added here. The constraints are:
  • The correlated constraint joining this subquery with the parent plan
  • A join constraint if the parent field uses join table


        // Process the constraint on the stack.`
        super.processConstraints();

        doCorrelatedJoin();

        processJoinTable();

        // Process any extra statement added as the result of #addTable.
        processStatements();
    
private voidprocessJoinTable()
Enhance the select statement to include the join table if the relationship is mapped via a join table.


        if (parentField.useJoinTable()) {
            addQueryTables(parentField.assocForeignColumns, config);

            // Put in a join for the association table.
            // Subqueries always join via equijoin.
            addJoinConstraint(this, this,
                    parentField.assocForeignColumns,
                    parentField.foreignColumns, ActionDesc.OP_EQUIJOIN);
        }