示例#1
0
  /** Simply appends column name with optional table reference and alias. */
  protected void appendColumnName(StringBuilder query, DbEntityDescriptor ded, String column) {
    query.append(resolveTable(tableRef, ded)).append('.').append(column);

    if (templateData.getColumnAliasType() != null) { // create column aliases
      String tableName = ded.getTableName();
      query.append(AS);
      switch (templateData.getColumnAliasType()) {
        case TABLE_NAME:
          query
              .append(tableName)
              .append(templateData.getDbOomManager().getColumnAliasSeparator())
              .append(column);
          break;
        case TABLE_REFERENCE:
          templateData.registerColumnDataForTableRef(tableRef, tableName);
          query
              .append(tableRef)
              .append(templateData.getDbOomManager().getColumnAliasSeparator())
              .append(column);
          break;
        case COLUMN_CODE:
          String code = templateData.registerColumnDataForColumnCode(tableName, column);
          query.append(code);
          break;
      }
    }
  }
示例#2
0
  /** Appends alias. */
  protected void appendAlias(StringBuilder query, DbEntityDescriptor ded, String column) {
    String tableName = ded.getTableName();

    ColumnAliasType columnAliasType = templateData.getColumnAliasType();
    String columnAliasSeparator = templateData.getDbOomManager().getColumnAliasSeparator();

    if (columnAliasType == null || columnAliasType == ColumnAliasType.TABLE_REFERENCE) {
      templateData.registerColumnDataForTableRef(tableRef, tableName);
      query.append(tableRef).append(columnAliasSeparator).append(column);
    } else if (columnAliasType == ColumnAliasType.COLUMN_CODE) {
      String code = templateData.registerColumnDataForColumnCode(tableName, column);
      query.append(code);
    } else if (columnAliasType == ColumnAliasType.TABLE_NAME) {
      query.append(tableName).append(columnAliasSeparator).append(column);
    }
  }