use of org.dbflute.bhv.writable.InsertOption 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));
}
}
use of org.dbflute.bhv.writable.InsertOption 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));
}
}
use of org.dbflute.bhv.writable.InsertOption 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));
}
}
use of org.dbflute.bhv.writable.InsertOption 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);
}
Aggregations