blob: 31306f496938610c01a2ebf80d76ab61fab42666 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
#if ($table.package != "")
package ${table.package};
#end
import java.io.Serializable;
import javax.persistence.*;
${table.importStatements}
/**
* The persistent class for the ${table.name} database table.
*
*/
@Entity
#if( !${table.defaultname} || $customizer.generateDDLAnnotations)
@Table(name=$customizer.convertToJavaStringLiteral(${table.name}))
#end
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.simplePropertyType} ${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.simpleCollectionType}<${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.simplePropertyType $customizer.propertyGetter($column.propertyName)() {
return this.${column.propertyName};
}
$column.propertySetScope void $customizer.propertySetter($column.propertyName)($column.simplePropertyType $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.simpleCollectionType}<${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
##
}
|