Beispiel #1
0
  @Override
  public QueryClause toQuerySql(SelectProcessor processor, SqlContext context, boolean order) {
    String tableName = (String) getAttribute(JoinElement.CUSTOM_TABLE_NAME);
    if (tableName != null) tableName = MetaHolder.toSchemaAdjustedName(tableName);
    PartitionResult[] prs =
        DbUtils.toTableNames(getInstance(), tableName, this, processor.getPartitionSupport());
    DatabaseDialect profile = processor.getProfile(prs);

    QueryClauseImpl clause = new QueryClauseImpl(profile);

    GroupClause groupClause = SelectProcessor.toGroupAndHavingClause(this, context, profile);
    clause.setGrouphavingPart(groupClause);

    clause.setSelectPart(SelectProcessor.toSelectSql(context, groupClause, profile));
    clause.setTables(type.getTableName(false), prs);
    clause.setWherePart(processor.parent.toWhereClause(this, context, false, profile).getSql());
    if (order) clause.setOrderbyPart(SelectProcessor.toOrderClause(this, context, profile));
    return clause;
  }