Search in sources :

Example 1 with LeftOuterJoinInfo

use of org.dbflute.cbean.sqlclause.join.LeftOuterJoinInfo in project dbflute-core by dbflute.

the class AbstractSqlClause method clearOuterJoinInlineWhereClause.

public void clearOuterJoinInlineWhereClause() {
    if (_outerJoinMap == null) {
        return;
    }
    for (Entry<String, LeftOuterJoinInfo> entry : _outerJoinMap.entrySet()) {
        final LeftOuterJoinInfo joinInfo = entry.getValue();
        if (joinInfo.hasInlineOrOnClause()) {
            joinInfo.getInlineWhereClauseList().clear();
            // contains on-clause condition
            joinInfo.getAdditionalOnClauseList().clear();
        }
    }
}
Also used : LeftOuterJoinInfo(org.dbflute.cbean.sqlclause.join.LeftOuterJoinInfo)

Example 2 with LeftOuterJoinInfo

use of org.dbflute.cbean.sqlclause.join.LeftOuterJoinInfo in project dbflute-core by dbflute.

the class AbstractSqlClause method doRegisterOuterJoin.

protected void doRegisterOuterJoin(String foreignAliasName, String foreignTableDbName, String localAliasName, String localTableDbName, Map<ColumnRealName, ColumnRealName> joinOnMap, String relationPath, ForeignInfo foreignInfo, String fixedCondition, FixedConditionResolver fixedConditionResolver) {
    assertAlreadyOuterJoin(foreignAliasName);
    assertJoinOnMapNotEmpty(joinOnMap, foreignAliasName);
    final Map<String, LeftOuterJoinInfo> outerJoinMap = getOuterJoinMap();
    final LeftOuterJoinInfo joinInfo = new LeftOuterJoinInfo();
    joinInfo.setForeignAliasName(foreignAliasName);
    joinInfo.setForeignTableDbName(foreignTableDbName);
    joinInfo.setLocalAliasName(localAliasName);
    joinInfo.setLocalTableDbName(localTableDbName);
    joinInfo.setJoinOnMap(joinOnMap);
    final LeftOuterJoinInfo localJoinInfo = outerJoinMap.get(localAliasName);
    if (localJoinInfo != null) {
        // means local is also joined (not base point)
        joinInfo.setLocalJoinInfo(localJoinInfo);
    }
    joinInfo.setRelationPath(relationPath);
    joinInfo.setPureFK(foreignInfo.isPureFK());
    joinInfo.setNotNullFKColumn(foreignInfo.isNotNullFKColumn());
    joinInfo.setFixedCondition(fixedCondition);
    joinInfo.setFixedConditionResolver(fixedConditionResolver);
    // it should be resolved before registration because
    // the process may have Query(Relation) as precondition
    joinInfo.resolveFixedCondition();
    outerJoinMap.put(foreignAliasName, joinInfo);
    getRelationPathForeignAliasMap().put(relationPath, foreignAliasName);
}
Also used : LeftOuterJoinInfo(org.dbflute.cbean.sqlclause.join.LeftOuterJoinInfo)

Example 3 with LeftOuterJoinInfo

use of org.dbflute.cbean.sqlclause.join.LeftOuterJoinInfo in project dbflute-core by dbflute.

the class AbstractSqlClause method doReflectWhereUsedToJoin.

protected void doReflectWhereUsedToJoin(String usedAliasName) {
    LeftOuterJoinInfo currentJoinInfo = getOuterJoinMap().get(usedAliasName);
    while (true) {
        if (currentJoinInfo == null) {
            // means base point
            break;
        }
        if (currentJoinInfo.isWhereUsedJoin()) {
            // means already traced
            break;
        }
        currentJoinInfo.setWhereUsedJoin(true);
        // trace back toward base point
        currentJoinInfo = currentJoinInfo.getLocalJoinInfo();
    }
}
Also used : LeftOuterJoinInfo(org.dbflute.cbean.sqlclause.join.LeftOuterJoinInfo)

Example 4 with LeftOuterJoinInfo

use of org.dbflute.cbean.sqlclause.join.LeftOuterJoinInfo in project dbflute-core by dbflute.

the class AbstractSqlClause method getOuterJoinInlineWhereClauseList4Register.

protected List<QueryClause> getOuterJoinInlineWhereClauseList4Register(String foreignAliasName, boolean onClause) {
    final LeftOuterJoinInfo joinInfo = getOuterJoinMap().get(foreignAliasName);
    final List<QueryClause> clauseList;
    if (onClause) {
        if (_orScopeQueryEffective) {
            clauseList = getTmpOrAdditionalOnClauseList(foreignAliasName);
        } else {
            clauseList = joinInfo.getAdditionalOnClauseList();
        }
    } else {
        if (_orScopeQueryEffective) {
            clauseList = getTmpOrOuterJoinInlineClauseList(foreignAliasName);
        } else {
            clauseList = joinInfo.getInlineWhereClauseList();
        }
    }
    return clauseList;
}
Also used : LeftOuterJoinInfo(org.dbflute.cbean.sqlclause.join.LeftOuterJoinInfo) QueryClause(org.dbflute.cbean.sqlclause.query.QueryClause) OrScopeQueryAndPartQueryClause(org.dbflute.cbean.sqlclause.query.OrScopeQueryAndPartQueryClause) StringQueryClause(org.dbflute.cbean.sqlclause.query.StringQueryClause)

Example 5 with LeftOuterJoinInfo

use of org.dbflute.cbean.sqlclause.join.LeftOuterJoinInfo in project dbflute-core by dbflute.

the class AbstractSqlClause method isUnderOverRelation.

/**
 * {@inheritDoc}
 */
public boolean isUnderOverRelation(String relationPath) {
    final Map<String, String> relationPathForeignAliasMap = getRelationPathForeignAliasMap();
    final String foreignAliasName = relationPathForeignAliasMap.get(relationPath);
    if (foreignAliasName == null) {
        // basically no way
        String msg = "Not found the foreign alias name by the relation path:";
        msg = msg + " " + relationPath + ", " + relationPathForeignAliasMap.keySet();
        throw new IllegalStateException(msg);
    }
    final Map<String, LeftOuterJoinInfo> outerJoinMap = getOuterJoinMap();
    final LeftOuterJoinInfo outerJoinInfo = outerJoinMap.get(foreignAliasName);
    if (outerJoinInfo == null) {
        // basically no way
        String msg = "Not found the outer join info by the foreign alias name:";
        msg = msg + " " + relationPath + ", " + foreignAliasName + ", " + outerJoinMap.keySet();
        throw new IllegalStateException(msg);
    }
    return outerJoinInfo.isUnderOverRelation();
}
Also used : LeftOuterJoinInfo(org.dbflute.cbean.sqlclause.join.LeftOuterJoinInfo)

Aggregations

LeftOuterJoinInfo (org.dbflute.cbean.sqlclause.join.LeftOuterJoinInfo)7 OrScopeQueryAndPartQueryClause (org.dbflute.cbean.sqlclause.query.OrScopeQueryAndPartQueryClause)1 QueryClause (org.dbflute.cbean.sqlclause.query.QueryClause)1 StringQueryClause (org.dbflute.cbean.sqlclause.query.StringQueryClause)1