use of org.dbflute.dbmeta.info.ForeignInfo in project dbflute-core by dbflute.
the class AbstractDBMeta method findForeignInfo.
/**
* {@inheritDoc}
*/
public ForeignInfo findForeignInfo(String foreignPropertyName) {
assertStringNotNullAndNotTrimmedEmpty("foreignPropertyName", foreignPropertyName);
final Map<String, ForeignInfo> flexibleMap = getForeignInfoFlexibleMap();
final ForeignInfo foreignInfo = flexibleMap.get(foreignPropertyName);
if (foreignInfo == null) {
final String notice = "The foreign info was not found.";
final String keyName = "Foreign Property";
throwDBMetaNotFoundException(notice, keyName, foreignPropertyName, flexibleMap.keySet());
}
return foreignInfo;
}
use of org.dbflute.dbmeta.info.ForeignInfo in project dbflute-core by dbflute.
the class AbstractConditionQuery method xregOutJo.
protected void xregOutJo(String prop) {
// should be called after registration
if (_queryRelationKeepingMap == null) {
// no way, just in case
_queryRelationKeepingMap = newLinkedHashMapSized(4);
}
final ConditionQuery cq = _queryRelationKeepingMap.get(prop);
if (cq == null) {
// no way, just in case
String msg = "Not found the condition-query for (Query)Relation: " + prop;
throw new IllegalStateException(msg);
}
final ForeignInfo foreignInfo = xgetLocalDBMeta().findForeignInfo(prop);
final Map<ColumnInfo, ColumnInfo> localForeignColMap = foreignInfo.getLocalForeignColumnInfoMap();
final Map<String, String> joinOnMap = newLinkedHashMapSized(localForeignColMap.size());
for (Entry<ColumnInfo, ColumnInfo> entry : localForeignColMap.entrySet()) {
final ColumnInfo localCol = entry.getKey();
final ColumnInfo foreignCol = entry.getValue();
joinOnMap.put(localCol.getColumnDbName(), foreignCol.getColumnDbName());
}
registerOuterJoin(cq, joinOnMap, prop);
}
use of org.dbflute.dbmeta.info.ForeignInfo 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);
}
use of org.dbflute.dbmeta.info.ForeignInfo in project dbflute-core by dbflute.
the class AbstractConditionQuery method registerOuterJoin.
// ===================================================================================
// Outer Join
// ==========
/**
* Register outer-join. <br>
* Optional info, fixed condition and fixed in-line, are resolved in this method.
* @param foreignCQ The condition-query for foreign table. (NotNull)
* @param joinOnResourceMap The resource map of join condition on on-clause. (NotNull)
* @param foreignPropertyName The property name of foreign relation corresponding to this join. (NotNull)
*/
protected void registerOuterJoin(ConditionQuery foreignCQ, Map<String, String> joinOnResourceMap, String foreignPropertyName) {
final DBMeta dbmeta = xgetLocalDBMeta();
final ForeignInfo foreignInfo = dbmeta.findForeignInfo(foreignPropertyName);
doRegisterOuterJoin(foreignCQ, joinOnResourceMap, foreignPropertyName, foreignInfo);
}
use of org.dbflute.dbmeta.info.ForeignInfo in project dbflute-core by dbflute.
the class TnDBMetaBeanAnnotationReader method getRelationKey.
public String getRelationKey(DfPropertyDesc pd) {
if (_simpleType) {
return null;
}
if (_fieldBeanAnnotationReader != null) {
return _fieldBeanAnnotationReader.getRelationKey(pd);
}
if (!_dbmeta.hasForeign(pd.getPropertyName())) {
return null;
}
final ForeignInfo foreignInfo = _dbmeta.findForeignInfo(pd.getPropertyName());
final Map<ColumnInfo, ColumnInfo> localForeignColumnInfoMap = foreignInfo.getLocalForeignColumnInfoMap();
final Set<ColumnInfo> keySet = localForeignColumnInfoMap.keySet();
final StringBuilder sb = new StringBuilder();
for (ColumnInfo localColumnInfo : keySet) {
final ColumnInfo foreignColumnInfo = localForeignColumnInfoMap.get(localColumnInfo);
if (sb.length() > 0) {
sb.append(", ");
}
sb.append(localColumnInfo.getColumnDbName());
sb.append(":").append(foreignColumnInfo.getColumnDbName());
}
return sb.toString();
}
Aggregations