Search in sources :

Example 31 with IllegalConditionBeanOperationException

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

the class AbstractConditionBean method useInScopeSubQuery.

// [DBFlute-1.1.0]
// ===================================================================================
// ExistsReferrer Way
// ==================
/**
 * Use in-scope sub-query for exists-referrer, basically for performance tuning. <br>
 * The exists-referrer uses plain sub-query way instead of correlation way. <br>
 * <pre>
 * cb.query().existsPurchase(purchaseCB -&gt; {
 *     purchaseCB.<span style="color: #CC4747">useInScopeSubQuery()</span>;
 *     purchaseCB.query().set...
 *     purchaseCB.query().set...
 * });
 * </pre>
 */
public void useInScopeSubQuery() {
    assertOptionThatBadTiming("useInScopeSubQuery()");
    final HpCBPurpose purpose = getPurpose();
    if (!purpose.isAny(HpCBPurpose.EXISTS_REFERRER, HpCBPurpose.MYSELF_EXISTS)) {
        String msg = "The method 'useInScopeSubQuery()' can be called only when ExistsReferrer.";
        throw new IllegalConditionBeanOperationException(msg);
    }
    getSqlClause().useInScopeSubQueryForExistsReferrer();
}
Also used : IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException) HpCBPurpose(org.dbflute.cbean.chelper.HpCBPurpose)

Example 32 with IllegalConditionBeanOperationException

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

the class AbstractConditionBean method acceptPrimaryKeyMap.

// ===================================================================================
// Accept PrimaryKey
// =================
/**
 * {@inheritDoc}
 */
public void acceptPrimaryKeyMap(Map<String, ? extends Object> primaryKeyMap) {
    if (!asDBMeta().hasPrimaryKey()) {
        String msg = "The table has no primary-keys: " + asTableDbName();
        throw new IllegalConditionBeanOperationException(msg);
    }
    final Entity entity = asDBMeta().newEntity();
    asDBMeta().acceptPrimaryKeyMap(entity, primaryKeyMap);
    final Map<String, Object> filteredMap = asDBMeta().extractPrimaryKeyMap(entity);
    for (Entry<String, Object> entry : filteredMap.entrySet()) {
        localCQ().invokeQuery(entry.getKey(), "equal", entry.getValue());
    }
}
Also used : Entity(org.dbflute.Entity) IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException)

Example 33 with IllegalConditionBeanOperationException

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

the class AbstractConditionBean method inviteDerivedToDreamCruise.

/**
 * {@inheritDoc}
 */
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(null, columnInfo, this, derivedAlias, true);
}
Also used : IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException) SqlClause(org.dbflute.cbean.sqlclause.SqlClause) ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo) SpecifiedColumn(org.dbflute.cbean.dream.SpecifiedColumn)

Example 34 with IllegalConditionBeanOperationException

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

the class HpQDRParameter method throwFromToDateBothNullException.

protected void throwFromToDateBothNullException(FromToOption option) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("The both arguments of from-to for (Query)DerivedReferrer were null.");
    br.addItem("Advice");
    br.addElement("Basically it cannot allow double null");
    br.addElement("of the from-to method, even if allowOneSide().");
    br.addItem("FromToOption");
    br.addElement(option);
    final String msg = br.buildExceptionMessage();
    throw new IllegalConditionBeanOperationException(msg);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException)

Example 35 with IllegalConditionBeanOperationException

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

the class HpQDRParameter method throwFromToFromDateOnlyNullNotAllowedException.

protected void throwFromToFromDateOnlyNullNotAllowedException(Date toDate, FromToOption option) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("The from-date of from-to for (Query)DerivedReferrer were null.");
    br.addItem("Advice");
    br.addElement("Basically it cannot allow from-date to be null.");
    br.addElement("If you need to specify null, use allowOneSide() option.");
    br.addItem("toDate");
    br.addElement(toDate);
    br.addItem("FromToOption");
    br.addElement(option);
    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