Search in sources :

Example 26 with ConditionBean

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

the class AbstractBehaviorWritable method delegateQueryInsert.

// -----------------------------------------------------
// Query Update
// ------------
protected int delegateQueryInsert(Entity entity, ConditionBean inCB, ConditionBean resCB, InsertOption<? extends ConditionBean> option) {
    final OptionalThing<InsertOption<? extends ConditionBean>> optOption = createOptionalInsertOption(option);
    adjustEntityBeforeQueryInsert(entity, inCB, resCB, optOption);
    final QueryInsertCBCommand command = createQueryInsertCBCommand(entity, inCB, resCB, option);
    final OptionalThing<ConditionBean> optInCB = OptionalThing.of(inCB);
    RuntimeException cause = null;
    try {
        hookBeforeInsert(command, entity, optInCB, optOption);
        return invoke(command);
    } catch (RuntimeException e) {
        cause = e;
        throw e;
    } finally {
        hookFinallyInsert(command, entity, optInCB, optOption, createOptionalCause(cause));
    }
}
Also used : QueryInsertCBCommand(org.dbflute.bhv.core.command.QueryInsertCBCommand) InsertOption(org.dbflute.bhv.writable.InsertOption) ConditionBean(org.dbflute.cbean.ConditionBean)

Example 27 with ConditionBean

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

Example 28 with ConditionBean

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

the class AbstractBehaviorWritable method setupCommonColumnOfInsertIfNeeds.

/**
 * Set up common columns of insert if it needs.
 * @param entity The entity for insert. (NotNull)
 * @param option The optional option of insert. (NotNull, EmptyAllowed: when no option)
 */
protected void setupCommonColumnOfInsertIfNeeds(Entity entity, OptionalThing<InsertOption<? extends ConditionBean>> option) {
    if (option.filter(op -> op.isCommonColumnAutoSetupDisabled()).isPresent()) {
        return;
    }
    final CommonColumnAutoSetupper setupper = getCommonColumnAutoSetupper();
    assertCommonColumnAutoSetupperNotNull();
    setupper.handleCommonColumnOfInsertIfNeeds(entity);
}
Also used : OptimisticLockColumnValueNullException(org.dbflute.exception.OptimisticLockColumnValueNullException) BehaviorCommandMeta(org.dbflute.bhv.core.BehaviorCommandMeta) DeleteNonstrictEntityCommand(org.dbflute.bhv.core.command.DeleteNonstrictEntityCommand) QueryUpdateCBCommand(org.dbflute.bhv.core.command.QueryUpdateCBCommand) Entity(org.dbflute.Entity) DeleteOption(org.dbflute.bhv.writable.DeleteOption) UniqueInfo(org.dbflute.dbmeta.info.UniqueInfo) OptionalThing(org.dbflute.optional.OptionalThing) BatchDeleteNonstrictCommand(org.dbflute.bhv.core.command.BatchDeleteNonstrictCommand) IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException) BatchUpdateCommand(org.dbflute.bhv.core.command.BatchUpdateCommand) UpdateEntityCommand(org.dbflute.bhv.core.command.UpdateEntityCommand) ArrayList(java.util.ArrayList) DeleteEntityCommand(org.dbflute.bhv.core.command.DeleteEntityCommand) ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) UpdateNonstrictEntityCommand(org.dbflute.bhv.core.command.UpdateNonstrictEntityCommand) ConditionBean(org.dbflute.cbean.ConditionBean) QueryDeleteCBCommand(org.dbflute.bhv.core.command.QueryDeleteCBCommand) UpdateOption(org.dbflute.bhv.writable.UpdateOption) CommonColumnAutoSetupper(org.dbflute.hook.CommonColumnAutoSetupper) IllegalBehaviorStateException(org.dbflute.exception.IllegalBehaviorStateException) SpecifyQuery(org.dbflute.cbean.scoping.SpecifyQuery) InsertEntityCommand(org.dbflute.bhv.core.command.InsertEntityCommand) QueryInsertSetupper(org.dbflute.bhv.writable.QueryInsertSetupper) BatchDeleteCommand(org.dbflute.bhv.core.command.BatchDeleteCommand) WritableOptionCall(org.dbflute.bhv.writable.WritableOptionCall) Set(java.util.Set) ResourceContext(org.dbflute.bhv.core.context.ResourceContext) BatchUpdateNonstrictCommand(org.dbflute.bhv.core.command.BatchUpdateNonstrictCommand) AbstractBatchUpdateCommand(org.dbflute.bhv.core.command.AbstractBatchUpdateCommand) BatchInsertCommand(org.dbflute.bhv.core.command.BatchInsertCommand) DBMeta(org.dbflute.dbmeta.DBMeta) List(java.util.List) EntityAlreadyDeletedException(org.dbflute.exception.EntityAlreadyDeletedException) ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo) EntityAlreadyUpdatedException(org.dbflute.exception.EntityAlreadyUpdatedException) InsertOption(org.dbflute.bhv.writable.InsertOption) QueryInsertCBCommand(org.dbflute.bhv.core.command.QueryInsertCBCommand) CommonColumnAutoSetupper(org.dbflute.hook.CommonColumnAutoSetupper)

