blob: 1831098585755a5078c446e6e1eeea0c6015dc4d (
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
|
#if ($table.package != "")
package ${table.package};
#end
import java.io.Serializable;
import javax.persistence.*;
/**
* The primary key class for the ${table.name} database table.
*
*/
@Embeddable
public class ${table.compositeKeyClassName} implements Serializable {
//default serial version id, required for serializable classes.
private static final long serialVersionUID = 1L;
#####
##### fields
#####
#foreach ($column in $table.primaryKeyColumns)
#if ($table.access == "field")
#parse("column.vm")
#end
${column.fieldScope} ${column.propertyType} ${column.propertyName};
#end
public ${table.compositeKeyClassName}() {
}
#####
##### simple properties getters and setters
#####
#foreach ($column in $table.primaryKeyColumns)
#if ($table.access == "property")
#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
##
## equals/hashCode
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ${table.compositeKeyClassName})) {
return false;
}
${table.compositeKeyClassName} castOther = (${table.compositeKeyClassName})other;
return
${table.primaryKeyEqualsClause}
}
public int hashCode() {
final int prime = 31;
int hash = 17;
${table.primaryKeyHashCodeClause}
return hash;
}
}
|