FromElement addFromElement() throws SemanticException { FromClause parentFromClause = fromClause.getParentFromClause(); if (parentFromClause != null) { // Look up class name using the first identifier in the path. String pathAlias = PathHelper.getAlias(path); FromElement parentFromElement = parentFromClause.getFromElement(pathAlias); if (parentFromElement != null) { return createFromElementInSubselect(path, pathAlias, parentFromElement, classAlias); } } EntityPersister entityPersister = fromClause.getSessionFactoryHelper().requireClassPersister(path); FromElement elem = createAndAddFromElement( path, classAlias, entityPersister, (EntityType) ((Queryable) entityPersister).getType(), null); // Add to the query spaces. fromClause.getWalker().addQuerySpaces(entityPersister.getQuerySpaces()); return elem; }
private FromElement evaluateFromElementPath(String path, String classAlias) throws SemanticException { ASTFactory factory = fromClause.getASTFactory(); FromReferenceNode pathNode = (FromReferenceNode) PathHelper.parsePath(path, factory); pathNode.recursiveResolve( FromReferenceNode.ROOT_LEVEL, // This is the root level node. false, // Generate an explicit from clause at the root. classAlias, null); if (pathNode.getImpliedJoin() != null) { return pathNode.getImpliedJoin(); } else { return pathNode.getFromElement(); } }