Search in sources :

Example 1 with QueryUsedAliasInfo

use of org.dbflute.cbean.sqlclause.query.QueryUsedAliasInfo in project dbflute-core by dbflute.

the class AbstractConditionBean method xregisterColQyClause.

protected <CB extends ConditionBean> void xregisterColQyClause(QueryClause queryClause, final HpCalcSpecification<CB> leftCalcSp, final HpCalcSpecification<CB> rightCalcSp) {
    // /= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
    // may null-revived -> no way to be inner-join
    // (DerivedReferrer or conversion's coalesce)
    // 
    // for example, the following SQL is no way to be inner
    // (suppose if PURCHASE refers WITHDRAWAL)
    // 
    // select mb.MEMBER_ID, mb.MEMBER_NAME
    // , mb.MEMBER_STATUS_CODE, wd.MEMBER_ID as WD_MEMBER_ID
    // from MEMBER mb
    // left outer join MEMBER_SERVICE ser on mb.MEMBER_ID = ser.MEMBER_ID
    // left outer join MEMBER_WITHDRAWAL wd on mb.MEMBER_ID = wd.MEMBER_ID
    // where (select coalesce(max(pc.PURCHASE_PRICE), 0)
    // from PURCHASE pc
    // where pc.MEMBER_ID = wd.MEMBER_ID -- may null
    // ) < ser.SERVICE_POINT_COUNT
    // order by mb.MEMBER_ID
    // 
    // it has a possible to be inner-join in various case
    // but it is hard to analyze in detail so simplify it
    // = = = = = = = = = =/
    final QueryUsedAliasInfo leftInfo = xcreateColQyAliasInfo(leftCalcSp);
    final QueryUsedAliasInfo rightInfo = xcreateColQyAliasInfo(rightCalcSp);
    getSqlClause().registerWhereClause(queryClause, leftInfo, rightInfo);
}
Also used : QueryUsedAliasInfo(org.dbflute.cbean.sqlclause.query.QueryUsedAliasInfo)

Example 2 with QueryUsedAliasInfo

use of org.dbflute.cbean.sqlclause.query.QueryUsedAliasInfo in project dbflute-core by dbflute.

the class HpAbstractSpecification method reflectDreamCruiseWhereUsedToJoin.

protected void reflectDreamCruiseWhereUsedToJoin(String relationPath, String tableAliasName) {
    if (!_baseCB.xisDreamCruiseShip()) {
        return;
    }
    // to suppress CountLeastJoin of the relation
    // the DreamCruise might be used in where clause (not correctly but safety logic)
    final ConditionBean portCB = _baseCB.xgetDreamCruiseDeparturePort();
    final QueryUsedAliasInfo usedAliasInfo = new QueryUsedAliasInfo(tableAliasName, new InnerJoinNoWaySpeaker() {

        public boolean isNoWayInner() {
            // non fact of inner-join, because judge is so difficult when DreamCruise
            return true;
        }
    });
    portCB.getSqlClause().reflectWhereUsedToJoin(usedAliasInfo);
}
Also used : QueryUsedAliasInfo(org.dbflute.cbean.sqlclause.query.QueryUsedAliasInfo) ConditionBean(org.dbflute.cbean.ConditionBean) InnerJoinNoWaySpeaker(org.dbflute.cbean.sqlclause.join.InnerJoinNoWaySpeaker)

Example 3 with QueryUsedAliasInfo

use of org.dbflute.cbean.sqlclause.query.QueryUsedAliasInfo in project dbflute-core by dbflute.

the class AbstractSqlClause method registerWhereClause.

/**
 * {@inheritDoc}
 */
