Search in sources :

Example 16 with ConditionBean

use of org.dbflute.cbean.ConditionBean 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 17 with ConditionBean

use of org.dbflute.cbean.ConditionBean 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 18 with ConditionBean

use of org.dbflute.cbean.ConditionBean 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 19 with ConditionBean

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

the class AbstractBehaviorWritable method delegateBatchInsert.

// -----------------------------------------------------
// Batch Update
// ------------
protected int[] delegateBatchInsert(List<? extends Entity> entityList, InsertOption<? extends ConditionBean> option) {
    if (entityList.isEmpty()) {
        return EMPTY_INT_ARRAY;
    }
    final OptionalThing<InsertOption<? extends ConditionBean>> optOption = createOptionalInsertOption(option);
    adjustEntityListBeforeBatchInsert(entityList, option);
    if (entityList.isEmpty()) {
        // might be filtered
        return EMPTY_INT_ARRAY;
    }
    final BatchInsertCommand command = createBatchInsertCommand(entityList, option);
    RuntimeException cause = null;
    try {
        hookBeforeInsert(command, entityList, emptyOpt(), optOption);
        return invoke(command);
    } catch (RuntimeException e) {
        cause = e;
        throw e;
    } finally {
        hookFinallyInsert(command, entityList, emptyOpt(), optOption, createOptionalCause(cause));
    }
}
Also used : BatchInsertCommand(org.dbflute.bhv.core.command.BatchInsertCommand) InsertOption(org.dbflute.bhv.writable.InsertOption) ConditionBean(org.dbflute.cbean.ConditionBean)

Example 20 with ConditionBean

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

the class AbstractBehaviorWritable method delegateInsert.

// ===================================================================================
// Delegate to Command
// ===================
// -----------------------------------------------------
// Entity Update
// -------------
protected int delegateInsert(Entity entity, InsertOption<? extends ConditionBean> option) {
    final OptionalThing<InsertOption<? extends ConditionBean>> optOption = createOptionalInsertOption(option);
    adjustEntityBeforeInsert(entity, optOption);
    final InsertEntityCommand command = createInsertEntityCommand(entity, option);
    RuntimeException cause = null;
    try {
        hookBeforeInsert(command, entity, emptyOpt(), optOption);
        return invoke(command);
    } catch (RuntimeException e) {
        cause = e;
        throw e;
    } finally {
        hookFinallyInsert(command, entity, emptyOpt(), optOption, createOptionalCause(cause));
    }
}
Also used : InsertEntityCommand(org.dbflute.bhv.core.command.InsertEntityCommand) InsertOption(org.dbflute.bhv.writable.InsertOption) 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