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;
}
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);
}
}
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;
}
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);
}
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);
}
Aggregations