Search in sources :

Example 1 with UpdateOption

use of org.dbflute.bhv.writable.UpdateOption in project dbflute-core by dbflute.

the class AbstractBehaviorWritable method delegateBatchUpdateNonstrict.

protected int[] delegateBatchUpdateNonstrict(List<? extends Entity> entityList, UpdateOption<? extends ConditionBean> option) {
    if (entityList.isEmpty()) {
        return EMPTY_INT_ARRAY;
    }
    final OptionalThing<UpdateOption<? extends ConditionBean>> optOption = createOptionalUpdateOption(option);
    adjustEntityListBeforeBatchUpdate(entityList, option, true);
    if (entityList.isEmpty()) {
        // might be filtered
        return EMPTY_INT_ARRAY;
    }
    final BatchUpdateNonstrictCommand command = createBatchUpdateNonstrictCommand(entityList, 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));
    }
}
Also used : BatchUpdateNonstrictCommand(org.dbflute.bhv.core.command.BatchUpdateNonstrictCommand) UpdateOption(org.dbflute.bhv.writable.UpdateOption) ConditionBean(org.dbflute.cbean.ConditionBean)

Example 2 with UpdateOption

use of org.dbflute.bhv.writable.UpdateOption 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 3 with UpdateOption

use of org.dbflute.bhv.writable.UpdateOption in project dbflute-core by dbflute.

the class AbstractBehaviorWritable method delegateQueryUpdate.

protected int delegateQueryUpdate(Entity entity, ConditionBean cb, UpdateOption<? extends ConditionBean> option) {
    final OptionalThing<UpdateOption<? extends ConditionBean>> optOption = createOptionalUpdateOption(option);
    adjustEntityBeforeQueryUpdate(entity, cb, optOption);
    final QueryUpdateCBCommand command = createQueryUpdateCBCommand(entity, cb, option);
    final OptionalThing<ConditionBean> optCB = OptionalThing.of(cb);
    RuntimeException cause = null;
    try {
        hookBeforeUpdate(command, entity, optCB, optOption);
        return invoke(command);
    } catch (RuntimeException e) {
        cause = e;
        throw e;
    } finally {
        hookFinallyUpdate(command, entity, optCB, optOption, createOptionalCause(cause));
    }
}
Also used : QueryUpdateCBCommand(org.dbflute.bhv.core.command.QueryUpdateCBCommand) UpdateOption(org.dbflute.bhv.writable.UpdateOption) ConditionBean(org.dbflute.cbean.ConditionBean)

Example 4 with UpdateOption

use of org.dbflute.bhv.writable.UpdateOption 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)

Example 5 with UpdateOption

use of org.dbflute.bhv.writable.UpdateOption in project dbflute-core by dbflute.

the class AbstractBehaviorWritable method delegateUpdateNonstrict.

protected int delegateUpdateNonstrict(Entity entity, UpdateOption<? extends ConditionBean> option) {
    final OptionalThing<UpdateOption<? extends ConditionBean>> optOption = createOptionalUpdateOption(option);
    adjustEntityBeforeUpdate(entity, optOption);
    final UpdateNonstrictEntityCommand command = createUpdateNonstrictEntityCommand(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));
    }
}
Also used : UpdateNonstrictEntityCommand(org.dbflute.bhv.core.command.UpdateNonstrictEntityCommand) UpdateOption(org.dbflute.bhv.writable.UpdateOption) ConditionBean(org.dbflute.cbean.ConditionBean)

Aggregations

UpdateOption (org.dbflute.bhv.writable.UpdateOption)6 ConditionBean (org.dbflute.cbean.ConditionBean)6 AbstractBatchUpdateCommand (org.dbflute.bhv.core.command.AbstractBatchUpdateCommand)2 BatchUpdateCommand (org.dbflute.bhv.core.command.BatchUpdateCommand)2 BatchUpdateNonstrictCommand (org.dbflute.bhv.core.command.BatchUpdateNonstrictCommand)2 QueryUpdateCBCommand (org.dbflute.bhv.core.command.QueryUpdateCBCommand)2 UpdateEntityCommand (org.dbflute.bhv.core.command.UpdateEntityCommand)2 UpdateNonstrictEntityCommand (org.dbflute.bhv.core.command.UpdateNonstrictEntityCommand)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Set (java.util.Set)1 Entity (org.dbflute.Entity)1 BehaviorCommandMeta (org.dbflute.bhv.core.BehaviorCommandMeta)1 BatchDeleteCommand (org.dbflute.bhv.core.command.BatchDeleteCommand)1 BatchDeleteNonstrictCommand (org.dbflute.bhv.core.command.BatchDeleteNonstrictCommand)1 BatchInsertCommand (org.dbflute.bhv.core.command.BatchInsertCommand)1 DeleteEntityCommand (org.dbflute.bhv.core.command.DeleteEntityCommand)1 DeleteNonstrictEntityCommand (org.dbflute.bhv.core.command.DeleteNonstrictEntityCommand)1 InsertEntityCommand (org.dbflute.bhv.core.command.InsertEntityCommand)1 QueryDeleteCBCommand (org.dbflute.bhv.core.command.QueryDeleteCBCommand)1