@Override public void visit(Selector node) { if (node.hasAlias()) { symbols.add(node.getAlias()); } else { symbols.add(node.getName()); } }
/** * {@inheritDoc} * * @see QueryObjectModelVisitor#visit(NamedSelector) */ public void visit(Selector selector) { append(selector.getName()); if (selector.hasAlias()) { append(" AS ").append(selector.getAlias()); } }
/** * Specify the name of the table from which tuples should be selected. The * supplied string is of the form " <code>tableName [AS alias]</code>". * * @param tableNameWithOptionalAlias * the name of the table, optionally including the alias * @return this builder object, for convenience in method chaining */ public QueryBuilder from(String tableNameWithOptionalAlias) { Selector selector = namedSelector(tableNameWithOptionalAlias); SelectorName oldName = this.source instanceof Selector ? ((Selector)source).getName() : null; // Go through the columns and change the selector name to use the new // alias ... for (int i = 0; i != columns.size(); ++i) { Column old = columns.get(i); if (old.getSelectorName().equals(oldName)) { columns.set(i, new Column(selector.getAliasOrName(), old.getPropertyName(), old.getColumnName())); } } this.source = selector; return this; }
name = selector.hasAlias() ? selector.getAlias() : selector.getName(); propertyName = parts[0]; columnName = parts[0];