/** * INTERNAL: * Find the alias for a given table from the first or second child in the additionalOuterJoinCriteria */ public DatabaseTable aliasForTable(DatabaseTable table) { DatabaseTable alias = null; if (this.firstChild != null) { alias = this.firstChild.aliasForTable(table); } if ((alias == null) && (this.secondChild != null)) { alias = this.secondChild.aliasForTable(table); } return alias; }
/** * INTERNAL: * Find the alias for a given table from the first or second child in the additionalOuterJoinCriteria */ public DatabaseTable aliasForTable(DatabaseTable table) { DatabaseTable alias = null; if (this.firstChild != null) { alias = this.firstChild.aliasForTable(table); } if ((alias == null) && (this.secondChild != null)) { alias = this.secondChild.aliasForTable(table); } return alias; }
/** * INTERNAL: * Find the alias for a given table from the first or second child in the additionalOuterJoinCriteria */ public DatabaseTable aliasForTable(DatabaseTable table) { DatabaseTable alias = null; if (this.firstChild != null) { alias = this.firstChild.aliasForTable(table); } if ((alias == null) && (this.secondChild != null)) { alias = this.secondChild.aliasForTable(table); } return alias; }
/** * INTERNAL: * Find the alias for a given table */ public DatabaseTable aliasForTable(DatabaseTable table) { return getBaseExpression().aliasForTable(table); }
/** * INTERNAL: * Find the alias for a given table */ @Override public DatabaseTable aliasForTable(DatabaseTable table) { return getBaseExpression().aliasForTable(table); }
/** * INTERNAL: * Find the alias for a given table */ public DatabaseTable aliasForTable(DatabaseTable table) { return getBaseExpression().aliasForTable(table); }
/** * INTERNAL: * Find the alias for a given table */ @Override public DatabaseTable aliasForTable(DatabaseTable table) { if (tableAliases == null) { if (this.baseExpression == null) { return null; } return this.baseExpression.aliasForTable(table); } return tableAliases.keyAtValue(table); }
/** * INTERNAL: * Find the alias for a given table */ @Override public DatabaseTable aliasForTable(DatabaseTable table) { if (tableAliases == null) { if (this.baseExpression == null) { return null; } return this.baseExpression.aliasForTable(table); } return tableAliases.keyAtValue(table); }
/** * INTERNAL: * Find the alias for a given table */ public DatabaseTable aliasForTable(DatabaseTable table) { if (tableAliases == null) { if (getBaseExpression() == null) { return null; } return getBaseExpression().aliasForTable(table); } return tableAliases.keyAtValue(table); }
private String getQualifiedName(DatasourcePlatform platform, boolean allowDelimiters){ if (qualifiedName == null) { // Print nested table using the TABLE function. DatabaseMapping mapping = queryKeyExpression.getMapping(); DatabaseTable nestedTable = mapping.getDescriptor().getTables().firstElement(); DatabaseTable tableAlias = queryKeyExpression.getBaseExpression().aliasForTable(nestedTable); StringBuilder name = new StringBuilder(); name.append("TABLE("); if (allowDelimiters && useDelimiters){ name.append(platform.getStartDelimiter()); } name.append(tableAlias.getName()); if (allowDelimiters && useDelimiters){ name.append(platform.getEndDelimiter()); } name.append("."); if (allowDelimiters && useDelimiters){ name.append(platform.getStartDelimiter()); } name.append(mapping.getField().getNameDelimited(platform)); if (allowDelimiters && useDelimiters){ name.append(platform.getEndDelimiter()); } name.append(")"); qualifiedName = name.toString(); } return qualifiedName; }
private String getQualifiedName(DatasourcePlatform platform, boolean allowDelimiters){ if (qualifiedName == null) { // Print nested table using the TABLE function. DatabaseMapping mapping = queryKeyExpression.getMapping(); DatabaseTable nestedTable = mapping.getDescriptor().getTables().firstElement(); DatabaseTable tableAlias = queryKeyExpression.getBaseExpression().aliasForTable(nestedTable); StringBuilder name = new StringBuilder(); name.append("TABLE("); if (allowDelimiters && useDelimiters){ name.append(platform.getStartDelimiter()); } name.append(tableAlias.getName()); if (allowDelimiters && useDelimiters){ name.append(platform.getEndDelimiter()); } name.append("."); if (allowDelimiters && useDelimiters){ name.append(platform.getStartDelimiter()); } name.append(mapping.getField().getNameDelimited(platform)); if (allowDelimiters && useDelimiters){ name.append(platform.getEndDelimiter()); } name.append(")"); qualifiedName = name.toString(); } return qualifiedName; }
/** * INTERNAL: Find the alias for a given table. Handle the special case where we are bogus * and it should be aliased against our derived tables instead. */ public DatabaseTable aliasForTable(DatabaseTable table) { if (hasViewTable()) { return getAliasedViewTable(); } if (doesNotRepresentAnObjectInTheQuery()) { for (Expression expression : this.derivedTables) { DatabaseTable result = expression.aliasForTable(table); if (result != null) { return result; } } } else { return super.aliasForTable(table); } return null; // No alias found in the derived tables }
/** * INTERNAL: Find the alias for a given table. Handle the special case where we are bogus * and it should be aliased against our derived tables instead. */ public DatabaseTable aliasForTable(DatabaseTable table) { if (hasViewTable()) { return getAliasedViewTable(); } if (doesNotRepresentAnObjectInTheQuery()) { for (Expression expression : this.derivedTables) { DatabaseTable result = expression.aliasForTable(table); if (result != null) { return result; } } } else { return super.aliasForTable(table); } return null; // No alias found in the derived tables }
/** * INTERNAL: * Find the alias for a given table */ @Override public DatabaseTable aliasForTable(DatabaseTable table) { DatabaseMapping mapping = getMapping(); if (isAttribute() || ((mapping != null) && (mapping.isAggregateObjectMapping() || mapping.isTransformationMapping()))) { return ((DataExpression)this.baseExpression).aliasForTable(table); } //"ref" and "structure" mappings, no table printed in the FROM clause, need to get the table alias form the parent table if ((mapping != null) && (mapping.isReferenceMapping() || mapping.isStructureMapping())) { DatabaseTable alias = this.baseExpression.aliasForTable(mapping.getDescriptor().getTables().firstElement()); alias.setName(alias.getName() + "." + mapping.getField().getName()); return alias; } // For direct-collection mappings the alias is store on the table expression. if ((mapping != null) && (mapping.isDirectCollectionMapping())) { if (tableAliases != null){ DatabaseTable aliasedTable = tableAliases.keyAtValue(table); if (aliasedTable != null){ return aliasedTable; } } return getTable(table).aliasForTable(table); } return super.aliasForTable(table); }
/** * INTERNAL: * Find the alias for a given table */ public DatabaseTable aliasForTable(DatabaseTable table) { DatabaseMapping mapping = getMapping(); if (isAttribute() || ((mapping != null) && (mapping.isAggregateObjectMapping() || mapping.isTransformationMapping()))) { return ((DataExpression)getBaseExpression()).aliasForTable(table); } //"ref" and "structure" mappings, no table printed in the FROM clause, need to get the table alias form the parent table if ((mapping != null) && (mapping.isReferenceMapping() || mapping.isStructureMapping())) { DatabaseTable alias = getBaseExpression().aliasForTable(mapping.getDescriptor().getTables().firstElement()); alias.setName(alias.getName() + "." + mapping.getField().getName()); return alias; } // For direct-collection mappings the alias is store on the table expression. if ((mapping != null) && (mapping.isDirectCollectionMapping())) { if (tableAliases != null){ DatabaseTable aliasedTable = tableAliases.keyAtValue(table); if (aliasedTable != null){ return aliasedTable; } } return getTable(table).aliasForTable(table); } return super.aliasForTable(table); }
/** * INTERNAL: * Append the field's alias to the writer. * This is used for pessimistic locking. */ protected void writeAlias(ExpressionSQLPrinter printer, DatabaseField field, SQLSelectStatement statement) { //print ", " before each selected field except the first one if (printer.isFirstElementPrinted()) { printer.printString(", "); } else { printer.setIsFirstElementPrinted(true); } if (statement.requiresAliases()) { if (field.getTable() != this.lastTable) { this.lastTable = field.getTable(); this.currentAlias = aliasForTable(this.lastTable); } printer.printString(this.currentAlias.getQualifiedNameDelimited(printer.getPlatform())); } else { printer.printString(field.getTable().getQualifiedNameDelimited(printer.getPlatform())); } }
/** * INTERNAL: * Append the field's alias to the writer. * This is used for pessimistic locking. */ protected void writeAlias(ExpressionSQLPrinter printer, DatabaseField field, SQLSelectStatement statement) { //print ", " before each selected field except the first one if (printer.isFirstElementPrinted()) { printer.printString(", "); } else { printer.setIsFirstElementPrinted(true); } if (statement.requiresAliases()) { if (field.getTable() != this.lastTable) { this.lastTable = field.getTable(); this.currentAlias = aliasForTable(this.lastTable); } printer.printString(this.currentAlias.getQualifiedNameDelimited(printer.getPlatform())); } else { printer.printString(field.getTable().getQualifiedNameDelimited(printer.getPlatform())); } }
/** * INTERNAL: * Append the field's alias to the writer. * This is used for pessimistic locking. */ protected void writeAlias(ExpressionSQLPrinter printer, DatabaseField field, SQLSelectStatement statement) { //print ", " before each selected field except the first one if (printer.isFirstElementPrinted()) { printer.printString(", "); } else { printer.setIsFirstElementPrinted(true); } if (statement.requiresAliases()) { if (field.getTable() != this.lastTable) { this.lastTable = field.getTable(); this.currentAlias = aliasForTable(this.lastTable); } printer.printString(this.currentAlias.getQualifiedNameDelimited(printer.getPlatform())); } else { printer.printString(field.getTable().getQualifiedNameDelimited(printer.getPlatform())); } }
/** * INTERNAL: * Append the field name to the writer. Should be overridden for special operators such as functions. */ protected void writeField(ExpressionSQLPrinter printer, DatabaseField field, SQLSelectStatement statement) { //print ", " before each selected field except the first one if (printer.isFirstElementPrinted()) { printer.printString(", "); } else { printer.setIsFirstElementPrinted(true); } if (statement.requiresAliases()) { if (field.getTable() != lastTable) { lastTable = field.getTable(); currentAlias = aliasForTable(lastTable); } printer.printString(currentAlias.getQualifiedNameDelimited(printer.getPlatform())); printer.printString("."); } printer.printString(field.getNameDelimited(printer.getPlatform())); //bug6070214: unique field aliases need to be generated when required. addFieldAliasIfNeeded(printer, field, statement); }
/** * INTERNAL: * Append the field name to the writer. Should be overridden for special operators such as functions. */ protected void writeField(ExpressionSQLPrinter printer, DatabaseField field, SQLSelectStatement statement) { //print ", " before each selected field except the first one if (printer.isFirstElementPrinted()) { printer.printString(", "); } else { printer.setIsFirstElementPrinted(true); } if (statement.requiresAliases()) { if (field.getTable() != lastTable) { lastTable = field.getTable(); currentAlias = aliasForTable(lastTable); } printer.printString(currentAlias.getQualifiedNameDelimited(printer.getPlatform())); printer.printString("."); } printer.printString(field.getNameDelimited(printer.getPlatform())); //bug6070214: unique field aliases need to be generated when required. if (statement.getUseUniqueFieldAliases()){ printer.printString(" AS " + statement.generatedAlias(field.getNameDelimited(printer.getPlatform()))); } }