public void registerWhereClause(QueryClause clause, QueryUsedAliasInfo... usedAliasInfos) {
    assertObjectNotNull("clause", clause);
    assertObjectNotNull("usedAliasInfos", usedAliasInfos);
    if (usedAliasInfos.length == 0) {
        String msg = "The argument 'usedAliasInfos' should not be empty.";
        throw new IllegalArgumentException(msg);
    }
    final List<QueryClause> clauseList = getWhereClauseList4Register();
    doRegisterWhereClause(clauseList, clause);
    for (QueryUsedAliasInfo usedAliasInfo : usedAliasInfos) {
        reflectWhereUsedToJoin(usedAliasInfo);
    }
}
Also used : QueryUsedAliasInfo(org.dbflute.cbean.sqlclause.query.QueryUsedAliasInfo) QueryClause(org.dbflute.cbean.sqlclause.query.QueryClause) OrScopeQueryAndPartQueryClause(org.dbflute.cbean.sqlclause.query.OrScopeQueryAndPartQueryClause) StringQueryClause(org.dbflute.cbean.sqlclause.query.StringQueryClause)

Example 4 with QueryUsedAliasInfo

use of org.dbflute.cbean.sqlclause.query.QueryUsedAliasInfo in project dbflute-core by dbflute.

the class AbstractSqlClause method registerInnerJoinLazyReflector.

// -----------------------------------------------------
// InnerJoin Reflection
// --------------------
protected void registerInnerJoinLazyReflector(String usedAliasName) {
    // without no-way speaker
    if (isOutOfWhereUsedInnerJoin()) {
        return;
    }
    final QueryUsedAliasInfo usedAliasInfo = new QueryUsedAliasInfo(usedAliasName, null);
    registerInnerJoinLazyReflector(usedAliasInfo);
}
Also used : QueryUsedAliasInfo(org.dbflute.cbean.sqlclause.query.QueryUsedAliasInfo)

Example 5 with QueryUsedAliasInfo

use of org.dbflute.cbean.sqlclause.query.QueryUsedAliasInfo in project dbflute-core by dbflute.

the class AbstractConditionQuery method doRegisterScalarCondition.

