Search in sources :

Example 1 with ColumnRealName

use of org.dbflute.dbmeta.name.ColumnRealName in project dbflute-core by dbflute.

the class AbstractSqlClause method doBuildJoinOnClauseBasic.

protected int doBuildJoinOnClauseBasic(StringBuilder sb, LeftOuterJoinInfo joinInfo, Map<ColumnRealName, ColumnRealName> joinOnMap, int currentConditionCount) {
    for (Entry<ColumnRealName, ColumnRealName> joinOnEntry : joinOnMap.entrySet()) {
        final ColumnRealName localRealName = joinOnEntry.getKey();
        final ColumnRealName foreignRealName = joinOnEntry.getValue();
        sb.append(currentConditionCount > 0 ? " and " : "");
        sb.append(localRealName).append(" = ").append(foreignRealName);
        ++currentConditionCount;
    }
    return currentConditionCount;
}
Also used : ColumnRealName(org.dbflute.dbmeta.name.ColumnRealName)

Example 2 with ColumnRealName

use of org.dbflute.dbmeta.name.ColumnRealName in project dbflute-core by dbflute.

the class DerivedReferrer method buildDerivedReferrer.

// ===================================================================================
// Build Clause
// ============
public String buildDerivedReferrer(String function, String correlatedColumnDbName, String relatedColumnDbName, String correlatedFixedCondition, DerivedReferrerOption option) {
    setupOptionAttribute(option);
    if (isSinglePrimaryKey(correlatedColumnDbName, relatedColumnDbName)) {
        final ColumnRealName correlatedColumnRealName = _localRealNameProvider.provide(correlatedColumnDbName);
        final ColumnSqlName relatedColumnSqlName = _subQuerySqlNameProvider.provide(relatedColumnDbName);
        final String subQueryClause = buildSubQueryClause(function, correlatedColumnRealName, relatedColumnSqlName, correlatedFixedCondition, option);
        final String beginMark = resolveSubQueryBeginMark(_subQueryIdentity) + ln();
        final String endMark = resolveSubQueryEndMark(_subQueryIdentity);
        final String endIndent = "       ";
        return doBuildDerivedReferrer(function, correlatedColumnRealName, relatedColumnSqlName, subQueryClause, beginMark, endMark, endIndent);
    } else {
        final List<String> columnDbNameSplit = Srl.splitListTrimmed(correlatedColumnDbName, ",");
        final ColumnRealName[] correlatedColumnRealNames = new ColumnRealName[columnDbNameSplit.size()];
        for (int i = 0; i < columnDbNameSplit.size(); i++) {
            correlatedColumnRealNames[i] = _localRealNameProvider.provide(columnDbNameSplit.get(i));
        }
        final List<String> relatedColumnSplit = Srl.splitListTrimmed(relatedColumnDbName, ",");
        final ColumnSqlName[] relatedColumnSqlNames = new ColumnSqlName[relatedColumnSplit.size()];
        for (int i = 0; i < relatedColumnSplit.size(); i++) {
            relatedColumnSqlNames[i] = _subQuerySqlNameProvider.provide(relatedColumnSplit.get(i));
        }
        final String subQueryClause = buildSubQueryClause(function, correlatedColumnRealNames, relatedColumnSqlNames, correlatedFixedCondition, option);
        final String beginMark = resolveSubQueryBeginMark(_subQueryIdentity) + ln();
        final String endMark = resolveSubQueryEndMark(_subQueryIdentity);
        final String endIndent = "       ";
        return doBuildDerivedReferrer(function, correlatedColumnRealNames, relatedColumnSqlNames, subQueryClause, beginMark, endMark, endIndent);
    }
}
Also used : ColumnSqlName(org.dbflute.dbmeta.name.ColumnSqlName) ColumnRealName(org.dbflute.dbmeta.name.ColumnRealName)

Example 3 with ColumnRealName

use of org.dbflute.dbmeta.name.ColumnRealName in project dbflute-core by dbflute.

the class InScopeRelation method buildInScopeRelation.

// ===================================================================================
// Build Clause
// ============
public String buildInScopeRelation(String columnDbName, String relatedColumnDbName, String correlatedFixedCondition, String inScopeOption) {
    inScopeOption = inScopeOption != null ? inScopeOption + " " : "";
    final String subQueryClause;
    {
        final ColumnSqlName relatedColumnSqlName = _subQuerySqlNameProvider.provide(relatedColumnDbName);
        subQueryClause = getSubQueryClause(relatedColumnSqlName, correlatedFixedCondition);
    }
    final String beginMark = resolveSubQueryBeginMark(_subQueryIdentity) + ln();
    final String endMark = resolveSubQueryEndMark(_subQueryIdentity);
    final String endIndent = "       ";
    final ColumnRealName columnRealName;
    {
        final ColumnRealName localRealName = _localRealNameProvider.provide(columnDbName);
        if (_suppressLocalAliasName) {
            columnRealName = ColumnRealName.create(null, localRealName.getColumnSqlName());
        } else {
            columnRealName = localRealName;
        }
    }
    return columnRealName + " " + inScopeOption + "in (" + beginMark + subQueryClause + ln() + endIndent + ")" + endMark;
}
Also used : ColumnSqlName(org.dbflute.dbmeta.name.ColumnSqlName) ColumnRealName(org.dbflute.dbmeta.name.ColumnRealName)

Example 4 with ColumnRealName

use of org.dbflute.dbmeta.name.ColumnRealName in project dbflute-core by dbflute.

the class ScalarCondition method buildSubQueryClause.

