Search in sources :

Example 1 with BatchUpdateCommand

use of org.dbflute.bhv.core.command.BatchUpdateCommand in project dbflute-core by dbflute.

the class AbstractBehaviorWritable method createBatchUpdateCommand.

protected BatchUpdateCommand createBatchUpdateCommand(List<? extends Entity> entityList, UpdateOption<? extends ConditionBean> option) {
    assertBehaviorCommandInvoker("createBatchUpdateCommand");
    final BatchUpdateCommand cmd = newBatchUpdateCommand();
    setupListEntityCommand(cmd, entityList);
    cmd.setUpdateOption(option);
    return cmd;
}
Also used : BatchUpdateCommand(org.dbflute.bhv.core.command.BatchUpdateCommand) AbstractBatchUpdateCommand(org.dbflute.bhv.core.command.AbstractBatchUpdateCommand)

Example 2 with BatchUpdateCommand

use of org.dbflute.bhv.core.command.BatchUpdateCommand in project dbflute-core by dbflute.

the class AbstractBehaviorWritable method delegateBatchUpdate.

protected int[] delegateBatchUpdate(List<? extends Entity> entityList, UpdateOption<? extends ConditionBean> option) {
    if (entityList.isEmpty()) {
        return EMPTY_INT_ARRAY;
    }
    if (asDBMeta().hasOptimisticLock()) {
        adjustEntityListBeforeBatchUpdate(entityList, option, false);
        if (entityList.isEmpty()) {
            // might be filtered
            return EMPTY_INT_ARRAY;
        }
        final BatchUpdateCommand command = createBatchUpdateCommand(entityList, option);
        final OptionalThing<UpdateOption<? extends ConditionBean>> optOption = createOptionalUpdateOption(option);
        RuntimeException cause = null;
        try {
            hookBeforeUpdate(command, entityList, emptyOpt(), optOption);
            return invoke(command);
        } catch (RuntimeException e) {
            cause = e;
            throw e;
        } finally {
            hookFinallyUpdate(command, entityList, emptyOpt(), optOption, createOptionalCause(cause));
        }
    } else {
        return delegateBatchUpdateNonstrict(entityList, option);
    }
}
Also used : BatchUpdateCommand(org.dbflute.bhv.core.command.BatchUpdateCommand) AbstractBatchUpdateCommand(org.dbflute.bhv.core.command.AbstractBatchUpdateCommand) UpdateOption(org.dbflute.bhv.writable.UpdateOption) ConditionBean(org.dbflute.cbean.ConditionBean)

Aggregations

AbstractBatchUpdateCommand (org.dbflute.bhv.core.command.AbstractBatchUpdateCommand)2 BatchUpdateCommand (org.dbflute.bhv.core.command.BatchUpdateCommand)2 UpdateOption (org.dbflute.bhv.writable.UpdateOption)1 ConditionBean (org.dbflute.cbean.ConditionBean)1