blob: 28c861c8443e41ccfd119cf51c2c2b779d387edd [file] [log] [blame]
#if ($table.package != "")
package ${table.package};
#end
import java.io.Serializable;
import javax.persistence.*;
/**
* The persistent class for the ${table.name} database table.
*
*/
@Entity
@Table(name="${table.name}")
public class ${table.className} ${table.generateExtendsImplements()} {
private static final long serialVersionUID = 1L;
#####
##### fields
#####
#if ($table.compositeKey)
#if ($table.access == "field")
@EmbeddedId
#end
private ${table.compositeKeyClassName} ${table.compositeKeyPropertyName};
#end
#foreach ($column in $table.getSimpleColumns(true, true, false))
#if ($table.access == "field")
#parse("mappingKind.vm")
#parse("column.vm")
#end
${column.fieldScope} ${column.propertyType} ${column.propertyName};
#end
#foreach ($role in $table.associationRoles)
#####
##### field annotations
#####
#if ($table.access == "field")
//${role.description}
#if ($role.cardinality == "many-to-one")
#parse("manyToOne.vm")
#elseif ($role.cardinality == "many-to-many")
#parse("manyToMany.vm")
#elseif ($role.cardinality == "one-to-many")
#parse("oneToMany.vm")
#elseif ($role.cardinality == "one-to-one")
#parse("oneToOne.vm")
#end
#end
#####
##### field declaration
#####
#if ($role.cardinality == "many-to-one" || $role.cardinality == "one-to-one")
#set ($propertyType = ${role.referencedTable.className})
#elseif ($role.cardinality == "many-to-many" || $role.cardinality == "one-to-many")
#set ($propertyType = "${role.referencedTable.defaultCollectionType}<${role.referencedTable.className}>")
#end
private $propertyType $role.propertyName;
#end
public ${table.className}() {
}
#####
##### simple properties getters and setters
#####
#if ($table.compositeKey)
#if ($table.access == "property")
@EmbeddedId
#end
public $table.compositeKeyClassName $customizer.propertyGetter($table.compositeKeyPropertyName)() {
return this.${table.compositeKeyPropertyName};
}
public void $customizer.propertySetter($table.compositeKeyPropertyName)($table.compositeKeyClassName $table.compositeKeyPropertyName) {
this.${table.compositeKeyPropertyName} = ${table.compositeKeyPropertyName};
}
#end
#foreach ($column in $table.getSimpleColumns(true, true, false))
#if ($table.access == "property")
#parse("mappingKind.vm")
#parse("column.vm")
#end
$column.propertyGetScope $column.propertyType $customizer.propertyGetter($column.propertyName)() {
return this.${column.propertyName};
}
$column.propertySetScope void $customizer.propertySetter($column.propertyName)($column.propertyType $column.propertyName) {
this.${column.propertyName} = ${column.propertyName};
}
#end
#####
##### associations getters and setters
#####
#foreach ($role in $table.associationRoles)
#if ($table.access == "property")
//${role.description}
#if ($role.cardinality == "many-to-one")
#parse("manyToOne.vm")
#elseif ($role.cardinality == "many-to-many")
#parse("manyToMany.vm")
#elseif ($role.cardinality == "one-to-many")
#parse("oneToMany.vm")
#elseif ($role.cardinality == "one-to-one")
#parse("oneToOne.vm")
#end
#end
##
#if ($role.cardinality == "many-to-one" || $role.cardinality == "one-to-one")
#set ($propertyType = $role.referencedTable.className)
#elseif ($role.cardinality == "many-to-many" || $role.cardinality == "one-to-many")
#set ($propertyType = "${role.referencedTable.defaultCollectionType}<${role.referencedTable.className}>")
#end
public $propertyType $customizer.propertyGetter($role.propertyName)() {
return this.${role.propertyName};
}
public void ${customizer.propertySetter($role.propertyName)}($propertyType $role.propertyName) {
this.${role.propertyName} = $role.propertyName;
}
##
#end
##
}