Search in sources :

Example 41 with ConditionBean

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

the class AbstractSelectCBReturnEntityCommand method beforeGettingSqlExecution.

// ===================================================================================
// Process Callback
// ================
public void beforeGettingSqlExecution() {
    assertStatus("beforeGettingSqlExecution");
    final ConditionBean cb = _conditionBean;
    FetchAssistContext.setFetchBeanOnThread(cb);
    ConditionBeanContext.setConditionBeanOnThread(cb);
}
Also used : ConditionBean(org.dbflute.cbean.ConditionBean)

Example 42 with ConditionBean

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

the class TnQueryDeleteDynamicCommand method execute.

// ===================================================================================
// Execute
// =======
public Object execute(Object[] args) {
    // analyze arguments
    final ConditionBean cb = extractConditionBeanWithCheck(args);
    final DeleteOption<ConditionBean> option = extractUpdateOptionWithCheck(args);
    prepareStatementConfigOnThreadIfExists(option);
    // arguments for execution (not contains an option)
    final String[] argNames = new String[] { "pmb" };
    final Class<?>[] argTypes = new Class<?>[] { cb.getClass() };
    final Object[] realArgs = new Object[] { cb };
    // prepare context
    final CommandContext context;
    {
        final String twoWaySql = buildQueryDeleteTwoWaySql(cb, option);
        context = createCommandContext(twoWaySql, argNames, argTypes, realArgs);
    }
    // execute
    final TnCommandContextHandler handler = createCommandContextHandler(context);
    handler.setExceptionMessageSqlArgs(context.getBindVariables());
    final int rows = handler.execute(realArgs);
    return Integer.valueOf(rows);
}
Also used : CommandContext(org.dbflute.twowaysql.context.CommandContext) TnCommandContextHandler(org.dbflute.s2dao.sqlhandler.TnCommandContextHandler) ConditionBean(org.dbflute.cbean.ConditionBean)

Example 43 with ConditionBean

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

the class TnQueryUpdateDynamicCommand method execute.

// ===================================================================================
// Execute
// =======
public Object execute(Object[] args) {
    // analyze arguments
    final Entity entity = extractEntityWithCheck(args);
    final ConditionBean cb = extractConditionBeanWithCheck(args);
    final UpdateOption<ConditionBean> option = extractUpdateOptionWithCheck(args);
    prepareStatementConfigOnThreadIfExists(option);
    // arguments for execution (not contains an option)
    final String[] argNames = new String[] { "entity", "pmb" };
    final Class<?>[] argTypes = new Class<?>[] { entity.getClass(), cb.getClass() };
    final Object[] realArgs = new Object[] { entity, cb };
    // prepare context
    final List<TnPropertyType> boundPropTypeList = new ArrayList<TnPropertyType>();
    final CommandContext context;
    {
        final String twoWaySql = buildQueryUpdateTwoWaySql(entity, cb, option, boundPropTypeList);
        if (twoWaySql == null) {
            // non execute
            return 0;
        }
        context = createCommandContext(twoWaySql, argNames, argTypes, realArgs);
    }
    // execute
    final TnCommandContextHandler handler = createCommandContextHandler(context);
    handler.setExceptionMessageSqlArgs(context.getBindVariables());
    handler.setFirstBoundPropTypeList(boundPropTypeList);
    final int rows = handler.execute(realArgs);
    return Integer.valueOf(rows);
}
Also used : Entity(org.dbflute.Entity) CommandContext(org.dbflute.twowaysql.context.CommandContext) ArrayList(java.util.ArrayList) TnCommandContextHandler(org.dbflute.s2dao.sqlhandler.TnCommandContextHandler) ConditionBean(org.dbflute.cbean.ConditionBean) TnPropertyType(org.dbflute.s2dao.metadata.TnPropertyType)

Example 44 with ConditionBean

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

the class PagingInvoker method throwPagingStatusInvalidException.

protected void throwPagingStatusInvalidException(PagingBean pagingBean) {
    final boolean cbean = pagingBean instanceof ConditionBean;
    final String name = cbean ? "condition-bean" : "parameter-bean";
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("The status of paging was INVALID. (paging parameters was not found)");
    br.addItem("Advice");
    br.addElement("Confirm your logic for paging of " + name + ".");
    br.addElement("Paging execution needs paging parameters 'pageSize' and 'pageNumber'.");
    br.addElement("For example:");
    br.addElement("  (x):");
    if (cbean) {
        br.addElement("    MemberCB cb = new MemberCB();");
        br.addElement("    cb.query().set...;");
        br.addElement("    ... = memberBhv.selectPage(cb);");
    } else {
        br.addElement("    SimpleMemberPmb pmb = new SimpleMemberPmb();");
        br.addElement("    pmb.set...;");
        br.addElement("    ... = memberBhv.outsideSql().manualPaging().selectPage(...);");
    }
    br.addElement("  (o):");
    if (cbean) {
        br.addElement("    MemberCB cb = new MemberCB();");
        br.addElement("    cb.query().set...;");
        br.addElement("    cb.paging(20, 2); // *Point!");
        br.addElement("    ... = memberBhv.selectPage(cb);");
    } else {
        br.addElement("    SimpleMemberPmb pmb = new SimpleMemberPmb();");
        br.addElement("    pmb.set...;");
        br.addElement("    pmb.paging(20, 2); // *Point!");
        br.addElement("    ... = memberBhv.outsideSql().manualPaging().selectPage(...);");
    }
    br.addItem("PagingBean");
    br.addElement(pagingBean);
    final String msg = br.buildExceptionMessage();
    throw new PagingStatusInvalidException(msg);
}
Also used : PagingStatusInvalidException(org.dbflute.exception.PagingStatusInvalidException) ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) ConditionBean(org.dbflute.cbean.ConditionBean)

Example 45 with ConditionBean

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

the class FunctionFilterOption method buildDreamCruiseTicketStatement.

protected String buildDreamCruiseTicketStatement(Object value) {
    final String bindPath;
    final SpecifiedColumn specifiedColumn = ((SpecifiedColumn) value);
    final String columnExp;
    if (_removeCalcAlias) {
        // e.g. VaryingUpdate
        columnExp = specifiedColumn.toColumnSqlName().toString();
    } else {
        // normally here
        columnExp = specifiedColumn.toColumnRealName().toString();
    }
    if (specifiedColumn.hasSpecifyCalculation()) {
        specifiedColumn.xinitSpecifyCalculation();
        final HpCalcSpecification<ConditionBean> calcSpecification = specifiedColumn.getSpecifyCalculation();
        if (_removeCalcAlias) {
            // e.g. VaryingUpdate
            bindPath = calcSpecification.buildStatementToSpecifidNameRemovedCalcAlias(columnExp);
        } else {
            // normally here
            bindPath = calcSpecification.buildStatementToSpecifidName(columnExp);
        }
    } else {
        bindPath = columnExp;
    }
    return bindPath;
}
Also used : SpecifiedColumn(org.dbflute.cbean.dream.SpecifiedColumn) 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