protected <CB extends ConditionBean> void doRegisterScalarCondition(final String function, final ConditionQuery subQuery, String propertyName, String operand, final HpSLCCustomized<CB> after, ScalarConditionOption option) {
    assertSubQueryNotNull("ScalarCondition", propertyName, subQuery);
    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 PartitionByProvider partitionByProvider = () -> after.preparePartitionBySqlClause();
    final ScalarCondition scalarCondition = new ScalarCondition(subQueryPath, localRealNameProvider, subQuerySqlNameProvider, subQueryLevel, subQueryClause, subQueryIdentity, subQueryDBMeta, cipherManager, mainSubQueryIdentity, operand, partitionByProvider);
    xregisterParameterOption(option);
    final QueryClause clause = new QueryClause() {

        /* lazy registration to use partition-by */
        public String toString() {
            return scalarCondition.buildScalarCondition(function, option);
        }
    };
    // no speak about inner-join because of no possible of null revival
    final QueryUsedAliasInfo usedAliasInfo = new QueryUsedAliasInfo(xgetAliasName(), null);
    registerWhereClause(clause, usedAliasInfo);
}
Also used : ColumnRealNameProvider(org.dbflute.dbmeta.name.ColumnRealNameProvider) DerivedReferrerOptionFactory(org.dbflute.cbean.coption.DerivedReferrerOptionFactory) UnionClauseProvider(org.dbflute.cbean.sqlclause.union.UnionClauseProvider) SpecifiedColumn(org.dbflute.cbean.dream.SpecifiedColumn) ConditionKeyInScope(org.dbflute.cbean.ckey.ConditionKeyInScope) Date(java.util.Date) ParameterOption(org.dbflute.cbean.coption.ParameterOption) LoggerFactory(org.slf4j.LoggerFactory) OrderByElement(org.dbflute.cbean.sqlclause.orderby.OrderByElement) QueryClause(org.dbflute.cbean.sqlclause.query.QueryClause) ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) ColumnSqlNameProvider(org.dbflute.dbmeta.name.ColumnSqlNameProvider) SimpleMapPmb(org.dbflute.twowaysql.pmbean.SimpleMapPmb) ColumnRealName(org.dbflute.dbmeta.name.ColumnRealName) PrimaryInfo(org.dbflute.dbmeta.info.PrimaryInfo) OrScopeQueryAndPartUnsupportedOperationException(org.dbflute.exception.OrScopeQueryAndPartUnsupportedOperationException) Map(java.util.Map) HpInvalidQueryInfo(org.dbflute.cbean.chelper.HpInvalidQueryInfo) DfBeanDescFactory(org.dbflute.helper.beans.factory.DfBeanDescFactory) ManualOrderOption(org.dbflute.cbean.ordering.ManualOrderOption) ConditionOption(org.dbflute.cbean.coption.ConditionOption) FixedConditionLazyChecker(org.dbflute.cbean.sqlclause.join.FixedConditionLazyChecker) Method(java.lang.reflect.Method) RangeOfOption(org.dbflute.cbean.coption.RangeOfOption) DfCollectionUtil(org.dbflute.util.DfCollectionUtil) SubQuery(org.dbflute.cbean.scoping.SubQuery) TimeZone(java.util.TimeZone) IndependentProcessor(org.dbflute.helper.function.IndependentProcessor) Timestamp(java.sql.Timestamp) Collection(java.util.Collection) LikeSearchOption(org.dbflute.cbean.coption.LikeSearchOption) QueryModeProvider(org.dbflute.cbean.cvalue.ConditionValue.QueryModeProvider) FixedConditionResolver(org.dbflute.cbean.sqlclause.join.FixedConditionResolver) ScalarConditionOption(org.dbflute.cbean.coption.ScalarConditionOption) DBMeta(org.dbflute.dbmeta.DBMeta) FunCustodial(org.dbflute.FunCustodial) DfBeanDesc(org.dbflute.helper.beans.DfBeanDesc) Classification(org.dbflute.jdbc.Classification) List(java.util.List) ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo) ExistsReferrer(org.dbflute.cbean.sqlclause.subquery.ExistsReferrer) LocalDate(java.time.LocalDate) Entry(java.util.Map.Entry) SqlClauseMySql(org.dbflute.cbean.sqlclause.SqlClauseMySql) DBMetaProvider(org.dbflute.dbmeta.DBMetaProvider) DBFluteSystem(org.dbflute.system.DBFluteSystem) ColumnFunctionCipher(org.dbflute.cbean.cipher.ColumnFunctionCipher) DateConditionAdjuster(org.dbflute.cbean.garnish.datefitting.DateConditionAdjuster) ConditionKeyPrepareResult(org.dbflute.cbean.ckey.ConditionKeyPrepareResult) ScalarCondition(org.dbflute.cbean.sqlclause.subquery.ScalarCondition) HpFixedConditionQueryResolver(org.dbflute.cbean.chelper.HpFixedConditionQueryResolver) LocalDateTime(java.time.LocalDateTime) IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException) HashMap(java.util.HashMap) ReflectionFailureException(org.dbflute.util.DfReflectionUtil.ReflectionFailureException) DerivedReferrerOption(org.dbflute.cbean.coption.DerivedReferrerOption) ManualOrderOptionCall(org.dbflute.cbean.ordering.ManualOrderOptionCall) GearedCipherManager(org.dbflute.cbean.cipher.GearedCipherManager) ConditionInvokingFailureException(org.dbflute.exception.ConditionInvokingFailureException) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) SqlClauseOracle(org.dbflute.cbean.sqlclause.SqlClauseOracle) HpQDRSetupper(org.dbflute.cbean.chelper.HpQDRSetupper) ExtensionOperand(org.dbflute.dbway.ExtensionOperand) HpQDRParameter(org.dbflute.cbean.chelper.HpQDRParameter) PartitionByProvider(org.dbflute.cbean.sqlclause.subquery.ScalarCondition.PartitionByProvider) DfReflectionUtil(org.dbflute.util.DfReflectionUtil) QueryUsedAliasInfo(org.dbflute.cbean.sqlclause.query.QueryUsedAliasInfo) ShortCharHandlingMode(org.dbflute.jdbc.ShortCharHandlingMode) Srl(org.dbflute.util.Srl) QueryClauseArranger(org.dbflute.cbean.sqlclause.query.QueryClauseArranger) ColumnSqlName(org.dbflute.dbmeta.name.ColumnSqlName) ConditionValue(org.dbflute.cbean.cvalue.ConditionValue) RelationInfo(org.dbflute.dbmeta.info.RelationInfo) ForeignInfo(org.dbflute.dbmeta.info.ForeignInfo) FromToOption(org.dbflute.cbean.coption.FromToOption) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) HpSLCFunction(org.dbflute.cbean.chelper.HpSLCFunction) SpecifyDerivedReferrer(org.dbflute.cbean.sqlclause.subquery.SpecifyDerivedReferrer) WayOfMySQL(org.dbflute.dbway.WayOfMySQL) QueryDerivedReferrer(org.dbflute.cbean.sqlclause.subquery.QueryDerivedReferrer) ConditionKey(org.dbflute.cbean.ckey.ConditionKey) ConditionOptionCall(org.dbflute.cbean.coption.ConditionOptionCall) HpSLCCustomized(org.dbflute.cbean.chelper.HpSLCCustomized) ConditionBeanExceptionThrower(org.dbflute.cbean.exception.ConditionBeanExceptionThrower) HpDerivingSubQueryInfo(org.dbflute.cbean.chelper.HpDerivingSubQueryInfo) SubQueryPath(org.dbflute.cbean.sqlclause.subquery.SubQueryPath) ReferrerInfo(org.dbflute.dbmeta.info.ReferrerInfo) DfTypeUtil(org.dbflute.util.DfTypeUtil) HpQDRFunction(org.dbflute.cbean.chelper.HpQDRFunction) SqlClause(org.dbflute.cbean.sqlclause.SqlClause) InScopeRelation(org.dbflute.cbean.sqlclause.subquery.InScopeRelation) ColumnSqlNameProvider(org.dbflute.dbmeta.name.ColumnSqlNameProvider) QueryClause(org.dbflute.cbean.sqlclause.query.QueryClause) DBMeta(org.dbflute.dbmeta.DBMeta) SubQueryPath(org.dbflute.cbean.sqlclause.subquery.SubQueryPath) SqlClause(org.dbflute.cbean.sqlclause.SqlClause) ScalarCondition(org.dbflute.cbean.sqlclause.subquery.ScalarCondition) GearedCipherManager(org.dbflute.cbean.cipher.GearedCipherManager) QueryUsedAliasInfo(org.dbflute.cbean.sqlclause.query.QueryUsedAliasInfo) PartitionByProvider(org.dbflute.cbean.sqlclause.subquery.ScalarCondition.PartitionByProvider)

Aggregations

QueryUsedAliasInfo (org.dbflute.cbean.sqlclause.query.QueryUsedAliasInfo)5 QueryClause (org.dbflute.cbean.sqlclause.query.QueryClause)2 Method (java.lang.reflect.Method)1 Timestamp (java.sql.Timestamp)1 LocalDate (java.time.LocalDate)1 LocalDateTime (java.time.LocalDateTime)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 TimeZone (java.util.TimeZone)1 FunCustodial (org.dbflute.FunCustodial)1 ConditionBean (org.dbflute.cbean.ConditionBean)1 HpDerivingSubQueryInfo (org.dbflute.cbean.chelper.HpDerivingSubQueryInfo)1 HpFixedConditionQueryResolver (org.dbflute.cbean.chelper.HpFixedConditionQueryResolver)1