if (field != null && field instanceof ForeignFieldDesc) {
ForeignFieldDesc ff = (ForeignFieldDesc) field;
if (ff.getComponentType() != rd.getPersistenceCapableClass() ) {
throw new JDOFatalInternalException(I18NHelper.getMessage(messages,
"core.constraint.unknownfield", // NOI18N
node.fieldName, rd.getPersistenceCapableClass().getName()));
}
SelectQueryPlan subqueryPlan = new CorrelatedInSelectPlan(rd, store, ff, this);
subqueryPlan.build();
// Make the tables involved in the subquery known to the parent query.
addQueryTables(subqueryPlan.tables);
// Push a new subquery constraint on the stack
ConstraintSubquery subqueryConstraint = new ConstraintSubquery();
subqueryConstraint.plan = subqueryPlan;
constraint.stack.add(subqueryConstraint);
ArrayList localFields = ff.getLocalFields();
// Add the local fields corresponding to the subquery to the stack.
for (int i = 0; i < localFields.size(); i++) {
constraint.addField((LocalFieldDesc) localFields.get(i), this);
}
} else {
// We didn't get a ForeignFieldDesc from config,
// or the field is not present in the config.
throw new JDOFatalInternalException(I18NHelper.getMessage(messages,
"core.constraint.unknownfield", // NOI18N
node.fieldName, rd.getPersistenceCapableClass().getName()));
}
}