Search in sources :

Example 1 with DeleteEntityCommand

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

the class AbstractBehaviorWritable method delegateDelete.

protected int delegateDelete(Entity entity, DeleteOption<? extends ConditionBean> option) {
    final OptionalThing<DeleteOption<? extends ConditionBean>> optOption = createOptionalDeleteOption(option);
    adjustEntityBeforeDelete(entity, optOption);
    if (asDBMeta().hasOptimisticLock()) {
        final DeleteEntityCommand command = createDeleteEntityCommand(entity, option);
        final OptionalThing<Object> optEntity = OptionalThing.of(entity);
        RuntimeException cause = null;
        try {
            hookBeforeDelete(command, optEntity, emptyOpt(), optOption);
            return invoke(command);
        } catch (RuntimeException e) {
            cause = e;
            throw e;
        } finally {
            hookFinallyDelete(command, optEntity, emptyOpt(), optOption, createOptionalCause(cause));
        }
    } else {
        return delegateDeleteNonstrict(entity, option);
    }
}
Also used : DeleteOption(org.dbflute.bhv.writable.DeleteOption) DeleteEntityCommand(org.dbflute.bhv.core.command.DeleteEntityCommand) ConditionBean(org.dbflute.cbean.ConditionBean)

Example 2 with DeleteEntityCommand

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

the class AbstractBehaviorWritable method createDeleteEntityCommand.

protected DeleteEntityCommand createDeleteEntityCommand(Entity entity, DeleteOption<? extends ConditionBean> option) {
    assertBehaviorCommandInvoker("createDeleteEntityCommand");
    final DeleteEntityCommand cmd = newDeleteEntityCommand();
    xsetupEntityCommand(cmd, entity);
    cmd.setDeleteOption(option);
    return cmd;
}
Also used : DeleteEntityCommand(org.dbflute.bhv.core.command.DeleteEntityCommand)

Aggregations

DeleteEntityCommand (org.dbflute.bhv.core.command.DeleteEntityCommand)2 DeleteOption (org.dbflute.bhv.writable.DeleteOption)1 ConditionBean (org.dbflute.cbean.ConditionBean)1