1
+ package com .swesource .sample .jee .domain ;
2
+
3
+ import org .hibernate .envers .Audited ;
4
+
5
+ import javax .persistence .Column ;
6
+ import javax .persistence .Entity ;
7
+ import javax .persistence .GeneratedValue ;
8
+ import javax .persistence .Id ;
9
+ import javax .persistence .Temporal ;
10
+ import javax .persistence .TemporalType ;
11
+ import javax .validation .constraints .Digits ;
12
+ import javax .validation .constraints .Size ;
13
+ import java .io .Serializable ;
14
+ import java .util .Date ;
15
+
16
+ /**
17
+ * @author arnie
18
+ */
19
+ @ Entity
20
+ @ Audited
21
+ public class Address implements Serializable {
22
+
23
+ private static final long serialVersionUID = 1L ;
24
+ private static final int ZIP_LENGTH = 5 ;
25
+ private static final int COUNTRY_MAX = 2 ;
26
+ private static final int COUNTRY_MIN = 2 ;
27
+
28
+ @ Id
29
+ @ GeneratedValue
30
+ private Long id ;
31
+
32
+ private String street ;
33
+
34
+ private String city ;
35
+
36
+ @ Column (length = ZIP_LENGTH )
37
+ @ Digits (integer = ZIP_LENGTH , fraction = 0 )
38
+ private String zip ;
39
+
40
+ /* ISO 3166 A2 compliant country code */
41
+ @ Column (length = COUNTRY_MAX )
42
+ @ Size (min = COUNTRY_MIN , max = COUNTRY_MAX )
43
+ private String country ;
44
+
45
+ @ Temporal (value = TemporalType .DATE )
46
+ private Date movingInDate ;
47
+
48
+ @ Override
49
+ public String toString () {
50
+ return this .getClass ().getName () + "@" + hashCode () + " [id = " + id + "]" ;
51
+ }
52
+
53
+ public Long getId () {
54
+ return id ;
55
+ }
56
+
57
+ public void setId (Long id ) {
58
+ this .id = id ;
59
+ }
60
+
61
+ public String getStreet () {
62
+ return street ;
63
+ }
64
+
65
+ public void setStreet (String street ) {
66
+ this .street = street ;
67
+ }
68
+
69
+ public String getCity () {
70
+ return city ;
71
+ }
72
+
73
+ public void setCity (String city ) {
74
+ this .city = city ;
75
+ }
76
+
77
+ public String getZip () {
78
+ return zip ;
79
+ }
80
+
81
+ public void setZip (String zip ) {
82
+ this .zip = zip ;
83
+ }
84
+
85
+ public String getCountry () {
86
+ return country ;
87
+ }
88
+
89
+ public void setCountry (String country ) {
90
+ this .country = country ;
91
+ }
92
+
93
+ public Date getMovingInDate () {
94
+ return movingInDate ;
95
+ }
96
+
97
+ public void setMovingInDate (Date movingInDate ) {
98
+ this .movingInDate = movingInDate ;
99
+ }
100
+ }
0 commit comments