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;
}
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);
}
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);
}
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);
}
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);
}
Aggregations