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); DatabaseTable nestedTableAlias = queryKeyExpression.aliasForTable(this); StringBuffer name = new StringBuffer(); 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; }
this.targetAlias = expression.aliasForTable(this.targetTable);
this.targetAlias = expression.aliasForTable(this.targetTable);
DatabaseTable targetAlias = outerExpression.aliasForTable(targetTable); target.hasMoreElements();) { DatabaseTable newTarget = (DatabaseTable)target.nextElement(); DatabaseTable newAlias = outerExpression.aliasForTable(newTarget); writer.write(", OUTER "); writer.write(newTarget.getQualifiedNameDelimited(printer.getPlatform()));
DatabaseTable targetAlias = outerExpression.aliasForTable(targetTable); target.hasMoreElements();) { DatabaseTable newTarget = (DatabaseTable)target.nextElement(); DatabaseTable newAlias = outerExpression.aliasForTable(newTarget); writer.write(", OUTER "); writer.write(newTarget.getQualifiedNameDelimited(printer.getPlatform()));
DatabaseTable targetAlias = outerExpression.aliasForTable(targetTable); target.hasMoreElements();) { DatabaseTable newTarget = (DatabaseTable)target.nextElement(); DatabaseTable newAlias = outerExpression.aliasForTable(newTarget); writer.write(", OUTER "); writer.write(newTarget.getQualifiedNameDelimited(printer.getPlatform()));
sourceTable = outerExpression.getSourceTable(); sourceAlias = outerExpression.getBaseExpression().aliasForTable(sourceTable); targetAlias = outerExpression.aliasForTable(targetTable); } else { sourceTable = ((ClassDescriptor)getDescriptorsForMultitableInheritanceOnly().get(index)).getTables().firstElement();
/** * INTERNAL: * Print SQL onto the stream, using the ExpressionPrinter for context */ @Override public void printSQL(ExpressionSQLPrinter printer) { if (isAttribute()) { printer.printField(getAliasedField()); } // If the mapping is a direct collection then this falls into a gray area. // It must be treated as an attribute at this moment for it has a direct field. // However it is not an attribute in the sense that it also represents a foreign // reference and a mapping criteria has been added. // For bug 2900974 these are now handled as non-attributes during normalize but // as attributes when printing SQL. // if ((!isAttribute()) && (getMapping() != null) && getMapping().isDirectCollectionMapping()) { DirectCollectionMapping directCollectionMapping = (DirectCollectionMapping)getMapping(); // The aliased table comes for free as it was a required part of the join criteria. TableExpression table = (TableExpression)getTable(directCollectionMapping.getReferenceTable()); DatabaseTable aliasedTable = table.aliasForTable(table.getTable()); DatabaseField aliasedField = directCollectionMapping.getDirectField().clone(); aliasedField.setTable(aliasedTable); printer.printField(aliasedField); } if ((getMapping() != null) && getMapping().isNestedTableMapping()) { DatabaseTable tableAlias = aliasForTable(new NestedTable(this)); printer.printString(tableAlias.getName()); } }
/** * INTERNAL: * Print SQL onto the stream, using the ExpressionPrinter for context */ public void printSQL(ExpressionSQLPrinter printer) { if (isAttribute()) { printer.printField(getAliasedField()); } // If the mapping is a direct collection then this falls into a gray area. // It must be treated as an attribute at this moment for it has a direct field. // However it is not an attribute in the sense that it also represents a foreign // reference and a mapping criteria has been added. // For bug 2900974 these are now handled as non-attributes during normalize but // as attributes when printing SQL. // if ((!isAttribute()) && (getMapping() != null) && getMapping().isDirectCollectionMapping()) { DirectCollectionMapping directCollectionMapping = (DirectCollectionMapping)getMapping(); // The aliased table comes for free as it was a required part of the join criteria. TableExpression table = (TableExpression)getTable(directCollectionMapping.getReferenceTable()); DatabaseTable aliasedTable = table.aliasForTable(table.getTable()); DatabaseField aliasedField = (DatabaseField)directCollectionMapping.getDirectField().clone(); aliasedField.setTable(aliasedTable); printer.printField(aliasedField); } if ((getMapping() != null) && getMapping().isNestedTableMapping()) { DatabaseTable tableAlias = aliasForTable(new NestedTable(this)); printer.printString(tableAlias.getName()); } }
/** * INTERNAL: * Print SQL onto the stream, using the ExpressionPrinter for context */ @Override public void printSQL(ExpressionSQLPrinter printer) { if (isAttribute()) { printer.printField(getAliasedField()); } // If the mapping is a direct collection then this falls into a gray area. // It must be treated as an attribute at this moment for it has a direct field. // However it is not an attribute in the sense that it also represents a foreign // reference and a mapping criteria has been added. // For bug 2900974 these are now handled as non-attributes during normalize but // as attributes when printing SQL. // if ((!isAttribute()) && (getMapping() != null) && getMapping().isDirectCollectionMapping()) { DirectCollectionMapping directCollectionMapping = (DirectCollectionMapping)getMapping(); // The aliased table comes for free as it was a required part of the join criteria. TableExpression table = (TableExpression)getTable(directCollectionMapping.getReferenceTable()); DatabaseTable aliasedTable = table.aliasForTable(table.getTable()); DatabaseField aliasedField = directCollectionMapping.getDirectField().clone(); aliasedField.setTable(aliasedTable); printer.printField(aliasedField); } if ((getMapping() != null) && getMapping().isNestedTableMapping()) { DatabaseTable tableAlias = aliasForTable(new NestedTable(this)); printer.printString(tableAlias.getName()); } }