Example 29 with ConditionBean

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

the class AbstractBehaviorWritable method setupCommonColumnOfUpdateIfNeeds.

/**
 * Set up common columns of update if it needs.
 * @param entity The entity for update. (NotNull)
 * @param option The optional option of update. (NotNull, EmptyAllowed: when no option)
 */
protected void setupCommonColumnOfUpdateIfNeeds(Entity entity, OptionalThing<UpdateOption<? extends ConditionBean>> option) {
    if (option.filter(op -> op.isCommonColumnAutoSetupDisabled()).isPresent()) {
        return;
    }
    final CommonColumnAutoSetupper setupper = getCommonColumnAutoSetupper();
    assertCommonColumnAutoSetupperNotNull();
    setupper.handleCommonColumnOfUpdateIfNeeds(entity);
}
Also used : OptimisticLockColumnValueNullException(org.dbflute.exception.OptimisticLockColumnValueNullException) BehaviorCommandMeta(org.dbflute.bhv.core.BehaviorCommandMeta) DeleteNonstrictEntityCommand(org.dbflute.bhv.core.command.DeleteNonstrictEntityCommand) QueryUpdateCBCommand(org.dbflute.bhv.core.command.QueryUpdateCBCommand) Entity(org.dbflute.Entity) DeleteOption(org.dbflute.bhv.writable.DeleteOption) UniqueInfo(org.dbflute.dbmeta.info.UniqueInfo) OptionalThing(org.dbflute.optional.OptionalThing) BatchDeleteNonstrictCommand(org.dbflute.bhv.core.command.BatchDeleteNonstrictCommand) IllegalConditionBeanOperationException(org.dbflute.exception.IllegalConditionBeanOperationException) BatchUpdateCommand(org.dbflute.bhv.core.command.BatchUpdateCommand) UpdateEntityCommand(org.dbflute.bhv.core.command.UpdateEntityCommand) ArrayList(java.util.ArrayList) DeleteEntityCommand(org.dbflute.bhv.core.command.DeleteEntityCommand) ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) UpdateNonstrictEntityCommand(org.dbflute.bhv.core.command.UpdateNonstrictEntityCommand) ConditionBean(org.dbflute.cbean.ConditionBean) QueryDeleteCBCommand(org.dbflute.bhv.core.command.QueryDeleteCBCommand) UpdateOption(org.dbflute.bhv.writable.UpdateOption) CommonColumnAutoSetupper(org.dbflute.hook.CommonColumnAutoSetupper) IllegalBehaviorStateException(org.dbflute.exception.IllegalBehaviorStateException) SpecifyQuery(org.dbflute.cbean.scoping.SpecifyQuery) InsertEntityCommand(org.dbflute.bhv.core.command.InsertEntityCommand) QueryInsertSetupper(org.dbflute.bhv.writable.QueryInsertSetupper) BatchDeleteCommand(org.dbflute.bhv.core.command.BatchDeleteCommand) WritableOptionCall(org.dbflute.bhv.writable.WritableOptionCall) Set(java.util.Set) ResourceContext(org.dbflute.bhv.core.context.ResourceContext) BatchUpdateNonstrictCommand(org.dbflute.bhv.core.command.BatchUpdateNonstrictCommand) AbstractBatchUpdateCommand(org.dbflute.bhv.core.command.AbstractBatchUpdateCommand) BatchInsertCommand(org.dbflute.bhv.core.command.BatchInsertCommand) DBMeta(org.dbflute.dbmeta.DBMeta) List(java.util.List) EntityAlreadyDeletedException(org.dbflute.exception.EntityAlreadyDeletedException) ColumnInfo(org.dbflute.dbmeta.info.ColumnInfo) EntityAlreadyUpdatedException(org.dbflute.exception.EntityAlreadyUpdatedException) InsertOption(org.dbflute.bhv.writable.InsertOption) QueryInsertCBCommand(org.dbflute.bhv.core.command.QueryInsertCBCommand) CommonColumnAutoSetupper(org.dbflute.hook.CommonColumnAutoSetupper)

Example 30 with ConditionBean

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

the class AbstractBehaviorWritable method delegateDeleteNonstrict.

protected int delegateDeleteNonstrict(Entity entity, DeleteOption<? extends ConditionBean> option) {
    final OptionalThing<DeleteOption<? extends ConditionBean>> optOption = createOptionalDeleteOption(option);
    adjustEntityBeforeDelete(entity, optOption);
    final DeleteNonstrictEntityCommand command = createDeleteNonstrictEntityCommand(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));
    }
}
Also used : DeleteNonstrictEntityCommand(org.dbflute.bhv.core.command.DeleteNonstrictEntityCommand) DeleteOption(org.dbflute.bhv.writable.DeleteOption) 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