Search in sources :

Example 1 with ReferrerInfo

use of org.dbflute.dbmeta.info.ReferrerInfo in project dbflute-core by dbflute.

the class AbstractDBMeta method cri.

protected // relation name
ReferrerInfo cri(// relation name
String constraintName, // relation name
String referrerPropertyName, // DB meta
DBMeta localDbm, // DB meta
DBMeta referrerDbm, // relation attribute
Map<ColumnInfo, ColumnInfo> localReferrerColumnInfoMap, // relation type and various info
boolean oneToOne, // relation type and various info
String reversePropertyName) {
    // createReferrerInfo()
    final Class<?> propertyAccessType = chooseReferrerPropertyAccessType(referrerDbm, oneToOne);
    final PropertyMethodFinder propertyMethodFinder = createReferrerPropertyMethodFinder();
    return new ReferrerInfo(constraintName, referrerPropertyName, localDbm, referrerDbm, localReferrerColumnInfoMap, propertyAccessType, oneToOne, reversePropertyName, propertyMethodFinder);
}
Also used : PropertyMethodFinder(org.dbflute.dbmeta.property.PropertyMethodFinder) ReferrerInfo(org.dbflute.dbmeta.info.ReferrerInfo)

Example 2 with ReferrerInfo

use of org.dbflute.dbmeta.info.ReferrerInfo in project dbflute-core by dbflute.

the class AbstractBehaviorReadable method doHelpLoadReferrerInternally.

protected <// generic
LOCAL_ENTITY extends Entity, // generic
KEY, // generic
REFERRER_CB extends ConditionBean, // generic
REFERRER_ENTITY extends Entity> NestedReferrerListGateway<REFERRER_ENTITY> doHelpLoadReferrerInternally(List<LOCAL_ENTITY> localEntityList, LoadReferrerOption<REFERRER_CB, REFERRER_ENTITY> loadReferrerOption, final String referrerProperty) {
    final DBMeta dbmeta = asDBMeta();
    final ReferrerInfo referrerInfo = dbmeta.findReferrerInfo(referrerProperty);
    final BehaviorReadable referrerBhv = xfindReferrerBehavior(referrerInfo);
    // might be unique key
    final Set<ColumnInfo> pkColSet = referrerInfo.getLocalReferrerColumnInfoMap().keySet();
    // key is referrer's
    final Map<ColumnInfo, ColumnInfo> mappingColMap = referrerInfo.getReferrerLocalColumnInfoMap();
    final InternalLoadReferrerCallback<LOCAL_ENTITY, KEY, REFERRER_CB, REFERRER_ENTITY> callback;
    if (pkColSet.size() == 1) {
        // simple key
        final ColumnInfo pkCol = pkColSet.iterator().next();
        final ColumnInfo fkCol = mappingColMap.keySet().iterator().next();
        callback = xcreateLoadReferrerCallback(referrerProperty, dbmeta, referrerInfo, referrerBhv, pkCol, fkCol);
    } else {
        // compound key
        final Set<ColumnInfo> fkColSet = mappingColMap.keySet();
        callback = xcreateLoadReferrerCallback(referrerProperty, dbmeta, referrerInfo, referrerBhv, pkColSet, fkColSet, mappingColMap);
    }
    return helpLoadReferrerInternally(localEntityList, loadReferrerOption, callback);
}
Also used : DBMeta(org.dbflute.dbmeta.DBMeta) ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo) ReferrerInfo(org.dbflute.dbmeta.info.ReferrerInfo)

Example 3 with ReferrerInfo

use of org.dbflute.dbmeta.info.ReferrerInfo in project dbflute-core by dbflute.

the class AbstractConditionQuery method xbuildReferrerCorrelatedFixedCondition.

protected String xbuildReferrerCorrelatedFixedCondition(ConditionQuery subQuery, String referrerPropertyName) {
    if (referrerPropertyName == null) {
        return null;
    }
    final DBMeta localDBMeta = xgetLocalDBMeta();
    if (!localDBMeta.hasReferrer(referrerPropertyName)) {
        // one-to-one referrer
        return null;
    }
    final ReferrerInfo referrerInfo = localDBMeta.findReferrerInfo(referrerPropertyName);
    return xdoBuildReferrerCorrelatedFixedCondition(subQuery, referrerInfo);
}
Also used : DBMeta(org.dbflute.dbmeta.DBMeta) ReferrerInfo(org.dbflute.dbmeta.info.ReferrerInfo)

Example 4 with ReferrerInfo

use of org.dbflute.dbmeta.info.ReferrerInfo in project dbflute-core by dbflute.

the class AbstractConditionQuery method xbuildForeignCorrelatedFixedCondition.

protected String xbuildForeignCorrelatedFixedCondition(ConditionQuery subQuery, String relationPropertyName) {
    if (relationPropertyName == null) {
        return null;
    }
    final DBMeta localDBMeta = xgetLocalDBMeta();
    final RelationInfo relationInfo = localDBMeta.findRelationInfo(relationPropertyName);
    if (!relationInfo.isReferrer()) {
        return null;
    }
    if (!(relationInfo instanceof ReferrerInfo)) {
        return null;
    }
    final ReferrerInfo referrerInfo = (ReferrerInfo) relationInfo;
    return xdoBuildReferrerCorrelatedFixedCondition(subQuery, referrerInfo);
}
Also used : DBMeta(org.dbflute.dbmeta.DBMeta) RelationInfo(org.dbflute.dbmeta.info.RelationInfo) ReferrerInfo(org.dbflute.dbmeta.info.ReferrerInfo)

Example 5 with ReferrerInfo

use of org.dbflute.dbmeta.info.ReferrerInfo in project dbflute-core by dbflute.

the class AbstractBehaviorReadable method xbuildReferrerCorrelatedFixedCondition.

protected String xbuildReferrerCorrelatedFixedCondition(ConditionBean cb, String referrerPropertyName) {
    if (referrerPropertyName == null) {
        return null;
    }
    final DBMeta localDBMeta = asDBMeta();
    if (!localDBMeta.hasReferrer(referrerPropertyName)) {
        // one-to-one referrer
        return null;
    }
    final ReferrerInfo referrerInfo = localDBMeta.findReferrerInfo(referrerPropertyName);
    return xdoBuildReferrerCorrelatedFixedCondition(cb, referrerInfo);
}
Also used : DBMeta(org.dbflute.dbmeta.DBMeta) ReferrerInfo(org.dbflute.dbmeta.info.ReferrerInfo)

Aggregations

ReferrerInfo (org.dbflute.dbmeta.info.ReferrerInfo)8 DBMeta (org.dbflute.dbmeta.DBMeta)4 Method (java.lang.reflect.Method)1 ColumnInfo (org.dbflute.dbmeta.info.ColumnInfo)1 RelationInfo (org.dbflute.dbmeta.info.RelationInfo)1 PropertyMethodFinder (org.dbflute.dbmeta.property.PropertyMethodFinder)1