use of org.dbflute.cbean.sqlclause.SqlClause in project dbflute-core by dbflute.
the class HpDerivingSubQueryInfo method extractDerivingColumn.
// ===================================================================================
// Meta Provider
// =============
public SpecifiedColumn extractDerivingColumn() {
final SqlClause subQuerySqlClause = _derivedReferrer.getSubQuerySqlClause();
final SpecifiedColumn specifiedColumn = subQuerySqlClause.getSpecifiedColumnAsOne();
if (specifiedColumn != null) {
return specifiedColumn;
}
// nested
return subQuerySqlClause.getSpecifiedDerivingColumnAsOne();
}
use of org.dbflute.cbean.sqlclause.SqlClause in project dbflute-core by dbflute.
the class HpDerivingSubQueryInfo method extractDerivingColumnInfo.
public ColumnInfo extractDerivingColumnInfo() {
final SqlClause subQuerySqlClause = _derivedReferrer.getSubQuerySqlClause();
final ColumnInfo columnInfo = subQuerySqlClause.getSpecifiedColumnInfoAsOne();
if (columnInfo != null) {
return columnInfo;
}
// nested
return subQuerySqlClause.getSpecifiedDerivingColumnInfoAsOne();
}
use of org.dbflute.cbean.sqlclause.SqlClause in project dbflute-core by dbflute.
the class SpecifyColumnRequiredChecker method checkSpecifyColumnRequiredIfNeeds.
// ===================================================================================
// Check
// =====
public void checkSpecifyColumnRequiredIfNeeds(ConditionBean cb, Consumer<Set<String>> thrower) {
// cannot embed this to SQL clause because of too complex
// so simple implementation like this:
final SqlClause sqlClause = cb.getSqlClause();
final Set<String> nonSpecifiedAliasSet = new LinkedHashSet<>();
doCheckBasePointTable(cb, sqlClause, nonSpecifiedAliasSet);
doCheckRelationTable(sqlClause, nonSpecifiedAliasSet);
if (!nonSpecifiedAliasSet.isEmpty()) {
handleNonSpecified(thrower, nonSpecifiedAliasSet);
}
}
use of org.dbflute.cbean.sqlclause.SqlClause in project dbflute-core by dbflute.
the class SelectCBExecution method processPagingSelectAndQuerySplit.
// ===================================================================================
// Paging Select and Query Split
// =============================
protected Object processPagingSelectAndQuerySplit(Object[] args, ConditionBean cb) {
if (!cb.canPagingSelectAndQuerySplit()) {
return null;
}
if (!cb.isFetchScopeEffective()) {
return null;
}
final DBMeta dbmeta = cb.asDBMeta();
final PrimaryInfo primaryInfo = dbmeta.getPrimaryInfo();
if (primaryInfo.isCompoundKey()) {
// basically no way, already checked
return null;
}
final ColumnInfo pkColumn = primaryInfo.getFirstColumn();
final SqlClause sqlClause = cb.getSqlClause();
final List<Object> pkList = doSplitSelectFirst(args, cb, dbmeta, sqlClause);
if (pkList == null) {
// no way just in case
return null;
}
if (pkList.isEmpty()) {
return pkList;
}
return doSplitSelectSecond(args, cb, pkColumn, sqlClause, pkList);
}
use of org.dbflute.cbean.sqlclause.SqlClause in project dbflute-core by dbflute.
the class AbstractConditionQuery method doRegisterSpecifyDerivedReferrer.
protected void doRegisterSpecifyDerivedReferrer(String function, final ConditionQuery subQuery, String columnDbName, String relatedColumnDbName, String propertyName, String referrerPropertyName, String aliasName, DerivedReferrerOption option) {
assertFunctionNotNull("SpecifyDerivedReferrer", columnDbName, function);
assertSubQueryNotNull("SpecifyDerivedReferrer", columnDbName, subQuery);
option.xacceptBaseCB(xgetBaseCB());
if (isDerivedReferrerSelectAllPossible(subQuery, option)) {
createCBExThrower().throwSpecifyDerivedReferrerSelectAllPossibleException(function, subQuery, aliasName);
}
final SubQueryPath subQueryPath = new SubQueryPath(xgetLocation(propertyName));
final GeneralColumnRealNameProvider localRealNameProvider = new GeneralColumnRealNameProvider();
final int subQueryLevel = subQuery.xgetSqlClause().getSubQueryLevel();
final SqlClause subQueryClause = subQuery.xgetSqlClause();
final String subQueryIdentity = propertyName + "[" + subQueryLevel + "]";
final ColumnSqlNameProvider subQuerySqlNameProvider = dbName -> subQuery.toColumnSqlName(dbName);
final DBMeta subQueryDBMeta = findDBMeta(subQuery.asTableDbName());
final GearedCipherManager cipherManager = xgetSqlClause().getGearedCipherManager();
final String mainSubQueryIdentity = propertyName + "[" + subQueryLevel + ":subquerymain]";
final SpecifyDerivedReferrer derivedReferrer = option.createSpecifyDerivedReferrer(subQueryPath, localRealNameProvider, subQuerySqlNameProvider, subQueryLevel, subQueryClause, subQueryIdentity, subQueryDBMeta, cipherManager, mainSubQueryIdentity, aliasName);
xregisterParameterOption(option);
final String correlatedFixedCondition = xbuildReferrerCorrelatedFixedCondition(subQuery, referrerPropertyName);
final String clause = derivedReferrer.buildDerivedReferrer(function, columnDbName, relatedColumnDbName, correlatedFixedCondition, option);
final HpDerivingSubQueryInfo subQueryInfo = xcreateDerivingSubQueryInfo(function, aliasName, clause, derivedReferrer);
xgetSqlClause().specifyDerivingSubQuery(subQueryInfo);
}
Aggregations