Search in sources :

Example 1 with UpdateEntityCommand

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

the class AbstractBehaviorWritable method delegateUpdate.

protected int delegateUpdate(Entity entity, UpdateOption<? extends ConditionBean> option) {
    final OptionalThing<UpdateOption<? extends ConditionBean>> optOption = createOptionalUpdateOption(option);
    adjustEntityBeforeUpdate(entity, optOption);
    if (asDBMeta().hasOptimisticLock()) {
        final UpdateEntityCommand command = createUpdateEntityCommand(entity, option);
        RuntimeException cause = null;
        try {
            hookBeforeUpdate(command, entity, emptyOpt(), optOption);
            return invoke(command);
        } catch (RuntimeException e) {
            cause = e;
            throw e;
        } finally {
            hookFinallyUpdate(command, entity, emptyOpt(), optOption, createOptionalCause(cause));
        }
    } else {
        return delegateUpdateNonstrict(entity, option);
    }
}
Also used : UpdateEntityCommand(org.dbflute.bhv.core.command.UpdateEntityCommand) UpdateOption(org.dbflute.bhv.writable.UpdateOption) ConditionBean(org.dbflute.cbean.ConditionBean)

Example 2 with UpdateEntityCommand

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

the class AbstractBehaviorWritable method createUpdateEntityCommand.

// ===================================================================================
// Behavior Command
// ================
// -----------------------------------------------------
// Basic
// -----
// an insert command creation is defined on the readable interface for non-primary key value
protected UpdateEntityCommand createUpdateEntityCommand(Entity entity, UpdateOption<? extends ConditionBean> option) {
    assertBehaviorCommandInvoker("createUpdateEntityCommand");
    final UpdateEntityCommand cmd = newUpdateEntityCommand();
    xsetupEntityCommand(cmd, entity);
    cmd.setUpdateOption(option);
    return cmd;
}
Also used : UpdateEntityCommand(org.dbflute.bhv.core.command.UpdateEntityCommand)

Aggregations

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