protected String buildSubQueryClause(String function, ScalarConditionOption option) {
    // release ScalarCondition for compound PK
    // (compound PK restricted until 1.0.5G without special reason)
    // if (!_subQueryDBMeta.hasPrimaryKey() || _subQueryDBMeta.hasCompoundPrimaryKey()) {
    // String msg = "The scalar-condition is unsupported when no primary key or compound primary key:";
    // msg = msg + " table=" + _subQueryDBMeta.getTableDbName();
    // throw new IllegalConditionBeanOperationException(msg);
    // }
    final String tableAliasName = getSubQueryLocalAliasName();
    final String derivedColumnDbName = _subQuerySqlClause.getSpecifiedColumnDbNameAsOne();
    if (derivedColumnDbName == null) {
        throwScalarConditionInvalidColumnSpecificationException(function);
    }
    final ColumnSqlName derivedColumnSqlName = getDerivedColumnSqlName();
    final ColumnRealName derivedColumnRealName = getDerivedColumnRealName();
    assertScalarConditionColumnType(function, derivedColumnDbName);
    ColumnRealName partitionByCorrelatedColumnRealName = null;
    ColumnSqlName partitionByRelatedColumnSqlName = null;
    final SqlClause partitionBySqlClause = _partitionByProvider.provideSqlClause();
    if (partitionBySqlClause != null) {
        final String partitionByColumnDbName = partitionBySqlClause.getSpecifiedColumnDbNameAsOne();
        if (partitionByColumnDbName == null) {
            // means empty specify or duplicate specify
            throwScalarConditionPartitionByInvalidColumnSpecificationException(function);
        }
        partitionByCorrelatedColumnRealName = _localRealNameProvider.provide(partitionByColumnDbName);
        partitionByRelatedColumnSqlName = _subQuerySqlNameProvider.provide(partitionByColumnDbName);
    }
    final String subQueryClause;
    if (_subQuerySqlClause.hasUnionQuery()) {
        subQueryClause = buildUnionSubQuerySql(function, tableAliasName, derivedColumnSqlName, derivedColumnRealName, partitionByCorrelatedColumnRealName, partitionByRelatedColumnSqlName, option);
    } else {
        final String selectClause = "select " + buildFunctionPart(function, derivedColumnRealName, option, false);
        final String fromWhereClause = buildFromWhereClause(selectClause, tableAliasName, partitionByCorrelatedColumnRealName, partitionByRelatedColumnSqlName);
        subQueryClause = selectClause + " " + fromWhereClause;
    }
    return resolveSubQueryLevelVariable(subQueryClause);
}
Also used : ColumnSqlName(org.dbflute.dbmeta.name.ColumnSqlName) SqlClause(org.dbflute.cbean.sqlclause.SqlClause) ColumnRealName(org.dbflute.dbmeta.name.ColumnRealName)

Example 5 with ColumnRealName

use of org.dbflute.dbmeta.name.ColumnRealName in project dbflute-core by dbflute.

the class AbstractSqlClause method registerOuterJoinInlineWhereClause.

// -----------------------------------------------------
// In-line for Outer Join
// ----------------------
public // foreign alias of column
void registerOuterJoinInlineWhereClause(// foreign alias of column
String foreignAliasName, // SQL name of column
ColumnSqlName columnSqlName, // basic resources
ConditionKey key, // basic resources
ConditionValue value, // optional resources
ColumnFunctionCipher cipher, // optional resources
ConditionOption option, boolean onClause) {
    assertNotYetOuterJoin(foreignAliasName);
    final List<QueryClause> clauseList = getOuterJoinInlineWhereClauseList4Register(foreignAliasName, onClause);
    final String tableAliasName = onClause ? foreignAliasName : getInlineViewBasePointAlias();
    final ColumnRealName columnRealName = ColumnRealName.create(tableAliasName, columnSqlName);
    doRegisterWhereClause(clauseList, columnRealName, key, value, cipher, option, true, onClause);
}
Also used : ColumnRealName(org.dbflute.dbmeta.name.ColumnRealName) QueryClause(org.dbflute.cbean.sqlclause.query.QueryClause) OrScopeQueryAndPartQueryClause(org.dbflute.cbean.sqlclause.query.OrScopeQueryAndPartQueryClause) StringQueryClause(org.dbflute.cbean.sqlclause.query.StringQueryClause)

Aggregations

ColumnRealName (org.dbflute.dbmeta.name.ColumnRealName)21 ColumnSqlName (org.dbflute.dbmeta.name.ColumnSqlName)8 ColumnInfo (org.dbflute.dbmeta.info.ColumnInfo)5 ColumnFunctionCipher (org.dbflute.cbean.cipher.ColumnFunctionCipher)2 SpecifiedColumn (org.dbflute.cbean.dream.SpecifiedColumn)2 OrScopeQueryAndPartQueryClause (org.dbflute.cbean.sqlclause.query.OrScopeQueryAndPartQueryClause)2 QueryClause (org.dbflute.cbean.sqlclause.query.QueryClause)2 StringQueryClause (org.dbflute.cbean.sqlclause.query.StringQueryClause)2 DBMeta (org.dbflute.dbmeta.DBMeta)2 ArrayList (java.util.ArrayList)1 GearedCipherManager (org.dbflute.cbean.cipher.GearedCipherManager)1 QueryModeProvider (org.dbflute.cbean.cvalue.ConditionValue.QueryModeProvider)1 SqlClause (org.dbflute.cbean.sqlclause.SqlClause)1 FixedConditionResolver (org.dbflute.cbean.sqlclause.join.FixedConditionResolver)1 OnQueryStringConnector (org.dbflute.dbway.OnQueryStringConnector)1 IllegalConditionBeanOperationException (org.dbflute.exception.IllegalConditionBeanOperationException)1