${database.allClassCopyright}package ${myBaseEntityPackageName};
#set ($myClassName = "${myBaseObjectClassName}")
import java.io.Serializable;
import java.util.*;
import org.seasar.dbflute.dbmeta.DBMeta;
#if (!$table.hasAllCommonColumn() || $table.hasRelation())
import org.seasar.dbflute.Entity;
#end
#if ($table.hasAllCommonColumn())
import ${glPackageBaseCommon}.${glEntityDefinedCommonColumn};
#end
#if (!$isSql2Entity)
import ${glPackageBaseCommon}.${glDBMetaInstanceHandler};
#end
#if ($table.hasClassification())
import ${glPackageBaseCommon}.${glCDef};
#end
#if ($table.isBuriTarget())
import ${glPackagePluginBuri}.${glBuriDef};
#end
#if ($table.hasRelation() || $table.isSql2EntityCustomizeHasNested())
import ${myExtendedEntityPackageName}.*;
#end
#if ($table.isLoadableCustomizeEntity())
import ${glPackageExtendedEntity}.*;
#end
#set ($myEntityInterfaceName = "")
#if (${table.hasAllCommonColumn()})
#set ($myEntityInterfaceName = ${glEntityDefinedCommonColumn})
#else
#set ($myEntityInterfaceName = "Entity")
#end
/**
* The entity of ${table.basicInfoDispString}.
#if ($table.isCommentForJavaDocValid())
* ${table.commentForJavaDoc}
#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 implements ${myEntityInterfaceName}, Serializable {
// ===================================================================================
// Definition
// ==========
/** Serial version UID. (Default) */
private static final long serialVersionUID = 1L;
// ===================================================================================
// Attribute
// =========
// -----------------------------------------------------
// Column
// ------
#foreach ($col in $table.columns)
/** ${col.aliasExpression}${col.name}: {${col.columnDefinitionLineDisp}} */
protected ${col.javaNative} _${col.uncapitalisedJavaName};
#end
// -----------------------------------------------------
// Internal
// --------
/** The modified properties for this entity. */
protected EntityModifiedProperties __modifiedProperties = newEntityModifiedProperties();
#if ($table.hasAllCommonColumn())
/** Is common column auto set up effective? */
protected boolean __canCommonColumnAutoSetup = true;
#end
// ===================================================================================
// Table Name
// ==========
/**
* {@inheritDoc}
*/
public String getTableDbName() {
return "${table.name}";
}
/**
* {@inheritDoc}
*/
public String getTablePropertyName() { // according to Java Beans rule
return "${table.javaBeansRulePropertyName}";
}
// ===================================================================================
// DBMeta
// ======
/**
* {@inheritDoc}
*/
public DBMeta getDBMeta() {
#if ($isSql2Entity)
return ${myDBMetaPackageName}.${myDBMetaClassName}.getInstance();
#else
return ${glDBMetaInstanceHandler}.findDBMeta(getTableDbName());
#end
}
// ===================================================================================
// Primary Key
// ===========
/**
* {@inheritDoc}
*/
public boolean hasPrimaryKeyValue() {
#foreach ($col in $table.primaryKey)
if (get${col.javaName}() == null) { return false; }
#end
return ${table.hasPrimaryKey()};
}
#if ($table.hasClassification())
// ===================================================================================
// Classification Property
// =======================
#foreach ($col in $table.columns)
#if ($col.hasClassification())
#set ($existTop = false)
#if ($database.classificationTopDefinitionMap.containsKey($col.classificationName))
#set ($classificationTopMap = $database.classificationTopDefinitionMap.get($col.classificationName))
#set ($existTop = true)
#end
/**
* Set the value of ${col.uncapitalisedJavaName} as the classification of ${col.classificationName}. It's treated as case insensitive and if the code value is null, it returns null.
* @return The instance of classification definition (as ENUM type). (Nullable) */ public ${glCDef}.${col.classificationName} get${col.javaName}As${col.classificationName}() { return ${glCDef}.${col.classificationName}.codeOf(get${col.javaName}()); } #end #end // =================================================================================== // Classification Setting // ====================== #foreach ($col in $table.columns) #if ($col.hasClassification()) #foreach ($classificationMap in $col.classificationMapList) /** * Set the value of ${col.uncapitalisedJavaName} as ${classificationMap.get('name')}.It's treated as case insensitive and if the code value is null, it returns false.
* @return Determination. */ public boolean is${col.JavaName}${classificationMap.get('name')}() { ${glCDef}.${col.classificationName} cdef = get${col.javaName}As${col.classificationName}(); return cdef != null ? cdef.equals(${glCDef}.${col.classificationName}.${classificationMap.get('name')}) : false; } #end #end #end #if ($table.hasImplicitClassification()) // =================================================================================== // Classification Name/Alias // ========================= #foreach ($col in $table.columns) #if ($col.hasClassification()) #if (!$col.isTableClassification()) #if ($col.hasClassificationName()) /** * Get the value of the column '${col.uncapitalisedJavaName}' as classification name. * @return The string of classification name. (Nullable) */ public String get${col.JavaName}Name() { ${glCDef}.${col.classificationName} cdef = get${col.javaName}As${col.classificationName}(); return cdef != null ? cdef.name() : null; } #end #if (${col.hasClassificationAlias()}) /** * Get the value of the column '${col.uncapitalisedJavaName}' as classification alias. * @return The string of classification alias. (Nullable) */ public String get${col.JavaName}Alias() { ${glCDef}.${col.classificationName} cdef = get${col.javaName}As${col.classificationName}(); return cdef != null ? cdef.alias() : null; } #end #end #end #end #end #end // =================================================================================== // Foreign Property // ================ #set ($foreignKeyIndex = 0) #foreach ($fk in $table.foreignKeys) #set ($foreignTable = $fk.foreignTable) #set ($foreignEntityClassName = "${fk.foreignTableExtendedEntityClassName}") #set ($foreignVariableName = "_${fk.foreignPropertyName}") /** ${fk.foreignSimpleDisp}. */ protected ${foreignEntityClassName} ${foreignVariableName}; /** * ${fk.foreignDispForJavaDoc} * @return The entity of foreign property '${fk.foreignJavaBeansRulePropertyName}'. (Nullable: If the foreign key does not have 'NotNull' constraint, please check null.) */ public ${foreignEntityClassName} get${fk.foreignJavaBeansRulePropertyNameInitCap}() { return ${foreignVariableName}; } /** * ${fk.foreignDispForJavaDoc} * @param ${fk.foreignPropertyName} The entity of foreign property '${fk.foreignJavaBeansRulePropertyName}'. (Nullable) */ public void set${fk.foreignJavaBeansRulePropertyNameInitCap}(${foreignEntityClassName} ${fk.foreignPropertyName}) { ${foreignVariableName} = ${fk.foreignPropertyName}; } #if ($database.isMakeEntityChaseRelation()) public ${foreignEntityClassName} chase${fk.foreignJavaBeansRulePropertyNameInitCap}() { return ${foreignVariableName} != null ? ${foreignVariableName} : new ${foreignEntityClassName}(); } #end #set ($foreignKeyIndex = $foreignKeyIndex + 1) #end #foreach ($referrer in $table.referrerAsOneList) #set ($referrerTable = $referrer.table) #set ($referrerEntityClassName = "${referrer.referrerTableExtendedEntityClassName}") #set ($referrerVariableName = "_${referrer.referrerPropertyNameAsOne}") /** ${referrer.referrerSimpleDispAsOne}. */ protected ${referrerEntityClassName} ${referrerVariableName}; /** * ${referrer.referrerDispAsOneForJavaDoc} * @return the entity of foreign property(referrer-as-one) '${referrer.referrerJavaBeansRulePropertyNameAsOne}'. (Nullable: If the foreign key does not have 'NotNull' constraint, please check null.) */ public ${referrerEntityClassName} get${referrer.referrerJavaBeansRulePropertyNameAsOneInitCap}() { return ${referrerVariableName}; } /** * ${referrer.referrerDispAsOneForJavaDoc} * @param ${referrer.referrerJavaBeansRulePropertyNameAsOne} The entity of foreign property(referrer-as-one) '${referrer.referrerJavaBeansRulePropertyNameAsOne}'. (Nullable) */ public void set${referrer.referrerJavaBeansRulePropertyNameAsOneInitCap}(${referrerEntityClassName} ${referrer.referrerJavaBeansRulePropertyNameAsOne}) { ${referrerVariableName} = ${referrer.referrerJavaBeansRulePropertyNameAsOne}; } #if ($database.isMakeEntityChaseRelation()) public ${referrerEntityClassName} chase${referrer.referrerJavaBeansRulePropertyNameAsOneInitCap}() { return ${referrerVariableName} != null ? ${referrerVariableName} : new ${referrerEntityClassName}(); } #end #set ($foreignKeyIndex = $foreignKeyIndex + 1) #end // =================================================================================== // Referrer Property // ================= #foreach ($referrer in $table.referrerAsManyList) #set ($referrerTable = $referrer.table) #set ($referrerEntityClassName = "${referrer.referrerTableExtendedEntityClassName}") #set ($referrerVariableName = "_${referrer.referrerPropertyName}") /** ${referrer.referrerSimpleDisp}. */ protected List<${referrerEntityClassName}> $referrerVariableName; /** * ${referrer.referrerDispForJavaDoc} * @return The entity list of referrer property '${referrer.referrerJavaBeansRulePropertyName}'. (NotNull: If it's not loaded yet, initializes the list instance of referrer as empty and returns it.) */ public List<${referrerEntityClassName}> get${referrer.referrerJavaBeansRulePropertyNameInitCap}() { if (${referrerVariableName} == null) { ${referrerVariableName} = new ArrayList<${referrerEntityClassName}>(); } return ${referrerVariableName}; } /** * ${referrer.referrerDispForJavaDoc} * @param ${referrer.referrerPropertyName} The entity list of referrer property '${referrer.referrerJavaBeansRulePropertyName}'. (Nullable) */ public void set${referrer.referrerJavaBeansRulePropertyNameInitCap}(List<${referrerEntityClassName}> ${referrer.referrerPropertyName}) { ${referrerVariableName} = ${referrer.referrerPropertyName}; } #end #if ($table.isBuriTarget() && $database.hasBuriAllRoundStateHistory()) #foreach ($processName in $table.tableProcessForMethodNameList) #set ($referrerEntityClassName = "${glProjectPrefix}BuriAllRoundStateHistory") #set ($referrerVariableName = "_buriAllRoundStateHistory_${processName}") protected List<${referrerEntityClassName}> $referrerVariableName; public List<${referrerEntityClassName}> getBuriAllRoundStateHistory_${processName}List() { if (${referrerVariableName} == null) { ${referrerVariableName} = new ArrayList<${referrerEntityClassName}>(); } return ${referrerVariableName}; } public void setBuriAllRoundStateHistory_${processName}List(List<${referrerEntityClassName}> buriAllRoundStateHistory_${processName}) { ${referrerVariableName} = buriAllRoundStateHistory_${processName}; } #end #end #if ($table.isLoadableCustomizeEntity()) #set ($domain = $table.loadableCustomizeDomain) protected ${domain.extendedEntityClassName} __innerDomain; protected ${domain.extendedEntityClassName} innerDomain() { if (__innerDomain == null) { __innerDomain = new ${domain.extendedEntityClassName}(); } return __innerDomain; } /** * Prepare the inner instance of domain entity (basically for LoadReferrer). *
* List<UnpaidSummaryMember> memberList = memberBhv.outsideSql()...;
* List<Member> domainList = new ArrayList<Member>();
* for (UnpaidSummaryMember member : memberList) {
* domainList.add(member.prepareDomain());
* }
* memberBhv.loadPurchaseList(domainList, new ConditionBeanSetupper...);
* for (UnpaidSummaryMember member : memberList) {
* Purchase purchase = member.getPurchaseList(); // you can get it
* ...
* }
*
* @return The domain entity for this customize entity.
*/
public ${domain.extendedEntityClassName} prepareDomain() {
#foreach ($exp in $table.loadableCustomizePrimaryKeySettingExpressionList)
innerDomain().${exp};
#end
return innerDomain();
}
#foreach ($referrer in $domain.referrerAsManyList)
#set ($referrerTable = $referrer.table)
#set ($referrerEntityClassName = "${referrer.referrerTableExtendedEntityClassName}")
/**
* ${referrer.referrerDispForJavaDoc}
* @return The entity list of referrer property '${referrer.referrerJavaBeansRulePropertyName}'. (NotNull: If it's not loaded yet, initializes the list instance of referrer as empty and returns it.)
*/
public List<${referrerEntityClassName}> get${referrer.referrerJavaBeansRulePropertyNameInitCap}() {
return innerDomain().get${referrer.referrerJavaBeansRulePropertyNameInitCap}();
}
#end
#end
// ===================================================================================
// Modified Properties
// ===================
/**
* {@inheritDoc}
*/
public Set