String fieldToken;
FieldDescriptor fd;
Selector firstSelector = null, currentSelector = null;
while (modelMapping.isManagedType(currentClass)) {
ClassMapping currentClassMapping = modelMapping.getClassMapping(currentClass);
Selector nextSelector = new Selector(currentClassMapping.getTable(), null);
if (currentSelector != null) {
Condition condition = new SimpleCondition
(column, Operator.EQUAL, nextSelector);
currentSelector.setCondition(condition);
} else {
firstSelector = nextSelector;
}
currentSelector = nextSelector;
if (!tok.hasMoreTokens()) {
throw new JDOUserException(I18N.msg("E_ordering"));
}
fieldToken = tok.nextToken();
fd = currentClassMapping.getFieldDescriptor(fieldToken);
if (fd == null) {
throw new JDOUserException(I18N.msg("E_unmapped_field", fieldToken));
}
column = currentClassMapping.getColumn(fieldToken);
currentClass = fd.type;
}
top.merge(firstSelector, Operator.ANDC);