Search in sources :

Example 6 with IllegalConditionBeanOperationException

use of org.dbflute.exception.IllegalConditionBeanOperationException in project dbflute-core by dbflute.

the class AbstractConditionBean method enablePagingSelectAndQuerySplit.

/**
 * Enable that it splits the SQL execute select and query of paging. <br>
 * You should confirm that the executed SQL on log matches with your expectation. <br>
 * It is very difficult internal logic so it also has simplistic logic. Be careful!
 * <pre>
 * 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)
 * </pre>
 * @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();
    _pagingSelectAndQuerySplit = true;
}
Also used : DBMeta(org.dbflute.dbmeta.DBMeta) IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException)

Example 7 with IllegalConditionBeanOperationException

use of org.dbflute.exception.IllegalConditionBeanOperationException in project dbflute-core by dbflute.

the class HpCalcSpecification method buildStatementAsSqlName.

// ===================================================================================
// Statement
// =========
/**
 * {@inheritDoc}
 */
public String buildStatementAsSqlName(String aliasName) {
    // e.g. VaryingUpdate, VaryingQueryUdpate
    final ColumnSqlName columnSqlName = getResolvedSpecifiedColumnSqlName();
    if (columnSqlName == null) {
        // very rare case, e.g. DreamCruise
        String msg = "Specified column is not found or too many columns are specified: " + aliasName;
        throw new IllegalConditionBeanOperationException(msg);
    }
    final String columnExp = (aliasName != null ? aliasName : "") + columnSqlName.toString();
    final boolean removeCalcAlias = aliasName == null;
    return doBuildStatement(columnExp, null, removeCalcAlias);
}
Also used : ColumnSqlName(org.dbflute.dbmeta.name.ColumnSqlName) IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException)

Example 8 with IllegalConditionBeanOperationException

use of org.dbflute.exception.IllegalConditionBeanOperationException in project dbflute-core by dbflute.

the class ConditionBeanExceptionThrower method throwManualOrderSameBeanAlreadyExistsException.

public void throwManualOrderSameBeanAlreadyExistsException(ConditionBean baseCB, ManualOrderOption existingMoOp, OrderByElement existingOrder, ManualOrderOption specifiedMob, OrderByElement specifiedOrder) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("The same ManualOrder option with other columns was registered.");
    br.addItem("Advice");
    br.addElement("You can use manual-order-bean one time.");
    br.addElement("Make sure your implementation:");
    br.addElement("For example:");
    // basically not comes here if lambda style so no needs to migrate this message
    br.addElement("  (x):");
    br.addElement("    MemberCB cb = new MemberCB();");
    br.addElement("    ManualOrderOption mob = new ManualOrderOption();");
    br.addElement("    mob.when_LessEqual(...);");
    br.addElement("    cb.query().addOrderBy_Birthdate_Asc().withManualOrder(mob);");
    br.addElement("    cb.query().addOrderBy_MemberId_Asc().withManualOrder(mob); // *Bad");
    br.addElement("  (o):");
    br.addElement("    MemberCB cb = new MemberCB();");
    br.addElement("    ManualOrderOption birthMob = new ManualOrderOption();");
    br.addElement("    birthMob.when_LessEqual(...);");
    br.addElement("    cb.query().addOrderBy_Birthdate_Asc().withManualOrder(birthMob);");
    br.addElement("    ManualOrderOption idMob = new ManualOrderOption();");
    br.addElement("    idMob.when_LessEqual(...);");
    br.addElement("    cb.query().addOrderBy_MemberId_Asc().withManualOrder(idMob); // Good");
    // don't use displaySql because of illegal CB's state
    br.addItem("ConditionBean");
    // check just in case
    br.addElement(baseCB != null ? baseCB.getClass().getName() : baseCB);
    br.addItem("Existing Option");
    br.addElement(existingMoOp);
    br.addElement(existingOrder);
    br.addItem("Specified Bean");
    br.addElement(specifiedMob);
    br.addElement(specifiedOrder);
    final String msg = br.buildExceptionMessage();
    throw new IllegalConditionBeanOperationException(msg);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException)

Example 9 with IllegalConditionBeanOperationException

use of org.dbflute.exception.IllegalConditionBeanOperationException in project dbflute-core by dbflute.

the class ManualOrderOption method throwManualOrderElseValueCaseWhenElementNotFoundException.

protected void throwManualOrderElseValueCaseWhenElementNotFoundException(Object elseValue) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Not found 'case when' element for 'else' value.");
    br.addItem("Advice");
    br.addElement("You should set 'case when' element before setting 'else' value.");
    br.addElement("For example:");
    br.addElement("  (x):");
    br.addElement("    ManualOrderOption mob = new ManualOrderOption();");
    br.addElement("    mob.elseEnd(0); // *NG");
    br.addElement("  (o):");
    br.addElement("    ManualOrderOption mob = new ManualOrderOption();");
    br.addElement("    mob.when_Equal(...); // *Don't forget here");
    br.addElement("    mob.elseEnd(0); // OK");
    br.addItem("Added ThenValue");
    br.addElement(elseValue);
    final String msg = br.buildExceptionMessage();
    throw new IllegalConditionBeanOperationException(msg);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException)

Example 10 with IllegalConditionBeanOperationException

use of org.dbflute.exception.IllegalConditionBeanOperationException in project dbflute-core by dbflute.

the class ManualOrderOption method throwManualOrderPreviousConditionNotFoundException.

protected void throwManualOrderPreviousConditionNotFoundException(HpMobConnectionMode mode, ConditionKey conditionKey, Object orderValue) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Not found previous condition of 'case when' for connecting next condition.");
    br.addItem("Advice");
    br.addElement("You should set first condition before setting next condition.");
    br.addItem("Connection Mode");
    br.addElement(mode);
    br.addItem("Added ConnectionKey");
    br.addElement(conditionKey);
    br.addItem("Added OrderValue");
    br.addElement(orderValue);
    final String msg = br.buildExceptionMessage();
    throw new IllegalConditionBeanOperationException(msg);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException)

Aggregations

IllegalConditionBeanOperationException (org.dbflute.exception.IllegalConditionBeanOperationException)36 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)24 HpMobCaseWhenElement (org.dbflute.cbean.chelper.HpMobCaseWhenElement)3 SpecifiedColumn (org.dbflute.cbean.dream.SpecifiedColumn)3 DBMeta (org.dbflute.dbmeta.DBMeta)3 ColumnInfo (org.dbflute.dbmeta.info.ColumnInfo)3 ColumnSqlName (org.dbflute.dbmeta.name.ColumnSqlName)3 ArrayList (java.util.ArrayList)2 Method (java.lang.reflect.Method)1 LocalDate (java.time.LocalDate)1 LocalDateTime (java.time.LocalDateTime)1 Collection (java.util.Collection)1 Date (java.util.Date)1 List (java.util.List)1 Entity (org.dbflute.Entity)1 HpCBPurpose (org.dbflute.cbean.chelper.HpCBPurpose)1 SqlClause (org.dbflute.cbean.sqlclause.SqlClause)1 OrderByClause (org.dbflute.cbean.sqlclause.orderby.OrderByClause)1 OrderByElement (org.dbflute.cbean.sqlclause.orderby.OrderByElement)1 ColumnRealName (org.dbflute.dbmeta.name.ColumnRealName)1