${database.allClassCopyright}package ${glPackageBaseBhv};
#set ($myClassName = "${myBaseBhvClassName}")
import java.util.List;
import org.seasar.dbflute.*;
import org.seasar.dbflute.bhv.*;
#if ($table.isAvailableNonPrimaryKeyWritable())
import org.seasar.dbflute.bhv.core.command.InsertEntityCommand;
#end
import org.seasar.dbflute.cbean.ConditionBean;
import org.seasar.dbflute.cbean.EntityRowHandler;
import org.seasar.dbflute.cbean.ListResultBean;
import org.seasar.dbflute.cbean.PagingResultBean;
import org.seasar.dbflute.dbmeta.DBMeta;
#if ($database.isMakeFlatExpansion())
import org.seasar.dbflute.dbmeta.hierarchy.HierarchyArranger;
import org.seasar.dbflute.dbmeta.hierarchy.HierarchyBasicRequest;
import org.seasar.dbflute.dbmeta.hierarchy.HierarchyRequest;
#end
#if ($table.isBuriTarget())
import ${glPackagePluginBuri}.${glBuriDef};
#end
#if ($table.hasPrimaryKeyForcedClassificationSetting())
import ${glPackageBaseCommon}.${glCDef};
#end
#if (${table.hasPrimaryKey()} && $table.hasReferrerAsMany())
import ${glPackageExtendedBhv}.*;
#end
import ${glPackageExtendedEntity}.*;
import ${myDBMetaPackageName}.*;
import ${glPackageCB}.*;
#set ($myExtendClassName = "")
#if ($table.isWritable())
#set ($myExtendClassName = "AbstractBehaviorWritable")
#else
#set ($myExtendClassName = "AbstractBehaviorReadable")
#end
/**
* The behavior of ${table.basicInfoDispString}.
#if ($table.isBuriInternal())
* {Buri Internal}
#end
*
* [primary-key] * ${table.primaryKeyNameCommaString} * * [column] * ${table.columnNameCommaString} * * [sequence] * ${table.definedSequenceName} * * [identity] * ${table.identityColumnName} * * [version-no] * ${table.versionNoColumnName} * * [foreign-table] * ${table.foreignTableNameCommaString} * * [referrer-table] * ${table.referrerTableNameCommaString} * * [foreign-property] * ${table.foreignPropertyNameCommaString} * * [referrer-property] * ${table.referrerPropertyNameCommaString} ** @author ${database.classAuthor} */ public abstract class ${myClassName} extends ${myExtendClassName} { // =================================================================================== // Definition // ========== ${database.behaviorQueryPathBeginMark} ${database.behaviorQueryPathEndMark} // =================================================================================== // Table name // ========== /** @return The name on database of table. (NotNull) */ public String getTableDbName() { return "${table.name}"; } // =================================================================================== // DBMeta // ====== /** @return The instance of DBMeta. (NotNull) */ public DBMeta getDBMeta() { return ${myDBMetaClassName}.getInstance(); } /** @return The instance of DBMeta as my table type. (NotNull) */ public ${myDBMetaClassName} getMyDBMeta() { return ${myDBMetaClassName}.getInstance(); } // =================================================================================== // New Instance // ============ /** {@inheritDoc} */ public Entity newEntity() { return newMyEntity(); } /** {@inheritDoc} */ public ConditionBean newConditionBean() { return newMyConditionBean(); } /** @return The instance of new entity as my table type. (NotNull) */ public ${myExtendedObjectClassName} newMyEntity() { return new ${myExtendedObjectClassName}(); } /** @return The instance of new condition-bean as my table type. (NotNull) */ public ${myConditionBeanClassName} newMyConditionBean() { return new ${myConditionBeanClassName}(); } // =================================================================================== // Count Select // ============ /** * Select the count by the condition-bean. {IgnorePagingCondition} *
* ${myConditionBeanClassName} cb = new ${myConditionBeanClassName}();
* cb.query().setFoo...(value);
* int count = ${myEntityVariableName}Bhv.selectCount(cb);
*
* @param cb The condition-bean of ${myExtendedObjectClassName}. (NotNull)
* @return The selected count.
*/
public int selectCount(${myConditionBeanClassName} cb) {
return doSelectCount(cb);
}
protected int doSelectCount(${myConditionBeanClassName} cb) {
assertCBNotNull(cb);
return delegateSelectCount(cb);
}
@Override
protected int doReadCount(ConditionBean cb) {
return selectCount(downcast(cb));
}
// ===================================================================================
// Cursor Select
// =============
/**
* Select the cursor by the condition-bean.
*
* ${myConditionBeanClassName} cb = new ${myConditionBeanClassName}();
* cb.query().setFoo...(value);
* ${myEntityVariableName}Bhv.selectCursor(cb, new EntityRowHandler<${myExtendedObjectClassName}>() {
* public void handle(${myExtendedObjectClassName} entity) {
* ... = entity.getFoo...();
* }
* });
*
* @param cb The condition-bean of ${myExtendedObjectClassName}. (NotNull)
* @param entityRowHandler The handler of entity row of ${myExtendedObjectClassName}. (NotNull)
*/
public void selectCursor(${myConditionBeanClassName} cb, EntityRowHandler<${myExtendedObjectClassName}> entityRowHandler) {
doSelectCursor(cb, entityRowHandler, ${myExtendedObjectClassName}.class);
}
protected
* ${myConditionBeanClassName} cb = new ${myConditionBeanClassName}();
* cb.query().setFoo...(value);
* ${myExtendedObjectClassName} ${myEntityVariableName} = ${myEntityVariableName}Bhv.selectEntity(cb);
* if (${myEntityVariableName} != null) {
* ... = ${myEntityVariableName}.get...();
* } else {
* ...
* }
*
* @param cb The condition-bean of ${myExtendedObjectClassName}. (NotNull)
* @return The selected entity. (Nullable: If the condition has no data, it returns null)
* @exception org.seasar.dbflute.exception.EntityDuplicatedException When the entity has been duplicated.
* @exception org.seasar.dbflute.exception.SelectEntityConditionNotFoundException When the condition for selecting an entity is not found.
*/
public ${myExtendedObjectClassName} selectEntity(${myConditionBeanClassName} cb) {
return doSelectEntity(cb, ${myExtendedObjectClassName}.class);
}
protected * ${myConditionBeanClassName} cb = new ${myConditionBeanClassName}(); * cb.query().setFoo...(value); * ${myExtendedObjectClassName} ${myEntityVariableName} = ${myEntityVariableName}Bhv.selectEntityWithDeletedCheck(cb); * ... = ${myEntityVariableName}.get...(); // the entity always be not null ** @param cb The condition-bean of ${myExtendedObjectClassName}. (NotNull) * @return The selected entity. (NotNull) * @exception org.seasar.dbflute.exception.EntityAlreadyDeletedException When the entity has already been deleted. * @exception org.seasar.dbflute.exception.EntityDuplicatedException When the entity has been duplicated. * @exception org.seasar.dbflute.exception.SelectEntityConditionNotFoundException When the condition for selecting an entity is not found. */ public ${myExtendedObjectClassName} selectEntityWithDeletedCheck(${myConditionBeanClassName} cb) { return doSelectEntityWithDeletedCheck(cb, ${myExtendedObjectClassName}.class); } protected
* ${myConditionBeanClassName} cb = new ${myConditionBeanClassName}();
* cb.query().setFoo...(value);
* cb.query().addOrderBy_Bar...();
* ListResultBean<${myExtendedObjectClassName}> ${myEntityListVariableName} = ${myEntityVariableName}Bhv.selectList(cb);
* for (${myExtendedObjectClassName} ${myEntityVariableName} : ${myEntityListVariableName}) {
* ... = ${myEntityVariableName}.get...();
* }
*
* @param cb The condition-bean of ${myExtendedObjectClassName}. (NotNull)
* @return The result bean of selected list. (NotNull)
* @exception org.seasar.dbflute.exception.DangerousResultSizeException When the result size is over the specified safety size.
*/
public ListResultBean<${myExtendedObjectClassName}> selectList(${myConditionBeanClassName} cb) {
return doSelectList(cb, ${myExtendedObjectClassName}.class);
}
protected * ${myConditionBeanClassName} cb = new ${myConditionBeanClassName}(); * cb.query().setFoo...(value); * cb.query().addOrderBy_Bar...(); * cb.paging(20, 3); // 20 records per a page and current page number is 3 * PagingResultBean<${myExtendedObjectClassName}> page = ${myEntityVariableName}Bhv.selectPage(cb); * int allRecordCount = page.getAllRecordCount(); * int allPageCount = page.getAllPageCount(); * boolean isExistPrePage = page.isExistPrePage(); * boolean isExistNextPage = page.isExistNextPage(); * ... * for (${myExtendedObjectClassName} ${myEntityVariableName} : page) { * ... = ${myEntityVariableName}.get...(); * } ** @param cb The condition-bean of ${myExtendedObjectClassName}. (NotNull) * @return The result bean of selected page. (NotNull) * @exception org.seasar.dbflute.exception.DangerousResultSizeException When the result size is over the specified safety size. */ public PagingResultBean<${myExtendedObjectClassName}> selectPage(${myConditionBeanClassName} cb) { return doSelectPage(cb, ${myExtendedObjectClassName}.class); } protected
* ${myEntityVariableName}Bhv.scalarSelect(Date.class).max(new ScalarQuery() { * public void query(${myConditionBeanClassName} cb) { * cb.specify().columnFooDatetime(); // required for a function * cb.query().setBarName_PrefixSearch("S"); * } * }); ** @param
* ${myEntityVariableName}Bhv.load${referrer.referrerJavaBeansRulePropertyNameInitCap}(${myEntityListVariableName}, new ConditionBeanSetupper<${referrerCBClassName}>() { * public void setup(${referrerCBClassName} cb) { * cb.setupSelect...(); * cb.query().setFoo...(value); * cb.query().addOrderBy_Bar...(); // basically you should order referrer list * } * }); * for (${myExtendedObjectClassName} ${myEntityVariableName} : ${myEntityListVariableName}) { * ... = ${myEntityVariableName}.get${referrer.referrerJavaBeansRulePropertyNameInitCap}(); * } ** About internal policy, the value of primary key(and others too) is treated as case-insensitive.
#if ($referrer.isSimpleKeyFK()) * cb.query().set${referrer.getLocalColumnJavaNameAsOne()}_InScope(pkList); * cb.query().addOrderBy_${referrer.getLocalColumnJavaNameAsOne()}_Asc(); #else * cb.query().set[ForeignKey]_InScope(pkList); * cb.query().addOrderBy_[ForeignKey]_Asc(); #end ** @param ${myEntityListVariableName} The entity list of ${table.javaBeansRulePropertyName}. (NotNull) * @param conditionBeanSetupper The instance of referrer condition-bean set-upper for registering referrer condition. (NotNull) */ public void load${referrer.referrerJavaBeansRulePropertyNameInitCap}(List<${myExtendedObjectClassName}> ${myEntityListVariableName}, ConditionBeanSetupper<${referrerCBClassName}> conditionBeanSetupper) { xassLRArg(${myEntityListVariableName}, conditionBeanSetupper); load${referrer.referrerJavaBeansRulePropertyNameInitCap}(${myEntityListVariableName}, new LoadReferrerOption<${referrerCBClassName}, ${referrerEntityClassName}>().xinit(conditionBeanSetupper)); } /** * {Refer to overload method that has an argument of the list of entity.} * @param ${myEntityVariableName} The entity of ${table.javaBeansRulePropertyName}. (NotNull) * @param loadReferrerOption The option of load-referrer. (NotNull) */ public void load${referrer.referrerJavaBeansRulePropertyNameInitCap}(${myExtendedObjectClassName} ${myEntityVariableName}, LoadReferrerOption<${referrerCBClassName}, ${referrerEntityClassName}> loadReferrerOption) { xassLRArg(${myEntityVariableName}, loadReferrerOption); load${referrer.referrerJavaBeansRulePropertyNameInitCap}(xnewLRLs(${myEntityVariableName}), loadReferrerOption); } #if ($referrer.isSimpleKeyFK()) #set ($referrerColumn = ${referrer.localColumnAsOne}) #set ($localColumn = ${referrer.foreignColumnAsOne}) #set ($keyJavaNative = "${referrerColumn.javaNative}") /** * {Refer to overload method that has an argument of condition-bean setupper.} * @param ${myEntityListVariableName} The entity list of ${table.javaBeansRulePropertyName}. (NotNull) * @param loadReferrerOption The option of load-referrer. (NotNull) */ public void load${referrer.referrerJavaBeansRulePropertyNameInitCap}(List<${myExtendedObjectClassName}> ${myEntityListVariableName}, LoadReferrerOption<${referrerCBClassName}, ${referrerEntityClassName}> loadReferrerOption) { xassLRArg(${myEntityListVariableName}, loadReferrerOption); if (${myEntityListVariableName}.isEmpty()) { return; } final ${referrerBhvClassName} referrerBhv = xgetBSFLR().select(${referrerBhvClassName}.class); helpLoadReferrerInternally(${myEntityListVariableName}, loadReferrerOption, new InternalLoadReferrerCallback<${myExtendedObjectClassName}, ${keyJavaNative}, ${referrerCBClassName}, ${referrerEntityClassName}>() { public ${keyJavaNative} getPKVal(${myExtendedObjectClassName} e) { return e.get${localColumn.javaName}(); } public void setRfLs(${myExtendedObjectClassName} e, List<${referrerEntityClassName}> ls) { e.set${referrer.referrerPropertyNameInitCap}(ls); } public ${referrerCBClassName} newMyCB() { return referrerBhv.newMyConditionBean(); } public void qyFKIn(${referrerCBClassName} cb, List<${keyJavaNative}> ls) { cb.query().set${referrerColumn.javaName}_InScope(ls); } public void qyOdFKAsc(${referrerCBClassName} cb) { cb.query().addOrderBy_${referrerColumn.javaName}_Asc(); } public void spFKCol(${referrerCBClassName} cb) { cb.specify().column${referrerColumn.javaName}(); } public List<${referrerEntityClassName}> selRfLs(${referrerCBClassName} cb) { return referrerBhv.selectList(cb); } public ${keyJavaNative} getFKVal(${referrerEntityClassName} e) { return e.get${referrerColumn.javaName}(); } public void setlcEt(${referrerEntityClassName} re, ${myExtendedObjectClassName} le) { re.set${referrer.foreignPropertyNameInitCap}(le); } }); } #else #set ($keyJavaNative = "java.util.Map
* ${myExtendedObjectClassName} ${myEntityVariableName} = new ${myExtendedObjectClassName}(); * // if auto-increment, you don't need to set the PK value * ${myEntityVariableName}.setFoo...(value); * ${myEntityVariableName}.setBar...(value); * ${myEntityVariableName}Bhv.insert(${myEntityVariableName}); * ... = ${myEntityVariableName}.getPK...(); // if auto-increment, you can get the value after ** @param ${myEntityVariableName} The entity of insert target. (NotNull) * @exception org.seasar.dbflute.exception.EntityAlreadyExistsException When the entity already exists. (Unique Constraint Violation) */ public void insert(${myExtendedObjectClassName} ${myEntityVariableName}) { assertEntityNotNull(${myEntityVariableName}); delegateInsert(${myEntityVariableName}); } @Override protected void doCreate(Entity entity) { insert(downcast(entity)); } /** * Update the entity modified-only. {UpdateCountZeroException, ExclusiveControl} *
* ${myExtendedObjectClassName} ${myEntityVariableName} = new ${myExtendedObjectClassName}(); * ${myEntityVariableName}.setPK...(value); // required * ${myEntityVariableName}.setFoo...(value); // you should set only modified columns * // if exclusive control, the value of exclusive control column is required * ${myEntityVariableName}.setVersionNo(value); * try { * ${myEntityVariableName}Bhv.update(${myEntityVariableName}); * } catch (EntityAlreadyUpdatedException e) { // if concurrent update * ... * } ** @param ${myEntityVariableName} The entity of update target. (NotNull) {PrimaryKeyRequired, ConcurrencyColumnRequired} #if ($table.hasOptimisticLock()) * @exception org.seasar.dbflute.exception.EntityAlreadyUpdatedException When the entity has already been updated. #else * @exception org.seasar.dbflute.exception.EntityAlreadyDeletedException When the entity has already been deleted. #end * @exception org.seasar.dbflute.exception.EntityDuplicatedException When the entity has been duplicated. * @exception org.seasar.dbflute.exception.EntityAlreadyExistsException When the entity already exists. (Unique Constraint Violation) */ public void update(final ${myExtendedObjectClassName} ${myEntityVariableName}) { helpUpdateInternally(${myEntityVariableName}, new InternalUpdateCallback<${myExtendedObjectClassName}>() { public int callbackDelegateUpdate(${myExtendedObjectClassName} entity) { return delegateUpdate(entity); } }); } @Override protected void doModify(Entity entity) { update(downcast(entity)); } #if ($table.hasOptimisticLock()) /** * Update the entity non-strictly modified-only. {UpdateCountZeroException, NonExclusiveControl} *
* ${myExtendedObjectClassName} ${myEntityVariableName} = new ${myExtendedObjectClassName}(); * ${myEntityVariableName}.setPK...(value); // required * ${myEntityVariableName}.setFoo...(value); // you should set only modified columns * // you don't need to set the value of exclusive control column * // (auto-increment for version number is valid though non-exclusive control) * //${myEntityVariableName}.setVersionNo(value); * ${myEntityVariableName}Bhv.updateNonstrict(${myEntityVariableName}); ** @param ${myEntityVariableName} The entity of update target. (NotNull) {PrimaryKeyRequired} * @exception org.seasar.dbflute.exception.EntityAlreadyDeletedException When the entity has already been deleted. * @exception org.seasar.dbflute.exception.EntityDuplicatedException When the entity has been duplicated. * @exception org.seasar.dbflute.exception.EntityAlreadyExistsException When the entity already exists. (Unique Constraint Violation) */ public void updateNonstrict(final ${myExtendedObjectClassName} ${myEntityVariableName}) { helpUpdateNonstrictInternally(${myEntityVariableName}, new InternalUpdateNonstrictCallback<${myExtendedObjectClassName}>() { public int callbackDelegateUpdateNonstrict(${myExtendedObjectClassName} entity) { return delegateUpdateNonstrict(entity); } }); } #end @Override protected void doModifyNonstrict(Entity entity) { #if ($table.hasOptimisticLock()) updateNonstrict(downcast(entity)); #else update(downcast(entity)); #end } /** * Insert or update the entity modified-only. {ExclusiveControl(when update)} * @param ${myEntityVariableName} The entity of insert or update target. (NotNull) #if ($table.hasOptimisticLock()) * @exception org.seasar.dbflute.exception.EntityAlreadyUpdatedException When the entity has already been updated. #else * @exception org.seasar.dbflute.exception.EntityAlreadyDeletedException When the entity has already been deleted. #end * @exception org.seasar.dbflute.exception.EntityDuplicatedException When the entity has been duplicated. * @exception org.seasar.dbflute.exception.EntityAlreadyExistsException When the entity already exists. (Unique Constraint Violation) */ public void insertOrUpdate(final ${myExtendedObjectClassName} ${myEntityVariableName}) { helpInsertOrUpdateInternally(${myEntityVariableName}, new InternalInsertOrUpdateCallback<${myExtendedObjectClassName}, ${myConditionBeanClassName}>() { public void callbackInsert(${myExtendedObjectClassName} entity) { insert(entity); } public void callbackUpdate(${myExtendedObjectClassName} entity) { update(entity); } public ${myConditionBeanClassName} callbackNewMyConditionBean() { return newMyConditionBean(); } public int callbackSelectCount(${myConditionBeanClassName} cb) { return selectCount(cb); } }); } @Override protected void doCreateOrUpdate(Entity entity) { insertOrUpdate(downcast(entity)); } #if ($table.hasOptimisticLock()) /** * Insert or update the entity non-strictly modified-only. {NonExclusiveControl(when update)} * @param ${myEntityVariableName} The entity of insert or update target. (NotNull) * @exception org.seasar.dbflute.exception.EntityAlreadyDeletedException When the entity has already been deleted. * @exception org.seasar.dbflute.exception.EntityDuplicatedException When the entity has been duplicated. * @exception org.seasar.dbflute.exception.EntityAlreadyExistsException When the entity already exists. (Unique Constraint Violation) */ public void insertOrUpdateNonstrict(${myExtendedObjectClassName} ${myEntityVariableName}) { helpInsertOrUpdateInternally(${myEntityVariableName}, new InternalInsertOrUpdateNonstrictCallback<${myExtendedObjectClassName}>() { public void callbackInsert(${myExtendedObjectClassName} entity) { insert(entity); } public void callbackUpdateNonstrict(${myExtendedObjectClassName} entity) { updateNonstrict(entity); } }); } #end @Override protected void doCreateOrUpdateNonstrict(Entity entity) { #if ($table.isUseUpdateDate() || $table.isUseVersionNo()) insertOrUpdateNonstrict(downcast(entity)); #else insertOrUpdate(downcast(entity)); #end } /** * Delete the entity. {UpdateCountZeroException, ExclusiveControl} *
* ${myExtendedObjectClassName} ${myEntityVariableName} = new ${myExtendedObjectClassName}(); * ${myEntityVariableName}.setPK...(value); // required * // if exclusive control, the value of exclusive control column is required * ${myEntityVariableName}.setVersionNo(value); * try { * ${myEntityVariableName}Bhv.delete(${myEntityVariableName}); * } catch (EntityAlreadyUpdatedException e) { // if concurrent update * ... * } ** @param ${myEntityVariableName} The entity of delete target. (NotNull) {PrimaryKeyRequired, ConcurrencyColumnRequired} #if ($table.hasOptimisticLock()) * @exception org.seasar.dbflute.exception.EntityAlreadyUpdatedException When the entity has already been updated. #else * @exception org.seasar.dbflute.exception.EntityAlreadyDeletedException When the entity has already been deleted. #end * @exception org.seasar.dbflute.exception.EntityDuplicatedException When the entity has been duplicated. */ public void delete(${myExtendedObjectClassName} ${myEntityVariableName}) { helpDeleteInternally(${myEntityVariableName}, new InternalDeleteCallback<${myExtendedObjectClassName}>() { public int callbackDelegateDelete(${myExtendedObjectClassName} entity) { return delegateDelete(entity); } }); } @Override protected void doRemove(Entity entity) { delete(downcast(entity)); } #if ($table.hasOptimisticLock()) /** * Delete the entity non-strictly. {UpdateCountZeroException, NonExclusiveControl} *
* ${myExtendedObjectClassName} ${myEntityVariableName} = new ${myExtendedObjectClassName}(); * ${myEntityVariableName}.setPK...(value); // required * // you don't need to set the value of exclusive control column * // (auto-increment for version number is valid though non-exclusive control) * //${myEntityVariableName}.setVersionNo(value); * ${myEntityVariableName}Bhv.deleteNonstrict(${myEntityVariableName}); ** @param ${myEntityVariableName} Entity. (NotNull) {PrimaryKeyRequired} * @exception org.seasar.dbflute.exception.EntityAlreadyDeletedException When the entity has already been deleted. * @exception org.seasar.dbflute.exception.EntityDuplicatedException When the entity has been duplicated. */ public void deleteNonstrict(${myExtendedObjectClassName} ${myEntityVariableName}) { helpDeleteNonstrictInternally(${myEntityVariableName}, new InternalDeleteNonstrictCallback<${myExtendedObjectClassName}>() { public int callbackDelegateDeleteNonstrict(${myExtendedObjectClassName} entity) { return delegateDeleteNonstrict(entity); } }); } /** * Delete the entity non-strictly ignoring deleted. {UpdateCountZeroException, NonExclusiveControl} *
* ${myExtendedObjectClassName} ${myEntityVariableName} = new ${myExtendedObjectClassName}(); * ${myEntityVariableName}.setPK...(value); // required * // you don't need to set the value of exclusive control column * // (auto-increment for version number is valid though non-exclusive control) * //${myEntityVariableName}.setVersionNo(value); * ${myEntityVariableName}Bhv.deleteNonstrictIgnoreDeleted(${myEntityVariableName}); * // if the target entity doesn't exist, no exception ** @param ${myEntityVariableName} Entity. (NotNull) {PrimaryKeyRequired} * @exception org.seasar.dbflute.exception.EntityDuplicatedException When the entity has been duplicated. */ public void deleteNonstrictIgnoreDeleted(${myExtendedObjectClassName} ${myEntityVariableName}) { helpDeleteNonstrictIgnoreDeletedInternally(${myEntityVariableName}, new InternalDeleteNonstrictIgnoreDeletedCallback<${myExtendedObjectClassName}>() { public int callbackDelegateDeleteNonstrict(${myExtendedObjectClassName} entity) { return delegateDeleteNonstrict(entity); } }); } #end // =================================================================================== // Batch Update // ============ /** * Batch-insert the list. This method uses 'Batch Update' of java.sql.PreparedStatement. * @param ${myEntityListVariableName} The list of the entity. (NotNull) * @return The array of inserted count. */ public int[] batchInsert(List<${myExtendedObjectClassName}> ${myEntityListVariableName}) { assertObjectNotNull("${myEntityListVariableName}", ${myEntityListVariableName}); return delegateInsertList(${myEntityListVariableName}); } /** * Batch-update the list.
* ${myExtendedObjectClassName} ${myEntityVariableName} = new ${myExtendedObjectClassName}(); * // you don't need to set PK value * //${myEntityVariableName}.setPK...(value); * ${myEntityVariableName}.setFoo...(value); // you should set only modified columns * // you don't need to set the value of exclusive control column * // (auto-increment for version number is valid though non-exclusive control) * //${myEntityVariableName}.setVersionNo(value); * ${myConditionBeanClassName} cb = new ${myConditionBeanClassName}(); * cb.query().setFoo...(value); * ${myEntityVariableName}Bhv.queryUpdate(${myEntityVariableName}, cb); ** @param ${myEntityVariableName} The entity that contains update values. (NotNull) {PrimaryKeyNotRequired} * @param cb The condition-bean of ${myExtendedObjectClassName}. (NotNull) * @return The updated count. */ public int queryUpdate(${myExtendedObjectClassName} ${myEntityVariableName}, ${myConditionBeanClassName} cb) { return delegateQueryUpdate(${myEntityVariableName}, cb); } /** * Query-delete the several entities. {NonExclusiveControl} *
* ${myConditionBeanClassName} cb = new ${myConditionBeanClassName}();
* cb.query().setFoo...(value);
* ${myEntityVariableName}Bhv.queryDelete(${myEntityVariableName}, cb);
*
* @param cb The condition-bean of ${myExtendedObjectClassName}. (NotNull)
* @return The deleted count.
*/
public int queryDelete(${myConditionBeanClassName} cb) {
return delegateQueryDelete(cb);
}
/**
* Varying-update the entity modified-only. {UpdateCountZeroException, ExclusiveControl}
* * ${myExtendedObjectClassName} ${myEntityVariableName} = new ${myExtendedObjectClassName}(); * ${myEntityVariableName}.setPK...(value); // required * ${myEntityVariableName}.setOther...(value); // you should set only modified columns * // if exclusive control, the value of exclusive control column is required * ${myEntityVariableName}.setVersionNo(value); * try { * UpdateOption<${myConditionBeanClassName}> option = new UpdateOption<${myConditionBeanClassName}>(); * option.self(new SpecifyQuery<${myConditionBeanClassName}>() { * public void specify(${myConditionBeanClassName} cb) { * cb.specify().columnXxxCount(); * } * }).plus(1); // XXX_COUNT = XXX_COUNT + 1 * ${myEntityVariableName}Bhv.varyingUpdate(${myEntityVariableName}, option); * } catch (EntityAlreadyUpdatedException e) { // if concurrent update * ... * } ** @param ${myEntityVariableName} The entity of update target. (NotNull) {PrimaryKeyRequired, ConcurrencyColumnRequired} * @param option The option of update for varying values. (NotNull) #if ($table.hasOptimisticLock()) * @exception org.seasar.dbflute.exception.EntityAlreadyUpdatedException When the entity has already been updated. #else * @exception org.seasar.dbflute.exception.EntityAlreadyDeletedException When the entity has already been deleted. #end * @exception org.seasar.dbflute.exception.EntityDuplicatedException When the entity has been duplicated. * @exception org.seasar.dbflute.exception.EntityAlreadyExistsException When the entity already exists. (Unique Constraint Violation) */ public void varyingUpdate(${myExtendedObjectClassName} ${myEntityVariableName}, final UpdateOption<${myConditionBeanClassName}> option) { processVaryingUpdate(option); helpUpdateInternally(${myEntityVariableName}, new InternalUpdateCallback<${myExtendedObjectClassName}>() { public int callbackDelegateUpdate(${myExtendedObjectClassName} entity) { return delegateVaryingUpdate(entity, option); } }); } #if ($table.hasOptimisticLock()) /** * Varying-update the entity non-strictly modified-only. {UpdateCountZeroException, NonExclusiveControl} *
* ${myExtendedObjectClassName} ${myEntityVariableName} = new ${myExtendedObjectClassName}(); * ${myEntityVariableName}.setPK...(value); // required * ${myEntityVariableName}.setOther...(value); // you should set only modified columns * // you don't need to set the value of exclusive control column * // (auto-increment for version number is valid though non-exclusive control) * //${myEntityVariableName}.setVersionNo(value); * UpdateOption<${myConditionBeanClassName}> option = new UpdateOption<${myConditionBeanClassName}>(); * option.self(new SpecifyQuery<${myConditionBeanClassName}>() { * public void specify(${myConditionBeanClassName} cb) { * cb.specify().columnFooCount(); * } * }).plus(1); // FOO_COUNT = FOO_COUNT + 1 * ${myEntityVariableName}Bhv.varyingUpdateNonstrict(${myEntityVariableName}, option); ** @param ${myEntityVariableName} The entity of update target. (NotNull) {PrimaryKeyRequired} * @param option The option of update for varying values. (NotNull) * @exception org.seasar.dbflute.exception.EntityAlreadyDeletedException When the entity has already been deleted. * @exception org.seasar.dbflute.exception.EntityDuplicatedException When the entity has been duplicated. * @exception org.seasar.dbflute.exception.EntityAlreadyExistsException When the entity already exists. (Unique Constraint Violation) */ public void varyingUpdateNonstrict(${myExtendedObjectClassName} ${myEntityVariableName}, final UpdateOption<${myConditionBeanClassName}> option) { processVaryingUpdate(option); helpUpdateNonstrictInternally(${myEntityVariableName}, new InternalUpdateNonstrictCallback<${myExtendedObjectClassName}>() { public int callbackDelegateUpdateNonstrict(${myExtendedObjectClassName} entity) { return delegateVaryingUpdateNonstrict(entity, option); } }); } #end /** * Varying-query-update the several entities non-strictly modified-only. {NonExclusiveControl} *
* ${myExtendedObjectClassName} ${myEntityVariableName} = new ${myExtendedObjectClassName}(); * // you don't need to set PK value * //${myEntityVariableName}.setPK...(value); * ${myEntityVariableName}.setOther...(value); // you should set only modified columns * // you don't need to set the value of exclusive control column * // (auto-increment for version number is valid though non-exclusive control) * //${myEntityVariableName}.setVersionNo(value); * ${myConditionBeanClassName} cb = new ${myConditionBeanClassName}(); * cb.query().setFoo...(value); * UpdateOption<${myConditionBeanClassName}> option = new UpdateOption<${myConditionBeanClassName}>(); * option.self(new SpecifyQuery<${myConditionBeanClassName}>() { * public void specify(${myConditionBeanClassName} cb) { * cb.specify().columnFooCount(); * } * }).plus(1); // FOO_COUNT = FOO_COUNT + 1 * ${myEntityVariableName}Bhv.varyingQueryUpdate(${myEntityVariableName}, cb, option); ** @param ${myEntityVariableName} The entity that contains update values. (NotNull) {PrimaryKeyNotRequired} * @param cb The condition-bean of ${myExtendedObjectClassName}. (NotNull) * @param option The option of update for varying values. (NotNull) * @return The updated count. */ public int varyingQueryUpdate(${myExtendedObjectClassName} ${myEntityVariableName}, ${myConditionBeanClassName} cb, final UpdateOption<${myConditionBeanClassName}> option) { processVaryingUpdate(option); return delegateVaryingQueryUpdate(${myEntityVariableName}, cb, option); } protected void processVaryingUpdate(UpdateOption<${myConditionBeanClassName}> option) { assertUpdateOptionNotNull(option); ${myConditionBeanClassName} cb = newMyConditionBean(); cb.xsetupForVaryingUpdate(); option.resolveSpecification(cb); } #else #if ($table.isAvailableNonPrimaryKeyWritable()) // =================================================================================== // Entity Update // ============= /** * Insert the entity. *
* ${myExtendedObjectClassName} ${myEntityVariableName} = new ${myExtendedObjectClassName}();
* ${myEntityVariableName}.setPK...(value);
* ${myEntityVariableName}.setFoo...(value);
* ${myEntityVariableName}.setBar...(value);
* ${myEntityVariableName}Bhv.insert(${myEntityVariableName});
*
* @param ${myEntityVariableName} The entity for insert. (NotNull)
*/
public void insert(${myExtendedObjectClassName} ${myEntityVariableName}) {
assertEntityNotNull(${myEntityVariableName});
delegateInsert(${myEntityVariableName});
}
#end
#end
#if ($table.isBuriTarget())
// ===================================================================================
// Buri Interface
// ==============
public ${myExtendedObjectClassName} xgetEntityForBuri(${table.primaryKeyArgsString}) { // For Buri
${myExtendedObjectClassName} entity = new ${myExtendedObjectClassName}();
${table.getPrimaryKeyArgsSetupString('entity')}
${myConditionBeanClassName} cb = newMyConditionBean();
cb.acceptPrimaryKeyMap(getDBMeta().extractPrimaryKeyMap(entity));
return selectEntity(cb);
}
public List<${myExtendedObjectClassName}> xgetEntitiesForBuri(List<${table.primaryKeyJavaNativeAsOne}> ids) { // For Buri
${myConditionBeanClassName} cb = newMyConditionBean();
cb.query().set${table.primaryKeyAsOne.javaName}_InScope(ids);
return selectList(cb);
}
protected org.escafe.buri.engine.processor.BuriAutoSelectProcessor _buriAutoSelectProcessor;
public void setBuriAutoSelectProcessor(org.escafe.buri.engine.processor.BuriAutoSelectProcessor buriAutoSelectProcessor) {
_buriAutoSelectProcessor = buriAutoSelectProcessor;
}
protected void toNextStatusAction(String processPath, Object entity, Object userData, String action) {
try {
_buriAutoSelectProcessor.toNextStatusAction(processPath, entity, userData, action);
} catch (org.seasar.coffee.script.exception.ScriptExecuteException e) {
if (e.getCause() instanceof ognl.MethodFailedException) {
ognl.MethodFailedException fail = (ognl.MethodFailedException) e.getCause();
Throwable reason = fail.getReason();
if (reason instanceof org.seasar.dbflute.exception.EntityAlreadyExistsException) {
throw (org.seasar.dbflute.exception.EntityAlreadyExistsException)reason;
} else if (reason instanceof org.seasar.dbflute.exception.EntityAlreadyDeletedException) {
throw (org.seasar.dbflute.exception.EntityAlreadyDeletedException)reason;
} else if (reason instanceof org.seasar.dbflute.exception.EntityAlreadyUpdatedException) {
throw (org.seasar.dbflute.exception.EntityAlreadyUpdatedException)reason;
}
}
throw e;
}
}
protected ${glBuriDef}.BuriUserDataProvider _buriUserDataProvider;
public void setBuriUserDataProvider(${glBuriDef}.BuriUserDataProvider buriUserDataProvider) {
_buriUserDataProvider = buriUserDataProvider;
}
#foreach ($processName in $table.tableProcessForMethodNameList)
public void toNextStatus_${processName}(${myExtendedObjectClassName} ${myEntityVariableName}, ${glBuriDef}.${processName}_Action action) {
assertEntityNotNull(${myEntityVariableName});
String processPath = ${glBuriDef}.BuriProcess.${processName}.path();
Object userData = getUserData_${processName}(${myEntityVariableName}, action);
toNextStatusAction(processPath, ${myEntityVariableName}, userData, action.code());
}
protected Object getUserData_${processName}(${myExtendedObjectClassName} ${myEntityVariableName}, ${glBuriDef}.${processName}_Action action) {
if (_buriUserDataProvider == null) { return null; }
return _buriUserDataProvider.provide(${glBuriDef}.BuriProcess.${processName}, ${myEntityVariableName}, action);
}
public ${glBuriDef}.${processName}_Status getStatus_${processName}(${myExtendedObjectClassName} ${myEntityVariableName}) {
assertEntityNotNullAndHasPrimaryKeyValue(${myEntityVariableName});
java.util.List