* @param sb String buffer taking the resulting text.
*/
protected void generateColumnText(LocalFieldDesc desc, QueryPlan thePlan,
StringBuffer sb) {
QueryTable table = null;
ColumnElement column = null;
Iterator iter = desc.getColumnElements();
while (iter.hasNext() && table == null) {
column = (ColumnElement) iter.next();
// For updates, the member variable tableList is complete
// at this point and includes only the table being updated.
// For selects, new tables are still added to tableList
// when join constraints are processed. Take the table list
// from the query plan to find the table matching the column.
if (action == QueryPlan.ACT_SELECT) {
table = thePlan.findQueryTable(column.getDeclaringTable());
} else {
table = findQueryTable(column.getDeclaringTable());
}
}
if (table == null) {
throw new JDOFatalInternalException(I18NHelper.getMessage(messages,
"core.configuration.fieldnotable", // NOI18N
desc.getName()));
}
// Select statements might include columns from several tables.
// Qualify the column with the table index.
if (action == QueryPlan.ACT_SELECT) {
sb.append("t").append(table.getTableIndex()).append("."); // NOI18N
}
appendQuotedText(sb, column.getName().getName());
}