// * joined prefetch PK
ObjEntity oe = getRootEntity();
// null tree will indicate that we don't take inheritance into account
EntityInheritanceTree tree = null;
if (query.isResolvingInherited()) {
tree = getRootInheritanceTree();
}
// ObjEntity attrs
Iterator attrs = (tree != null) ? tree.allAttributes().iterator() : oe
.getAttributes()
.iterator();
while (attrs.hasNext()) {
ObjAttribute oa = (ObjAttribute) attrs.next();
Iterator dbPathIterator = oa.getDbPathIterator();
while (dbPathIterator.hasNext()) {
Object pathPart = dbPathIterator.next();
if (pathPart instanceof DbRelationship) {
DbRelationship rel = (DbRelationship) pathPart;
dbRelationshipAdded(rel);
}
else if (pathPart instanceof DbAttribute) {
DbAttribute dbAttr = (DbAttribute) pathPart;
if (dbAttr == null) {
throw new CayenneRuntimeException(
"ObjAttribute has no DbAttribute: " + oa.getName());
}
appendColumn(columns, oa, dbAttr, attributes, null);
}
}
}
// relationship keys
Iterator rels = (tree != null) ? tree.allRelationships().iterator() : oe
.getRelationships()
.iterator();
while (rels.hasNext()) {
ObjRelationship rel = (ObjRelationship) rels.next();
DbRelationship dbRel = (DbRelationship) rel.getDbRelationships().get(0);