Search in sources :

Example 1 with FixedConditionResolver

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

the class AbstractConditionQuery method doRegisterOuterJoin.

protected void doRegisterOuterJoin(ConditionQuery foreignCQ, Map<String, String> joinOnResourceMap, final String foreignPropertyName, ForeignInfo foreignInfo) {
    // translate join-on map using column real name
    final Map<ColumnRealName, ColumnRealName> joinOnMap = newLinkedHashMap();
    for (Entry<String, String> entry : joinOnResourceMap.entrySet()) {
        final String local = entry.getKey();
        final String foreign = entry.getValue();
        joinOnMap.put(toColumnRealName(local), foreignCQ.toColumnRealName(foreign));
    }
    final String foreignAlias = foreignCQ.xgetAliasName();
    final String foreignTable = foreignCQ.asTableDbName();
    final String localAlias = xgetAliasName();
    final String localTable = asTableDbName();
    final String fixedCondition = foreignInfo.getFixedCondition();
    final boolean fixedInline = foreignInfo.isFixedInline();
    final FixedConditionResolver resolver = createForeignFixedConditionResolver(foreignCQ);
    final String relationPath = foreignCQ.xgetRelationPath();
    if (fixedInline) {
        // basic
        xgetSqlClause().registerOuterJoinFixedInline(// basic
        foreignAlias, // basic
        foreignTable, // basic
        localAlias, // basic
        localTable, // join objects
        joinOnMap, // join objects
        relationPath, // join objects
        foreignInfo, fixedCondition, // fixed condition (to in-line view)
        resolver);
    } else {
        // normally here
        // basic
        xgetSqlClause().registerOuterJoin(// basic
        foreignAlias, // basic
        foreignTable, // basic
        localAlias, // basic
        localTable, // join objects
        joinOnMap, // join objects
        relationPath, // join objects
        foreignInfo, fixedCondition, // fixed condition (to on-clause)
        resolver);
    }
    xprepareFixedConditionDynamicParameterLazyChecker(foreignPropertyName, foreignInfo);
}
Also used : FixedConditionResolver(org.dbflute.cbean.sqlclause.join.FixedConditionResolver) ColumnRealName(org.dbflute.dbmeta.name.ColumnRealName)

Example 2 with FixedConditionResolver

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

the class AbstractConditionQuery method xdoBuildReferrerCorrelatedFixedCondition.

protected String xdoBuildReferrerCorrelatedFixedCondition(ConditionQuery subQuery, ReferrerInfo referrerInfo) {
    final RelationInfo reverseRelation = referrerInfo.getReverseRelation();
    if (reverseRelation == null) {
        return null;
    }
    if (!(reverseRelation instanceof ForeignInfo)) {
        String msg = "The reverse relation (referrer's reverse) should be foreign info: " + referrerInfo;
        throw new IllegalStateException(msg);
    }
    final ForeignInfo foreignInfo = (ForeignInfo) reverseRelation;
    final String fixedCondition = foreignInfo.getFixedCondition();
    if (fixedCondition == null || fixedCondition.trim().length() == 0) {
        return null;
    }
    final FixedConditionResolver resolver = createReferrerFixedConditionResolver(subQuery);
    return resolver.resolveVariable(fixedCondition, false);
}
Also used : ForeignInfo(org.dbflute.dbmeta.info.ForeignInfo) FixedConditionResolver(org.dbflute.cbean.sqlclause.join.FixedConditionResolver) RelationInfo(org.dbflute.dbmeta.info.RelationInfo)

Aggregations

FixedConditionResolver (org.dbflute.cbean.sqlclause.join.FixedConditionResolver)2 ForeignInfo (org.dbflute.dbmeta.info.ForeignInfo)1 RelationInfo (org.dbflute.dbmeta.info.RelationInfo)1 ColumnRealName (org.dbflute.dbmeta.name.ColumnRealName)1