Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   /*
    * Copyright 2014-2015 the original author or authors.
    *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
    *
    *     http://www.apache.org/licenses/LICENSE-2.0
    *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
   * either express or implied. See the License for the specific language
   * governing permissions and limitations under the License.
   */
  package org.dbflute.cbean;
  
  import java.util.List;
  import java.util.Map;
  import java.util.Set;
  
The condition-bean as abstract.

Author(s):
jflute
  
  public abstract class AbstractConditionBean implements ConditionBean {
  
      // ===================================================================================
      //                                                                           Attribute
      //                                                                           =========
      // -----------------------------------------------------
     //                                             SqlClause
     //                                             ---------
     
SQL clause instance.
 
     protected final SqlClause _sqlClause;
     {
          = createSqlClause();
     }
 
     // -----------------------------------------------------
     //                                                Paging
     //                                                ------
     
Is the count executed later? {Internal}
 
     protected boolean _pagingCountLater// the default is on the DBFlute generator (true @since 0.9...)
 
    
Can the paging re-select? {Internal}
 
     protected boolean _pagingReSelect = true// fixedly true as default
 
    
Does it split SQL execution as select and query? {Internal}
 
     protected boolean _pagingSelectAndQuerySplit;
 
     // -----------------------------------------------------
     //                                                 Union
     //                                                 -----
     
The list of condition-bean for union. {Internal} (NullAllowed)
 
     protected List<ConditionBean_unionCBeanList;

    
The synchronizer of union query. {Internal} (NullAllowed)
 
 
     // -----------------------------------------------------
     //                                          Purpose Type
     //                                          ------------
     
The purpose of condition-bean. (NotNull)
 
     protected HpCBPurpose _purpose = .// as default
 
    
Is the condition-bean locked? e.g. true if in sub-query process
 
     protected boolean _locked;
 
     // -----------------------------------------------------
     //                                          Dream Cruise
     //                                          ------------
     
Is this condition-bean departure port for dream cruise?
 
     protected boolean _departurePortForDreamCruise;

    
The departure port (base point condition-bean) of dream cruise. (used when dream cruise) (NullAllowed)
 
     protected ConditionBean _dreamCruiseDeparturePort;

    
The ticket (specified column) of dream cruise. (used when dream cruise) (NullAllowed)
 
     protected SpecifiedColumn _dreamCruiseTicket;

    
The journey log book (relation path) of dream cruise. (used when dream cruise) (NullAllowed)
 
     protected List<String_dreamCruiseJourneyLogBook;

    
The binding value or dream cruise ticket for mystic binding. (NullAllowed)
 
     protected Object _mysticBinding;
 
     // -----------------------------------------------------
     //                                        Various Option
     //                                        --------------
     
The max result size of safety select. {Internal}
 
     protected int _safetyMaxResultSize;

    
The option of cursor select. {Internal} (NullAllowed)
 
     protected CursorSelectOption _cursorSelectOption// set by sub-class
 
    
The configuration of statement. {Internal} (NullAllowed)
 
     protected StatementConfig _statementConfig;

    
Can the relation mapping (entity instance) be cached? {Internal}
 
     protected boolean _canRelationMappingCache = true// fixedly true as default
 
    
Does it allow access to non-specified column? {Internal}
 
     protected boolean _nonSpecifiedColumnAccessAllowed// the default is on the DBFlute generator (false @since 1.1)
 
    
Does it allow selecting undefined classification code? {Internal}
 
     protected boolean _undefinedClassificationSelectAllowed;

    
Does it check record count before QueryUpdate? (contains QueryDelete) {Internal}
 
     protected boolean _queryUpdateCountPreCheck;

    
The handler of derived type. {Internal} (NullAllowed: lazy-loaded)
 
     protected DerivedTypeHandler _derivedTypeHandler;

    
The display style of date for logging, overriding default style. (NullAllowed: configured default style)
 
 
     // ===================================================================================
     //                                                                           SqlClause
     //                                                                           =========
     
 
     public SqlClause getSqlClause() {
         return ;
     }

    
Create SQL clause. {for condition-bean}

Returns:
SQL clause. (NotNull)
 
     protected abstract SqlClause createSqlClause();
 
     // ===================================================================================
     //                                                                             DB Meta
     //                                                                             =======
     
 
     public DBMeta asDBMeta() { // not to depend on concrete entity (but little merit any more?)
     }

    
Get the provider of DB meta.

Returns:
The provider of DB meta. (NotNull)
 
     protected abstract DBMetaProvider getDBMetaProvider();
 
     // ===================================================================================
     //                                                                        Setup Select
     //                                                                        ============
     protected void doSetupSelect(SsCall callback) {
         final String foreignPropertyName = callback.qf().xgetForeignPropertyName();
         // allowed since 0.9.9.4C but basically SetupSelect should be called before Union
         // (basically for DBFlute internal operation, Dream Cruise)
         //assertSetupSelectBeforeUnion(foreignPropertyName);
         final String foreignTableAliasName = callback.qf().xgetAliasName();
         final String localRelationPath = localCQ().xgetRelationPath();
         final String foreignRelationPath = callback.qf().xgetRelationPath();
         getSqlClause().registerSelectedRelation(foreignTableAliasNameasTableDbName(), foreignPropertyNamelocalRelationPath,
                 foreignRelationPath);
     }
 
     protected static interface SsCall {
         public ConditionQuery qf();
     }
 
     protected void assertSetupSelectPurpose(String foreignPropertyName) { // called by setupSelect_...() of sub-class
         if (.isNoSetupSelect()) {
             final String titleName = DfTypeUtil.toClassTitle(this);
             throwSetupSelectIllegalPurposeException(titleNameforeignPropertyName);
         }
         if (isLocked()) {
             createCBExThrower().throwSetupSelectThatsBadTimingException(thisforeignPropertyName);
         }
     }
 
     protected void throwSetupSelectIllegalPurposeException(String classNameString foreignPropertyName) {
         createCBExThrower().throwSetupSelectIllegalPurposeException(thisforeignPropertyName);
     }
 
     // unused because it has been allowed
     //protected void assertSetupSelectBeforeUnion(String foreignPropertyName) {
     //    if (hasUnionQueryOrUnionAllQuery()) {
     //        throwSetupSelectAfterUnionException(foreignPropertyName);
     //    }
     //}
     //
     //protected void throwSetupSelectAfterUnionException(String foreignPropertyName) {
     //    createCBExThrower().throwSetupSelectAfterUnionException(this, foreignPropertyName);
     //}
 
     // [DBFlute-0.9.5.3]
     // ===================================================================================
     //                                                                             Specify
     //                                                                             =======
     protected <CQ extends ConditionQueryHpSpQyCall<CQ> xcreateSpQyCall(HpSpQyHas<CQ> hasHpSpQyQy<CQ> qy) {
         return new HpSpQyDelegatingCall<CQ>(hasqy);
     }
 
     protected void assertSpecifyPurpose() { // called by specify() of sub-class
         if (.isNoSpecify()) {
             throwSpecifyIllegalPurposeException();
         }
         if (isLocked() && !xisDreamCruiseShip()) { // DreamCruise might call specify() and query()
         }
     }
 
     protected void throwSpecifyIllegalPurposeException() {
     }
 
     @Deprecated
     public boolean hasSpecifiedColumn() {
         return hasSpecifiedLocalColumn();
     }
 
     // ===================================================================================
     //                                                                               Query
     //                                                                               =====
     protected void assertQueryPurpose() { // called by query() of sub-class and other queries
         if (.isNoQuery()) {
             throwQueryIllegalPurposeException();
         }
         if (isLocked()) {
             createCBExThrower().throwQueryThatsBadTimingException(this);
         }
     }
 
     protected void throwQueryIllegalPurposeException() {
     }
 
     // -----------------------------------------------------
     //                                  InnerJoin AutoDetect
     //                                  --------------------
     
 
     public void enableInnerJoinAutoDetect() {
     }

    
 
     public void disableInnerJoinAutoDetect() {
     }
 
     // [DBFlute-0.9.5.3]
     // ===================================================================================
     //                                                                        Column Query
     //                                                                        ============
     protected <CB extends ConditionBeanColumnCalculator xcolqy(CB leftCB, CB rightCBSpecifyQuery<CB> leftSpSpecifyQuery<CB> rightSp,
             final String operand) {
         assertQueryPurpose();
 
         final HpCalcSpecification<CB> leftCalcSp = xcreateCalcSpecification(leftSp);
         leftCalcSp.specify(leftCB);
         final String leftColumn = xbuildColQyLeftColumn(leftCBleftCalcSp);
 
         final HpCalcSpecification<CB> rightCalcSp = xcreateCalcSpecification(rightSp);
         rightCalcSp.specify(rightCB);
         final String rightColumn = xbuildColQyRightColumn(rightCBrightCalcSp);
         rightCalcSp.setLeftCalcSp(leftCalcSp);
 
         final QueryClause queryClause = xcreateColQyClause(leftColumnoperandrightColumnrightCalcSp);
         xregisterColQyClause(queryClauseleftCalcSprightCalcSp);
         return rightCalcSp;
     }
 
     // -----------------------------------------------------
     //                                   Create ColQyOperand
     //                                   -------------------
     protected <CB extends ConditionBeanHpColQyOperand<CB> xcreateColQyOperand(HpColQyHandler<CB> handler) {
         return new HpColQyOperand<CB>(handler);
     }
 
         return new HpColQyOperand.HpExtendedColQyOperandMySql<CB>(handler);
     }
 
     // -----------------------------------------------------
     //                                     Build ColQyColumn
     //                                     -----------------
     protected <CB extends ConditionBeanString xbuildColQyLeftColumn(CB leftCBHpCalcSpecification<CB> leftCalcSp) {
         final ColumnRealName realName = xextractColQyColumnRealName(leftCBleftCalcSp);
         return xbuildColQyColumn(leftCBrealName.toString(), "left");
     }
 
     protected <CB extends ConditionBeanString xbuildColQyRightColumn(CB rightCBHpCalcSpecification<CB> rightCalcSp) {
         final ColumnRealName realName = xextractColQyColumnRealName(rightCBrightCalcSp);
         return xbuildColQyColumn(rightCBrealName.toString(), "right");
     }
 
     protected <CB extends ConditionBeanColumnRealName xextractColQyColumnRealName(CB cbHpCalcSpecification<CB> calcSp) {
         final Object mysticBinding = cb.xgetMysticBinding();
         if (mysticBinding != null) {
             calcSp.setMysticBindingSnapshot(mysticBinding);
             return xdoExtractColQyColumnMysticBinding(cbmysticBinding);
         }
         return xdoExtractColQyColumnSpecifiedColumn(calcSp);
     }
 
     protected <CB extends ConditionBeanColumnRealName xdoExtractColQyColumnMysticBinding(CB cbfinal Object mysticBinding) {
         final String exp = cb.getSqlClause().registerFreeParameterToThemeList("mystic"mysticBinding);
         return ColumnRealName.create(nullnew ColumnSqlName(exp));
     }
 
     protected <CB extends ConditionBeanColumnRealName xdoExtractColQyColumnSpecifiedColumn(HpCalcSpecification<CB> calcSp) {
         final ColumnRealName realName = calcSp.getResolvedSpecifiedColumnRealName();
         if (realName == null) {
         }
         return realName;
     }
 
     protected <CB extends ConditionBeanString xbuildColQyColumn(CB cbString sourceString themeKey) {
         final String bindingExp = getSqlClause().registerColumnQueryObjectToThemeList(themeKeycb);
         return Srl.replace(source"/*pmb.conditionQuery."bindingExp);
     }
 
     protected <CB extends ConditionBeanHpCalcSpecification<CB> xcreateCalcSpecification(SpecifyQuery<CB> calcSp) {
         return xnewCalcSpecification(calcSpthis);
     }
 
     protected <CB extends ConditionBeanHpCalcSpecification<CB> xnewCalcSpecification(SpecifyQuery<CB> calcSpConditionBean baseCB) {
         return new HpCalcSpecification<CB>(calcSpbaseCB);
     }
 
     // -----------------------------------------------------
     //                                    Create ColQyClause
     //                                    ------------------
     protected <CB extends ConditionBeanQueryClause xcreateColQyClause(final String leftColumnfinal String operand,
             final String rightColumnfinal HpCalcSpecification<CB> rightCalcSp) {
         return new QueryClause() {
             @Override
             public String toString() {
                 final String leftExp = resolveColumnExp(rightCalcSp.getLeftCalcSp(), leftColumn);
                 final String rightExp = resolveColumnExp(rightCalcSprightColumn);
                 return xbuildColQyClause(leftExpoperandrightExp);
             }
 
             protected String resolveColumnExp(HpCalcSpecification<CB> calcSpString columnExp) {
                 final String resolvedExp;
                 if (calcSp != null) {
                     final String statement = calcSp.buildStatementToSpecifidName(columnExp);
                     if (statement != null) { // exists calculation
                         assertCalculationColumnType(calcSp);
                         resolvedExp = statement// cipher already resolved
                     } else {
                         final ColumnInfo columnInfo = calcSp.getSpecifiedColumnInfo();
                         if (columnInfo != null) { // means plain column
                             resolvedExp = decryptIfNeeds(columnInfocolumnExp);
                         } else { // deriving sub-query
                             resolvedExp = columnExp;
                         }
                     }
                 } else {
                     resolvedExp = columnExp;
                 }
                 return resolvedExp;
             }
 
             protected void assertCalculationColumnType(HpCalcSpecification<CB> calcSp) {
                 if (calcSp.hasConvert()) {
                     return// because it may be Date type
                 }
                 final ColumnInfo columnInfo = calcSp.getResolvedSpecifiedColumnInfo();
                 if (columnInfo != null) { // basically true but checked just in case
                     if (!columnInfo.isObjectNativeTypeNumber()) {
                         // *simple message because other types may be supported at the future
                         String msg = "Not number column specified: " + columnInfo;
                         throw new ColumnQueryCalculationUnsupportedColumnTypeException(msg);
                     }
                 }
             }
         };
     }
 
     protected String xbuildColQyClause(String leftExpString operandString rightExp) { // can be overridden just in case
         final StringBuilder sb = new StringBuilder();
         if (hasSubQueryEndOnLastLine(leftExp)) {
             if (hasSubQueryEndOnLastLine(rightExp)) { // (sub-query = sub-query)
                 // add line separator before right expression
                 // because of independent format for right query
                 sb.append(reflectToSubQueryEndOnLastLine(leftExp" " + operand + " "));
                 sb.append(ln()).append("       ").append(rightExp);
             } else { // (sub-query = column)
                 sb.append(reflectToSubQueryEndOnLastLine(leftExp" " + operand + " " + rightExp));
             }
         } else { // (column = sub-query) or (column = column) 
             sb.append(leftExp).append(" ").append(operand).append(" ").append(rightExp);
         }
         return sb.toString();
     }
 
     protected boolean hasSubQueryEndOnLastLine(String columnExp) {
         return SubQueryIndentProcessor.hasSubQueryEndOnLastLine(columnExp);
     }
 
     protected String reflectToSubQueryEndOnLastLine(String columnExpString inserted) {
         return SubQueryIndentProcessor.moveSubQueryEndToRear(columnExp + inserted);
     }
 
     protected <CB extends ConditionBeanvoid xregisterColQyClause(QueryClause queryClausefinal 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(queryClauseleftInforightInfo);
     }
 
     protected <CB extends ConditionBeanQueryUsedAliasInfo xcreateColQyAliasInfo(final HpCalcSpecification<CB> calcSp) {
         final String usedAliasName = calcSp.getResolvedSpecifiedTableAliasName();
         return new QueryUsedAliasInfo(usedAliasNamenew InnerJoinNoWaySpeaker() {
             public boolean isNoWayInner() {
                 return calcSp.mayNullRevived();
             }
         });
     }
 
     // [DBFlute-0.9.9.4C]
     // ===================================================================================
     //                                                                        Dream Cruise
     //                                                                        ============
     
 
     public void overTheWaves(SpecifiedColumn dreamCruiseTicket) {
         if (dreamCruiseTicket == null) {
             String msg = "The argument 'dreamCruiseColumn' should not be null.";
             throw new IllegalArgumentException(msg);
         }
         if ( != null) {
             String msg = "The other dream cruise ticket already exists: " + ;
             throw new IllegalConditionBeanOperationException(msg);
         }
         if (!dreamCruiseTicket.isDreamCruiseTicket()) {
             String msg = "The specified column was not dream cruise ticket: " + dreamCruiseTicket;
             throw new IllegalConditionBeanOperationException(msg);
         }
          = dreamCruiseTicket;
     }

    
 
     public SpecifiedColumn inviteDerivedToDreamCruise(String derivedAlias) {
         if (!xisDreamCruiseShip()) {
             String msg = "This invitation is only allowed by Dream Cruise Ship: " + derivedAlias;
             throw new IllegalConditionBeanOperationException(msg);
         }
         final SqlClause portClause = xgetDreamCruiseDeparturePort().getSqlClause();
         if (!portClause.hasSpecifiedDerivingSubQuery(derivedAlias)) {
             String msg = "Not found the derived info by the argument 'derivedAlias': " + derivedAlias;
             throw new IllegalArgumentException(msg);
         }
         final ColumnInfo columnInfo = portClause.getSpecifiedDerivingColumnInfo(derivedAlias);
         if (columnInfo == null) {
             String msg = "Not found the derived column by the argument 'derivedAlias': " + derivedAlias;
             throw new IllegalArgumentException(msg);
         }
         return new SpecifiedColumn(nullcolumnInfothisderivedAliastrue);
     }

    
 
     public ConditionBean xcreateDreamCruiseCB() {
         return xdoCreateDreamCruiseCB();
     }
 
     protected abstract ConditionBean xdoCreateDreamCruiseCB();

    
 
     public void xmarkAsDeparturePortForDreamCruise() {
          = true;
     }

    
 
     public boolean xisDreamCruiseDeparturePort() {
         return ;
     }

    
 
     public boolean xisDreamCruiseShip() {
         return ..equals(getPurpose());
     }

    
 
         return ;
     }

    
 
     public boolean xhasDreamCruiseTicket() {
         return  != null;
     }

    
 
         return ;
     }

    
 
     public void xkeepDreamCruiseJourneyLogBook(String relationPath) {
         xassertDreamCruiseShip();
         if ( == null) {
              = new ArrayList<String>();
         }
         .add(relationPath);
     }

    
 
     public void xsetupSelectDreamCruiseJourneyLogBook() {
         xassertDreamCruiseShip();
         if ( == null) {
             return;
         }
             public void reflect() {
                 xdoSetupSelectDreamCruiseJourneyLogBook();
             }
         });
     }

    
 
         xassertDreamCruiseShip();
         if ( == null) {
             return;
         }
             xsetupSelectDreamCruiseJourneyLogBook();
         }
     }
 
     protected void xdoSetupSelectDreamCruiseJourneyLogBook() {
         // small waste exists but simple logic is best here
         final ConditionBean departurePort = xgetDreamCruiseDeparturePort();
         for (String relationPath : ) {
             final List<StringrelNoExpList = Srl.splitList(relationPath"_"); // e.g. _2_5
             final StringBuilder sb = new StringBuilder();
             DBMeta currentMeta = asDBMeta();
             int index = 0;
             for (String relNoExp : relNoExpList) {
                 if ("".equals(relNoExp)) {
                     continue;
                 }
                 final Integer relationNo = Integer.valueOf(relNoExp);
                 final ForeignInfo foreignInfo = currentMeta.findForeignInfo(relationNo);
                 final String foreignPropertyName = foreignInfo.getForeignPropertyName();
                 if (index > 0) {
                     sb.append(".");
                 }
                 sb.append(foreignPropertyName);
                 currentMeta = foreignInfo.getForeignDBMeta();
                 ++index;
             }
             departurePort.invokeSetupSelect(sb.toString());
         }
     }
 
     protected void xassertDreamCruiseShip() {
         if (!xisDreamCruiseShip()) {
             String msg = "The operation is only allowed at Dream Cruise.";
             throw new IllegalConditionBeanOperationException(msg);
         }
     }

    
 
     public void mysticRhythms(Object mysticBinding) {
         if (mysticBinding == null) {
             String msg = "The argument 'mysticBinding' should not be null.";
             throw new IllegalArgumentException(msg);
         }
         if ( != null) {
             String msg = "The other mystic binding already exists: " + mysticBinding;
             throw new IllegalConditionBeanOperationException(msg);
         }
         if (mysticBinding instanceof SpecifiedColumn) {
             String msg = "The mystic binding should be bound value: " + mysticBinding;
             throw new IllegalConditionBeanOperationException(msg);
         }
          = mysticBinding;
     }

    
 
     public Object xgetMysticBinding() {
         return ;
     }
 
     // [DBFlute-0.9.6.3]
     // ===================================================================================
     //                                                                       OrScope Query
     //                                                                       =============
     protected <CB extends ConditionBeanvoid xorSQ(CB cbOrQuery<CB> orQuery) {
         assertQueryPurpose();
         if (getSqlClause().isOrScopeQueryAndPartEffective()) {
             // limit because of so complex
             String msg = "The OrScopeQuery in and-part is unsupported: " + asTableDbName();
             throw new OrScopeQueryAndPartUnsupportedOperationException(msg);
         }
         xdoOrSQ(cborQuery);
     }
 
     protected <CB extends ConditionBeanvoid xdoOrSQ(CB cbOrQuery<CB> orQuery) {
         getSqlClause().beginOrScopeQuery();
         final HpCBPurpose originalPurpose = xhandleOrSQPurposeChange();
         try {
             // cannot lock base condition-bean for now
             // because it uses same instance in or-scope query
             orQuery.query(cb);
         } finally {
             xhandleOrSQPurposeClose(originalPurpose);
             getSqlClause().endOrScopeQuery();
         }
     }
 
     protected HpCBPurpose xhandleOrSQPurposeChange() { // might be overridden before Java8
         final HpCBPurpose originalPurpose = getPurpose();
         xsetupForOrScopeQuery();
         return originalPurpose;
     }
 
     protected void xhandleOrSQPurposeClose(HpCBPurpose originalPurpose) {
         if (originalPurpose != null) { // because it might be overridden before Java8
             xchangePurposeSqlClause(originalPurposenull);
         }
     }
 
     protected <CB extends ConditionBeanvoid xorSQAP(CB cbAndQuery<CB> andQuery) {
         assertQueryPurpose();
         if (!getSqlClause().isOrScopeQueryEffective()) {
         }
         if (getSqlClause().isOrScopeQueryAndPartEffective()) {
         }
         try {
             andQuery.query(cb);
         } finally {
             getSqlClause().endOrScopeQueryAndPart();
         }
     }
 
     // ===================================================================================
     //                                                                       Invalid Query
     //                                                                       =============
     // -----------------------------------------------------
     //                                         Null or Empty
     //                                         -------------
     
 
     public void ignoreNullOrEmptyQuery() {
         assertOptionThatBadTiming("ignoreNullOrEmptyQuery()");
     }

    
 
     public void checkNullOrEmptyQuery() {
         assertOptionThatBadTiming("checkNullOrEmptyQuery()");
         getSqlClause().checkNullOrEmptyQuery();
     }
 
     // -----------------------------------------------------
     //                                          Empty String
     //                                          ------------
     
 
     public void enableEmptyStringQuery(ModeQuery noArgInLambda) {
         assertOptionThatBadTiming("enableEmptyStringQuery()");
         assertObjectNotNull("noArgInLambda"noArgInLambda);
         final boolean originallyAllowed = getSqlClause().isEmptyStringQueryAllowed();
         if (!originallyAllowed) {
             doEnableEmptyStringQuery();
         }
         try {
             noArgInLambda.query();
         } finally {
             if (!originallyAllowed) {
                 disableEmptyStringQuery();
             }
         }
     }
 
     protected void doEnableEmptyStringQuery() {
     }

    
 
     public void disableEmptyStringQuery() {
         assertOptionThatBadTiming("disableEmptyStringQuery()");
     }
 
     // -----------------------------------------------------
     //                                            Overriding
     //                                            ----------
     
 
     public void enableOverridingQuery(ModeQuery noArgInLambda) {
         assertOptionThatBadTiming("enableOverridingQuery()");
         assertObjectNotNull("noArgInLambda"noArgInLambda);
         final boolean originallyAllowed = getSqlClause().isOverridingQueryAllowed();
         if (!originallyAllowed) {
             doEnableOverridingQuery();
         }
         try {
             noArgInLambda.query();
         } finally {
             if (!originallyAllowed) {
                 disableOverridingQuery();
             }
         }
     }
 
     protected void doEnableOverridingQuery() {
         getSqlClause().enableOverridingQuery();
     }

    
 
     public void disableOverridingQuery() {
         assertOptionThatBadTiming("disableOverridingQuery()");
     }
 
     // ===================================================================================
     //                                                                   Accept PrimaryKey
     //                                                                   =================
     
 
     public void acceptPrimaryKeyMap(Map<String, ? extends ObjectprimaryKeyMap) {
         if (!asDBMeta().hasPrimaryKey()) {
             String msg = "The table has no primary-keys: " + asTableDbName();
             throw new IllegalConditionBeanOperationException(msg);
         }
         final Entity entity = asDBMeta().newEntity();
         asDBMeta().acceptPrimaryKeyMap(entityprimaryKeyMap);
         final Map<StringObjectfilteredMap = asDBMeta().extractPrimaryKeyMap(entity);
         for (Entry<StringObjectentry : filteredMap.entrySet()) {
             localCQ().invokeQuery(entry.getKey(), "equal"entry.getValue());
         }
     }
 
     // ===================================================================================
     //                                                        Implementation of PagingBean
     //                                                        ============================
     // -----------------------------------------------------
     //                                  Paging Determination
     //                                  --------------------
     
 
     public boolean isPaging() { // for parameter comment
         String msg = "This method is unsupported on ConditionBean!";
         throw new IllegalConditionBeanOperationException(msg);
     }

    
 
     public boolean canPagingCountLater() { // for framework
         return ;
     }

    
 
     public boolean canPagingReSelect() { // for framework
         return ;
     }
 
     // -----------------------------------------------------
     //                                        Paging Setting
     //                                        --------------
     
 
     public void paging(int pageSizeint pageNumber) {
         assertOptionThatBadTiming("paging()");
         if (pageSize <= 0) {
             throwPagingPageSizeNotPlusException(pageSizepageNumber);
         }
         fetchFirst(pageSize);
         xfetchPage(pageNumber);
     }
 
     protected void throwPagingPageSizeNotPlusException(int pageSizeint pageNumber) {
         createCBExThrower().throwPagingPageSizeNotPlusException(thispageSizepageNumber);
     }

    
 
     public void xsetPaging(boolean paging) {
         // Do nothing because this is unsupported on ConditionBean.
         // And it is possible that this method is called by PagingInvoker.
     }

    
 
     public void enablePagingCountLater() {
         assertOptionThatBadTiming("enablePagingCountLater()");
          = true;
         getSqlClause().enablePagingCountLater(); // tell her about it
     }

    
 
     public void disablePagingCountLater() {
         assertOptionThatBadTiming("disablePagingCountLater()");
          = false;
         getSqlClause().disablePagingCountLater(); // tell her about it
     }

    
 
     public void enablePagingReSelect() {
         assertOptionThatBadTiming("enablePagingReSelect()");
          = true;
     }

    
 
     public void disablePagingReSelect() {
         assertOptionThatBadTiming("disablePagingReSelect()");
          = false;
     }
 
     // ConditionBean original
     
 
     public void enablePagingCountLeastJoin() {
         assertOptionThatBadTiming("enablePagingCountLeastJoin()");
     }

    
 
     public void disablePagingCountLeastJoin() {
         assertOptionThatBadTiming("disablePagingCountLeastJoin()");
     }

    
 
     public boolean canPagingSelectAndQuerySplit() {
         return ;
     }

    
