FileDocCategorySizeDatePackage
CorrelatedExistSelectPlan.javaAPI DocGlassfish v2 API4703Fri May 04 22:35:14 BST 2007com.sun.jdo.spi.persistence.support.sqlstore.sql.generator

CorrelatedExistSelectPlan

public class CorrelatedExistSelectPlan extends CorrelatedSelectPlan
Implements the select plan for Exist-Subqueries.
author
Mitesh Meswani
author
Markus Fuchs

Fields Summary
Constructors Summary
public CorrelatedExistSelectPlan(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, parentField, parentPlan);
    
Methods Summary
protected voiddoCorrelatedJoin()
The correlated constraint joining this subquery with the parent field. The joined table is added as a side-effect.

        ArrayList foreignFields = null;

        if (parentField.useJoinTable()) {
            foreignFields = parentField.assocLocalFields;
            // The join table is included in #processJoinTable
        } else {
            foreignFields = parentField.foreignFields;
        }

        ArrayList localFields = parentField.localFields;
        // Add the constraint linking the parent query with the subquery.
        for (int i = 0; i < localFields.size(); i++) {
            LocalFieldDesc la = (LocalFieldDesc) localFields.get(i);
            LocalFieldDesc fa = (LocalFieldDesc) foreignFields.get(i);

            ConstraintFieldDesc lcfd = new ConstraintFieldDesc(la, parentPlan);
            ConstraintFieldDesc fcfd = new ConstraintFieldDesc(fa, this);

            constraint.addField(lcfd);
            constraint.addField(fcfd);
            // Subqueries always join via equijoin.
            constraint.addOperation(ActionDesc.OP_EQ);
        }
    
protected StatementnewStatement()

        return new SelectOneStatement(store.getVendorType(), this);
    
protected voidprocessFields()
There are no real fields to be selected for an (NOT)EXIST query. This method just adds the table for the nested select. The statement for nested select is created as a side effect.

        for (int i = 0; i < parentField.foreignFields.size(); i++) {
            LocalFieldDesc field = (LocalFieldDesc) parentField.foreignFields.get(i);
            addTable(field);
        }