/** * INTERNAL: * Print SQL onto the stream, using the ExpressionPrinter for context */ @Override public void printSQL(ExpressionSQLPrinter printer) { printer.printField(getAliasedField()); }
/** * INTERNAL: * Print SQL onto the stream, using the ExpressionPrinter for context */ public void printSQL(ExpressionSQLPrinter printer) { printer.printField(getAliasedField()); }
/** * INTERNAL: * Print SQL onto the stream, using the ExpressionPrinter for context */ @Override public void printSQL(ExpressionSQLPrinter printer) { printer.printField(getAliasedField()); }
private void printLockStartWithPrimaryKeyFields(SQLSelectStatement statement, ExpressionSQLPrinter printer) { printer.printString(LOCK_START_PREFIX); Iterator<DatabaseField> iterator = statement.getQuery().getDescriptor().getPrimaryKeyFields().iterator(); while (iterator.hasNext()) { DatabaseField field = iterator.next(); DatabaseTable alias = statement.getExpressionBuilder().aliasForTable(field.getTable()); printer.printField(field, alias); if(iterator.hasNext()) { printer.printString(","); } } printer.printString(LOCK_START_SUFFIX); }
public EclipseLinkFunctionRenderContext(List<Expression> arguments, AbstractSession session, ExpressionSQLPrinter printer) { this.argumentIndices = new int[arguments.size()]; Arrays.fill(this.argumentIndices, -1); this.arguments = arguments; this.argumentStrings = new String[arguments.size()]; // Since there are no public getters we can use to extract the translation row or whether we should print qualified names, we render dummy expressions Writer oldWriter = printer.getWriter(); try { StringWriter stringWriter = new StringWriter(); printer.setWriter(stringWriter); printer.printField(new DatabaseField("x.x")); boolean printQualifiedNames = stringWriter.getBuffer().indexOf(".") != -1; ParameterExpressionMock parameterExpressionMock = new ParameterExpressionMock(); parameterExpressionMock.printSQL(printer); List<?> parameters = printer.getCall().getParameters(); parameters.remove(parameters.size() - 1); List<?> parameterTypes = printer.getCall().getParameterTypes(); parameterTypes.remove(parameterTypes.size() - 1); stringWriter.getBuffer().setLength(0); expressionSQLPrinter = new ExpressionSQLPrinter(session, parameterExpressionMock.translationRow, datasourceCallMock, printQualifiedNames, new ExpressionBuilder()); expressionSQLPrinter.setWriter(stringWriter); } finally { printer.setWriter(oldWriter); } }
public EclipseLinkFunctionRenderContext(List<Expression> arguments, AbstractSession session, ExpressionSQLPrinter printer) { this.argumentIndices = new int[arguments.size()]; Arrays.fill(this.argumentIndices, -1); this.arguments = arguments; this.argumentStrings = new String[arguments.size()]; // Since there are no public getters we can use to extract the translation row or whether we should print qualified names, we render dummy expressions Writer oldWriter = printer.getWriter(); try { StringWriter stringWriter = new StringWriter(); printer.setWriter(stringWriter); printer.printField(new DatabaseField("x.x")); boolean printQualifiedNames = stringWriter.getBuffer().indexOf(".") != -1; ParameterExpressionMock parameterExpressionMock = new ParameterExpressionMock(); parameterExpressionMock.printSQL(printer); List<?> parameters = printer.getCall().getParameters(); parameters.remove(parameters.size() - 1); List<?> parameterTypes = printer.getCall().getParameterTypes(); parameterTypes.remove(parameterTypes.size() - 1); stringWriter.getBuffer().setLength(0); expressionSQLPrinter = new ExpressionSQLPrinter(session, parameterExpressionMock.translationRow, datasourceCallMock, printQualifiedNames, new ExpressionBuilder()); expressionSQLPrinter.setWriter(stringWriter); } finally { printer.setWriter(oldWriter); } }
/** * INTERNAL: * Print SQL onto the stream, using the ExpressionPrinter for context */ public void printSQL(ExpressionSQLPrinter printer) { // to support custom types, print expressions derived from field expressions and direct query keys with their aliases // Note: This is also necessary for TableExpressions, but they are taken care of by their associated FieldExpression. if (getBaseExpression() != null && getBaseExpression().isFieldExpression() || (getBaseExpression().isQueryKeyExpression() && ((QueryKeyExpression)getBaseExpression()).isAttribute())){ getBaseExpression().printSQL(printer); printer.printString("."); } printer.printField(getAliasedField()); }
/** * INTERNAL: * Print SQL onto the stream, using the ExpressionPrinter for context */ public void printSQL(ExpressionSQLPrinter printer) { // to support custom types, print expressions derived from field expressions and direct query keys with their aliases // Note: This is also necessary for TableExpressions, but they are taken care of by their associated FieldExpression. if (getBaseExpression() != null && getBaseExpression().isFieldExpression() || (getBaseExpression().isQueryKeyExpression() && ((QueryKeyExpression)getBaseExpression()).isAttribute())){ getBaseExpression().printSQL(printer); printer.printString("."); } printer.printField(getAliasedField()); }
/** * INTERNAL: * Print SQL onto the stream, using the ExpressionPrinter for context */ public void printSQL(ExpressionSQLPrinter printer) { // to support custom types, print expressions derived from field expressions and direct query keys with their aliases // Note: This is also necessary for TableExpressions, but they are taken care of by their associated FieldExpression. if (getBaseExpression() != null && getBaseExpression().isFieldExpression() || (getBaseExpression().isQueryKeyExpression() && ((QueryKeyExpression)getBaseExpression()).isAttribute())){ getBaseExpression().printSQL(printer); printer.printString("."); } printer.printField(getAliasedField()); }
/** * 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 */ @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()); } }