public Collection<DbEntity> getRootDbEntities() { checkDescriptorInitialized(); return descriptor.getRootDbEntities(); }
private void addPrefetchedColumnsIfAny(final String visitedIdentifier) { PrefetchTreeNode prefetchTree = context.getCompiledExpression().getPrefetchTree(); if (prefetchTree != null) { for (PrefetchTreeNode prefetch : prefetchTree.adjacentJointNodes()) { ClassDescriptor descriptor = context.getEntityDescriptor(prefetch.getEjbqlPathEntityId()); if (visitedIdentifier.equals(prefetch.getEjbqlPathEntityId())) { DbEntity table = descriptor.getRootDbEntities().iterator().next(); ObjEntity objectEntity = descriptor.getEntity(); prefetch.setEntityName(objectEntity.getName()); Expression prefetchExp = ExpressionFactory.exp(prefetch.getPath()); Expression dbPrefetch = objectEntity.translateToDbPath(prefetchExp); DbRelationship r = null; for (PathComponent<DbAttribute, DbRelationship> component : table.resolvePath(dbPrefetch, context .getMetadata().getPathSplitAliases())) { r = component.getRelationship(); } if (r == null) { throw new CayenneRuntimeException("Invalid joint prefetch '%s' for entity: %s" , prefetch, objectEntity.getName()); } for (DbAttribute attribute : r.getTargetEntity().getAttributes()) { appendColumn(prefetch.getEjbqlPathEntityId() + "." + prefetch.getPath(), attribute, "", prefetch.getPath() + "." + attribute.getName(), null); } } } } }