Enable that it splits the SQL execute select and query of paging.
You should confirm that the executed SQL on log matches with your expectation.
It is very difficult internal logic so it also has simplistic logic. Be careful!
 Cannot use this:
  o if no PK or compound PK table (exception is thrown)
  o if SpecifiedDerivedOrderBy or not Paging (but no exception)

 Automatically Changed:
  o disable PagingCountLater (to suppress rows calculation)
 

Deprecated:
This is rare handling for performance tuning so don't use this easily.
 
     public void enablePagingSelectAndQuerySplit() {
         assertOptionThatBadTiming("enablePagingSelectAndQuerySplit()");
         final DBMeta dbmeta = asDBMeta();
         if (!dbmeta.hasPrimaryKey() || dbmeta.getPrimaryInfo().isCompoundKey()) {
             String msg = "The PagingSelectAndQuerySplit needs only-one column key table: " + asTableDbName();
             throw new IllegalConditionBeanOperationException(msg);
         }
         // MySQL's rows calculation is not fit with this function
         // e.g.
         //  paging : select PK only by business condition with sql_calc_found_rows
         //  paging : select business data by PK without no sql_calc_found_rows
         //  count  : select found_rows() -> returns latest count, why?  
         disablePagingCountLater();
          = true;
     }
 
     public void disablePagingSelectAndQuerySplit() {
         assertOptionThatBadTiming("disablePagingSelectAndQuerySplit()");
          = false;
     }
 
     // -----------------------------------------------------
     //                                         Fetch Setting
     //                                         -------------
     
 
     public PagingBean fetchFirst(int fetchSize) {
         assertOptionThatBadTiming("fetchFirst()");
         getSqlClause().fetchFirst(fetchSize);
         return this;
     }

    
 
     public PagingBean xfetchScope(int fetchStartIndexint fetchSize) {
         assertOptionThatBadTiming("xfetchScope()");
         getSqlClause().fetchScope(fetchStartIndexfetchSize);
         return this;
     }

    
 
     public PagingBean xfetchPage(int fetchPageNumber) {
         assertOptionThatBadTiming("xfetchPage()");
         getSqlClause().fetchPage(fetchPageNumber);
         return this;
     }
 
     // -----------------------------------------------------
     //                                       Paging Resource
     //                                       ---------------
     
 
     public <ENTITY> PagingInvoker<ENTITY> createPagingInvoker(String tableDbName) {
         return new PagingInvoker<ENTITY>(tableDbName);
     }
 
     // -----------------------------------------------------
     //                                        Fetch Property
     //                                        --------------
     
 
     public int getFetchStartIndex() {
         return getSqlClause().getFetchStartIndex();
     }

    
 
     public int getFetchSize() {
         return getSqlClause().getFetchSize();
     }

    
 
     public int getFetchPageNumber() {
         return getSqlClause().getFetchPageNumber();
     }

    
 
     public int getPageStartIndex() {
         return getSqlClause().getPageStartIndex();
     }

    
    public int getPageEndIndex() {
        return getSqlClause().getPageEndIndex();
    }

    
    public boolean isFetchScopeEffective() {
        return getSqlClause().isFetchScopeEffective();
    }
    // -----------------------------------------------------
    //                                         Hint Property
    //                                         -------------
    
