void registerFromElement(FromElement element) { fromElements.add(element); String classAlias = element.getClassAlias(); if (classAlias != null) { // The HQL class alias refers to the class name. fromElementByClassAlias.put(classAlias, element); } // Associate the table alias with the element. String tableAlias = element.getTableAlias(); if (tableAlias != null) { fromElementByTableAlias.put(tableAlias, element); } }
private FromElement createFromElementInSubselect( String path, String pathAlias, FromElement parentFromElement, String classAlias) throws SemanticException { if (log.isDebugEnabled()) { log.debug("createFromElementInSubselect() : path = " + path); } // Create an DotNode AST for the path and resolve it. FromElement fromElement = evaluateFromElementPath(path, classAlias); EntityPersister entityPersister = fromElement.getEntityPersister(); // If the first identifier in the path referrs to the class alias (not the class name), then // this // is a correlated subselect. If it's a correlated sub-select, use the existing table alias. // Otherwise // generate a new one. String tableAlias = null; boolean correlatedSubselect = pathAlias.equals(parentFromElement.getClassAlias()); if (correlatedSubselect) { tableAlias = fromElement.getTableAlias(); } else { tableAlias = null; } // If the from element isn't in the same clause, create a new from element. if (fromElement.getFromClause() != fromClause) { if (log.isDebugEnabled()) { log.debug("createFromElementInSubselect() : creating a new FROM element..."); } fromElement = createFromElement(entityPersister); initializeAndAddFromElement( fromElement, path, classAlias, entityPersister, (EntityType) ((Queryable) entityPersister).getType(), tableAlias); } if (log.isDebugEnabled()) { log.debug("createFromElementInSubselect() : " + path + " -> " + fromElement); } return fromElement; }