1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.imca.model.entities;
17
18 import javax.persistence.Entity;
19 import javax.persistence.GeneratedValue;
20 import javax.persistence.GenerationType;
21 import javax.persistence.Id;
22 import javax.persistence.NamedQueries;
23 import javax.persistence.NamedQuery;
24
25
26
27
28
29
30
31
32 @Entity
33 @NamedQueries ({
34 @NamedQuery(name = "AddressBasicSearch",
35 query = "SELECT a FROM AddressEntity a WHERE " +
36 "a.street1 LIKE :search " +
37 "OR a.street2 LIKE :search " +
38 "OR a.city LIKE :search " +
39 "OR a.area LIKE :search")
40 })
41 public class AddressEntity {
42
43
44
45
46 @Id
47 @GeneratedValue(strategy=GenerationType.TABLE)
48 private long id;
49
50
51
52
53 private String street1 = "";
54
55
56
57
58 private String street2 = "";
59
60
61
62
63 private String city = "";
64
65
66
67
68 private String area = "";
69
70
71
72
73 private String postCode = "";
74
75
76
77
78 private String countryCode = "";
79
80
81
82
83
84
85 public String getArea() {
86 return area;
87 }
88
89
90
91
92 public void setArea(String area) {
93 this.area = area;
94 }
95
96
97
98
99
100
101 public String getCity() {
102 return city;
103 }
104
105
106
107
108 public void setCity(String city) {
109 this.city = city;
110 }
111
112
113
114
115
116
117 public String getCountryCode() {
118 return countryCode;
119 }
120
121
122
123
124 public void setCountryCode(String countryCode) {
125 this.countryCode = countryCode;
126 }
127
128
129
130
131
132
133 public long getId() {
134 return id;
135 }
136
137
138
139
140 public void setId(long id) {
141 this.id = id;
142 }
143
144
145
146
147
148
149 public String getPostCode() {
150 return postCode;
151 }
152
153
154
155
156 public void setPostCode(String postCode) {
157 this.postCode = postCode;
158 }
159
160
161
162
163
164
165 public String getStreet1() {
166 return street1;
167 }
168
169
170
171
172 public void setStreet1(String street1) {
173 this.street1 = street1;
174 }
175
176
177
178
179
180
181 public String getStreet2() {
182 return street2;
183 }
184
185
186
187
188 public void setStreet2(String street2) {
189 this.street2 = street2;
190 }
191
192
193
194
195
196 public String toString(){
197 StringBuffer buf = new StringBuffer();
198 addToString(buf, this.street1);
199 addToString(buf, this.street2);
200 addToString(buf, this.city);
201 addToString(buf, this.area);
202 addToString(buf, this.postCode);
203 addToString(buf, this.countryCode);
204 return buf.toString();
205 }
206
207
208
209
210
211
212
213 private void addToString(StringBuffer buf, String field){
214 if (field != null && field.length() > 0) {
215 if (buf.length() > 0){
216 buf.append(", ");
217 }
218 buf.append(field);
219 }
220 }
221 }