Get select-hint. {select [select-hint] * from table...}

Returns:
select-hint. (NotNull)
    public String getSelectHint() {
        return getSqlClause().getSelectHint();
    }

    
Get from-base-table-hint. {select * from table [from-base-table-hint] where ...}

Returns:
from-base-table-hint. (NotNull)
    public String getFromBaseTableHint() {
        return getSqlClause().getFromBaseTableHint();
    }

    
Get from-hint. {select * from table left outer join ... on ... [from-hint] where ...}

Returns:
from-hint. (NotNull)
    public String getFromHint() {
        return getSqlClause().getFromHint();
    }

    
Get sql-suffix. {select * from table where ... order by ... [sql-suffix]}

Returns:
Sql-suffix. (NotNull)
    public String getSqlSuffix() {
        return getSqlClause().getSqlSuffix();
    }
    // ===================================================================================
    //                                                         Implementation of FetchBean
    //                                                         ===========================
    
    public void checkSafetyResult(int safetyMaxResultSize) {
        assertOptionThatBadTiming("checkSafetyResult()");
         = safetyMaxResultSize;
    }

    
    public int getSafetyMaxResultSize() {
        return ;
    }
    // ===================================================================================
    //                                                Implementation of FetchNarrowingBean
    //                                                ====================================
    
    public int getFetchNarrowingSkipStartIndex() {
    }

    
    public int getFetchNarrowingLoopCount() {
        return getSqlClause().getFetchNarrowingLoopCount();
    }

    
    public boolean isFetchNarrowingSkipStartIndexEffective() {
        return !getSqlClause().isFetchStartIndexSupported();
    }

    
    public boolean isFetchNarrowingLoopCountEffective() {
        return !getSqlClause().isFetchSizeSupported();
    }

    
    public boolean isFetchNarrowingEffective() {
        return getSqlClause().isFetchNarrowingEffective();
    }

    
    public void xdisableFetchNarrowing() {
        // no need to disable in ConditionBean, basically for OutsideSql
        String msg = "This method is unsupported on ConditionBean!";
        throw new UnsupportedOperationException(msg);
    }

    
    public void xenableIgnoredFetchNarrowing() {
        // do nothing
    }
<