use of org.dbflute.dbmeta.name.ColumnRealName in project dbflute-core by dbflute.
the class DerivedReferrer method setupUnionMainForFixedCondition.
protected void setupUnionMainForFixedCondition(StringBuilder keySb, String tableAliasName, ColumnSqlName derivedColumnSqlName) {
// all columns because fixed condition might contain them
final List<ColumnInfo> columnInfoList = _subQueryDBMeta.getColumnInfoList();
for (ColumnInfo columnInfo : columnInfoList) {
final ColumnSqlName sqlName = columnInfo.getColumnSqlName();
if (sqlName.equals(derivedColumnSqlName)) {
// to suppress same columns selected
continue;
}
final ColumnRealName realName = ColumnRealName.create(tableAliasName, columnInfo.getColumnSqlName());
keySb.append(keySb.length() > 0 ? ", " : "");
keySb.append(realName);
}
}
use of org.dbflute.dbmeta.name.ColumnRealName in project dbflute-core by dbflute.
the class DerivedReferrer method buildSubQueryClause.
// ===================================================================================
// (Single PrimaryKey) SubQuery Clause
// ===================================
/**
* Build the clause of sub-query by single primary key.
* @param function The expression for deriving function. (NotNull)
* @param correlatedColumnRealName The real names of correlated column that is main-query table's column. (NotNull)
* @param relatedColumnSqlName The real names of related column that is sub-query table's column. (NotNull)
* @param correlatedFixedCondition The fixed condition as correlated condition. (NullAllowed)
* @param option The option of DerivedReferrer. (NotNull)
* @return The clause of sub-query. (NotNull)
*/
protected String buildSubQueryClause(String function, ColumnRealName correlatedColumnRealName, ColumnSqlName relatedColumnSqlName, String correlatedFixedCondition, DerivedReferrerOption option) {
final String tableAliasName = getSubQueryLocalAliasName();
final ColumnSqlName derivedColumnSqlName = getDerivedColumnSqlName();
if (derivedColumnSqlName == null) {
throwDerivedReferrerInvalidColumnSpecificationException(function);
}
final ColumnRealName derivedColumnRealName = getDerivedColumnRealName();
final String subQueryClause;
if (_subQuerySqlClause.hasUnionQuery()) {
subQueryClause = buildUnionSubQueryClause(function, correlatedColumnRealName, relatedColumnSqlName, option, tableAliasName, derivedColumnRealName, derivedColumnSqlName, correlatedFixedCondition);
} else {
final String selectClause = "select " + buildFunctionPart(function, derivedColumnRealName, option, false);
final String fromWhereClause;
if (option.isSuppressCorrelation()) {
// e.g. myselfDerived
fromWhereClause = buildPlainFromWhereClause(selectClause, tableAliasName, correlatedFixedCondition);
} else {
// basically here
fromWhereClause = buildCorrelationFromWhereClause(selectClause, tableAliasName, correlatedColumnRealName, relatedColumnSqlName, correlatedFixedCondition);
}
subQueryClause = selectClause + " " + fromWhereClause;
}
return resolveSubQueryLevelVariable(subQueryClause);
}
use of org.dbflute.dbmeta.name.ColumnRealName in project dbflute-core by dbflute.
the class AbstractConditionQuery method registerOrderBy.
// ===================================================================================
// Order By
// ========
// -----------------------------------------------------
// Basic
// -----
protected void registerOrderBy(String columnDbName, boolean ascOrDesc) {
final DBMeta dbmeta = xgetLocalDBMeta();
final ColumnInfo columnInfo = dbmeta.findColumnInfo(columnDbName);
final ColumnRealName columnRealName = toColumnRealName(columnInfo);
xgetSqlClause().registerOrderBy(columnRealName.toString(), ascOrDesc, columnInfo);
}
use of org.dbflute.dbmeta.name.ColumnRealName in project dbflute-core by dbflute.
the class AbstractConditionQuery method setupConditionValueAndRegisterWhereClause.
protected void setupConditionValueAndRegisterWhereClause(ConditionKey key, Object value, ConditionValue cvalue, String columnDbName, ConditionOption option) {
final DBMeta dbmeta = xgetLocalDBMeta();
final ColumnInfo columnInfo = dbmeta.findColumnInfo(columnDbName);
final QueryModeProvider queryModeProvider = xcreateQueryModeProvider();
final Object filtered = filterConditionValueIfNeeds(key, value, cvalue, columnDbName, option, columnInfo);
final String propertyName = columnInfo.getPropertyName();
final String uncapPropName = initUncap(propertyName);
// if Java, it is necessary to use uncapPropName
final String location = xgetLocation(uncapPropName);
key.setupConditionValue(queryModeProvider, cvalue, filtered, location, option);
final ColumnRealName columnRealName = toColumnRealName(columnDbName);
final ColumnFunctionCipher cipher = xgetSqlClause().findColumnFunctionCipher(columnInfo);
final String usedAliasName = xgetAliasName();
xgetSqlClause().registerWhereClause(columnRealName, key, cvalue, cipher, option, usedAliasName);
}
use of org.dbflute.dbmeta.name.ColumnRealName 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);
}
Aggregations