Search in sources :

Example 31 with ConditionBean

use of org.dbflute.cbean.ConditionBean in project dbflute-core by dbflute.

the class SpecifiedColumn method initializeCalcSpecificationIfNeeds.

// ===================================================================================
// CalcSpecification Handling
// ==========================
protected void initializeCalcSpecificationIfNeeds() {
    if (_calcSpecification == null) {
        _calcSpecification = createEmptyCalcSpecification();
        final ConditionBean handlingCB;
        if (_baseCB.xisDreamCruiseShip()) {
            // to tell option parameters by DreamCruise to base condition-bean
            handlingCB = _baseCB.xgetDreamCruiseDeparturePort();
        } else {
            handlingCB = _baseCB;
        }
        _calcSpecification.setBaseCB(handlingCB);
    }
}
Also used : ConditionBean(org.dbflute.cbean.ConditionBean)

Example 32 with ConditionBean

use of org.dbflute.cbean.ConditionBean in project dbflute-core by dbflute.

the class TnAbstractBasicSqlHandler method getSpecifiedLogDateDisplayStyle.

protected BoundDateDisplayStyle getSpecifiedLogDateDisplayStyle() {
    if (ConditionBeanContext.isExistConditionBeanOnThread()) {
        final ConditionBean cb = ConditionBeanContext.getConditionBeanOnThread();
        final BoundDateDisplayStyle specifiedStyle = cb.getLogDateDisplayStyle();
        if (specifiedStyle != null) {
            return specifiedStyle;
        }
    }
    return null;
}
Also used : BoundDateDisplayStyle(org.dbflute.twowaysql.style.BoundDateDisplayStyle) ConditionBean(org.dbflute.cbean.ConditionBean)

Example 33 with ConditionBean

use of org.dbflute.cbean.ConditionBean in project dbflute-core by dbflute.

the class TnInsertEntityDynamicCommand method execute.

// ===================================================================================
// Execute
// =======
public Object execute(Object[] args) {
    final Object bean = extractBeanFromArgsChecked(args);
    final InsertOption<ConditionBean> option = extractInsertOptionChecked(args);
    prepareStatementConfigOnThreadIfExists(option);
    final TnBeanMetaData bmd = _beanMetaData;
    final TnPropertyType[] propertyTypes = createInsertPropertyTypes(bmd, bean, _propertyNames, option);
    final String sql = filterExecutedSql(createInsertSql(bmd, propertyTypes, option));
    return doExecute(bean, propertyTypes, sql, option);
}
Also used : TnBeanMetaData(org.dbflute.s2dao.metadata.TnBeanMetaData) ConditionBean(org.dbflute.cbean.ConditionBean) TnPropertyType(org.dbflute.s2dao.metadata.TnPropertyType)

Example 34 with ConditionBean

use of org.dbflute.cbean.ConditionBean in project dbflute-core by dbflute.

the class BehaviorExceptionThrower method throwDangerousResultSizeException.

public void throwDangerousResultSizeException(FetchBean fetchBean, Throwable cause) {
    final int safetyMaxResultSize = fetchBean.getSafetyMaxResultSize();
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("You've already been in DANGER ZONE. (check is working)");
    br.addItem("Advice");
    br.addElement("The selected size is over the specified safety size.");
    br.addElement("Confirm your conditions and table records.");
    br.addItem("Safety Max Result Size");
    br.addElement(safetyMaxResultSize);
    if (fetchBean instanceof ConditionBean) {
        final ConditionBean cb = ((ConditionBean) fetchBean);
        setupInvalidQueryElement(br, cb);
        setupFetchSizeElement(br, cb);
        setupDisplaySqlElement(br, cb);
    } else {
        br.addItem("Fetch Bean");
        br.addElement(fetchBean);
        if (cause instanceof FetchingOverSafetySizeException) {
            final String sql = ((FetchingOverSafetySizeException) cause).getDangerousDisplaySql();
            if (sql != null) {
                br.addItem("Dangerous SQL");
                br.addElement(sql);
            }
        }
    }
    final String msg = br.buildExceptionMessage();
    throw new DangerousResultSizeException(msg, cause, safetyMaxResultSize);
}
Also used : FetchingOverSafetySizeException(org.dbflute.exception.FetchingOverSafetySizeException) DangerousResultSizeException(org.dbflute.exception.DangerousResultSizeException) ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) ConditionBean(org.dbflute.cbean.ConditionBean)

Example 35 with ConditionBean

use of org.dbflute.cbean.ConditionBean in project dbflute-core by dbflute.

the class BehaviorExceptionThrower method setupSearchKeyElement.

protected void setupSearchKeyElement(ExceptionMessageBuilder br, Object searchKey) {
    if (searchKey instanceof Object[]) {
        final Object[] ary = (Object[]) searchKey;
        if (ary.length == 1) {
            searchKey = ary[0];
        } else {
            final StringBuilder sb = new StringBuilder();
            for (Object obj : ary) {
                if (sb.length() > 0) {
                    sb.append(", ");
                }
                sb.append(obj);
            }
            sb.insert(0, "{").append("}");
            searchKey = sb.toString();
        }
    }
    if (searchKey instanceof ConditionBean) {
        final ConditionBean cb = (ConditionBean) searchKey;
        setupInvalidQueryElement(br, cb);
        setupDisplaySqlElement(br, cb);
    } else {
        br.addItem("Search Condition");
        br.addElement(searchKey);
    }
}
Also used : ConditionBean(org.dbflute.cbean.ConditionBean)

Aggregations

ConditionBean (org.dbflute.cbean.ConditionBean)45 DeleteOption (org.dbflute.bhv.writable.DeleteOption)7 UpdateOption (org.dbflute.bhv.writable.UpdateOption)7 ArrayList (java.util.ArrayList)5 InsertOption (org.dbflute.bhv.writable.InsertOption)5 Entity (org.dbflute.Entity)4 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)4 List (java.util.List)3 AbstractBatchUpdateCommand (org.dbflute.bhv.core.command.AbstractBatchUpdateCommand)3 BatchDeleteCommand (org.dbflute.bhv.core.command.BatchDeleteCommand)3 BatchDeleteNonstrictCommand (org.dbflute.bhv.core.command.BatchDeleteNonstrictCommand)3 BatchInsertCommand (org.dbflute.bhv.core.command.BatchInsertCommand)3 BatchUpdateCommand (org.dbflute.bhv.core.command.BatchUpdateCommand)3 BatchUpdateNonstrictCommand (org.dbflute.bhv.core.command.BatchUpdateNonstrictCommand)3 DeleteEntityCommand (org.dbflute.bhv.core.command.DeleteEntityCommand)3 DeleteNonstrictEntityCommand (org.dbflute.bhv.core.command.DeleteNonstrictEntityCommand)3 InsertEntityCommand (org.dbflute.bhv.core.command.InsertEntityCommand)3 QueryDeleteCBCommand (org.dbflute.bhv.core.command.QueryDeleteCBCommand)3 QueryInsertCBCommand (org.dbflute.bhv.core.command.QueryInsertCBCommand)3 QueryUpdateCBCommand (org.dbflute.bhv.core.command.QueryUpdateCBCommand)3