Subversion Repositories SmartDukaan

Rev

Rev 21717 | Rev 22009 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
21717 ashik.ali 1
package com.spice.profitmandi.dao.entity.user;
21545 ashik.ali 2
 
3
import java.io.Serializable;
4
import java.time.LocalDateTime;
5
 
6
import javax.persistence.Column;
7
import javax.persistence.Entity;
8
import javax.persistence.GeneratedValue;
9
import javax.persistence.GenerationType;
10
import javax.persistence.Id;
11
import javax.persistence.NamedQueries;
12
import javax.persistence.NamedQuery;
13
import javax.persistence.Table;
14
import javax.persistence.UniqueConstraint;
15
 
16
/**
17
 * This class basically contains address details
18
 * 
19
 * @author ashikali
20
 *
21
 */
22
@Entity
21665 amit.gupta 23
@Table(name="user.address", schema = "user", uniqueConstraints = {@UniqueConstraint(columnNames = {"name", "line_1", "line_2", "landmark", "city", "state", "pin", "country", "phone"})})
21545 ashik.ali 24
@NamedQueries({
21666 amit.gupta 25
	@NamedQuery(name = "Address.selectCount", query = "select count(a) from Address a where a.retailerId= :retailerId"),
21674 amit.gupta 26
	@NamedQuery(name="Address.selectAll",query="select a from Address a where a.retailerId= :retailerId order by a.updateTimestamp desc"),
21545 ashik.ali 27
	@NamedQuery(name="Address.selectById",query="select a from Address a where a.id= :id"),
28
	@NamedQuery(name="Address.selectByIds",query="select a from Address a where a.id in :ids"),
29
	@NamedQuery(name="Address.selectByParams",query="select a from Address a where a.name= :name and a.line1 = :line1 and a.line2 = :line2 and a.landmark = :landmark and a.city = :city and a.state = :state and a.pinCode = :pinCode and a.country = :country and a.phoneNumber = :phoneNumber"),
30
	@NamedQuery(name="Address.deleteById",query="delete from Address a where a.id= :id"),
31
})
32
public class Address implements Serializable{
33
 
34
	private static final long serialVersionUID = 1L;
35
 
36
	public Address() {
37
	}
38
 
39
	@Id
40
	@Column(name="id", unique=true, updatable=false)
41
	@GeneratedValue(strategy = GenerationType.IDENTITY)
42
	private int id;
43
 
44
	@Column(name="name")
45
	private String name;
46
 
47
	@Column(name = "line_1")
48
	private String line1;
49
 
50
	@Column(name = "line_2")
51
	private String line2;
52
 
53
	@Column(name = "landmark")
54
	private String landmark;
55
 
56
	@Column(name = "city")
57
	private String city;
58
 
59
	@Column(name = "state")
60
	private String state;
61
 
62
	@Column(name = "pin", length = 10)
63
	private String pinCode;
64
 
65
	@Column(name = "country", length = 100)
66
	private String country;
67
 
68
	@Column(name = "phone", length = 20)
69
	private String phoneNumber;
70
 
71
	@Column(name = "enabled", columnDefinition="tinyint(1) default 0")
72
	private boolean enabled;
21666 amit.gupta 73
 
74
	@Column(name = "user_id")
75
	private int retailerId;
21545 ashik.ali 76
 
77
	@Column(name="added_on", updatable = false)
78
	private LocalDateTime createTimestamp = LocalDateTime.now();
79
 
80
	@Column(name="update_timestamp")
81
	private LocalDateTime updateTimestamp = LocalDateTime.now();
82
 
83
	public int getId() {
84
		return id;
85
	}
86
	public void setId(int id) {
87
		this.id = id;
88
	}
89
	public void setName(String name) {
90
        this.name = name;
91
    }
92
    public String getName() {
93
        return name;
94
    }
95
    public void setLine1(String line1) {
96
		this.line1 = line1;
97
	}
98
    public String getLine1() {
99
		return line1;
100
	}
101
    public void setLine2(String line2) {
102
		this.line2 = line2;
103
	}
104
    public String getLine2() {
105
		return line2;
106
	}
107
    public void setLandmark(String landmark) {
108
		this.landmark = landmark;
109
	}
110
    public String getLandmark() {
111
		return landmark;
112
	}
113
    public void setCity(String city) {
114
		this.city = city;
115
	}
116
    public String getCity() {
117
		return city;
118
	}
119
    public void setPinCode(String pinCode) {
120
		this.pinCode = pinCode;
121
	}
122
    public String getPinCode() {
123
		return pinCode;
124
	}
125
    public void setState(String state) {
126
		this.state = state;
127
	}
128
    public String getState() {
129
		return state;
130
	}
131
    public void setCountry(String country) {
132
		this.country = country;
133
	}
134
    public String getCountry() {
135
		return country;
136
	}
137
    public void setPhoneNumber(String phoneNumber) {
138
		this.phoneNumber = phoneNumber;
139
	}
140
    public String getPhoneNumber() {
141
		return phoneNumber;
142
	}
143
    public void setEnabled(boolean enabled) {
144
		this.enabled = enabled;
145
	}
146
    public boolean isEnabled() {
147
		return enabled;
148
	}
149
 
150
    public void setCreateTimestamp(LocalDateTime createTimestamp) {
151
		this.createTimestamp = createTimestamp;
152
	}
153
    public LocalDateTime getCreateTimestamp() {
154
		return createTimestamp;
155
	}
156
 
157
    public void setUpdateTimestamp(LocalDateTime updateTimestamp) {
158
		this.updateTimestamp = updateTimestamp;
159
	}
160
    public LocalDateTime getUpdateTimestamp() {
161
		return updateTimestamp;
162
	}
163
 
21666 amit.gupta 164
	public int getRetaierId() {
165
		return retailerId;
21545 ashik.ali 166
	}
21666 amit.gupta 167
	public void setRetaierId(int retailerId) {
168
		this.retailerId = retailerId;
21545 ashik.ali 169
	}
21924 ashik.ali 170
 
171
 
21545 ashik.ali 172
	@Override
21924 ashik.ali 173
	public int hashCode() {
174
		final int prime = 31;
175
		int result = 1;
176
		result = prime * result + ((city == null) ? 0 : city.hashCode());
177
		result = prime * result + ((country == null) ? 0 : country.hashCode());
178
		result = prime * result + ((createTimestamp == null) ? 0 : createTimestamp.hashCode());
179
		result = prime * result + (enabled ? 1231 : 1237);
180
		result = prime * result + id;
181
		result = prime * result + ((landmark == null) ? 0 : landmark.hashCode());
182
		result = prime * result + ((line1 == null) ? 0 : line1.hashCode());
183
		result = prime * result + ((line2 == null) ? 0 : line2.hashCode());
184
		result = prime * result + ((name == null) ? 0 : name.hashCode());
185
		result = prime * result + ((phoneNumber == null) ? 0 : phoneNumber.hashCode());
186
		result = prime * result + ((pinCode == null) ? 0 : pinCode.hashCode());
187
		result = prime * result + retailerId;
188
		result = prime * result + ((state == null) ? 0 : state.hashCode());
189
		result = prime * result + ((updateTimestamp == null) ? 0 : updateTimestamp.hashCode());
190
		return result;
191
	}
192
	@Override
193
	public boolean equals(Object obj) {
194
		if (this == obj)
195
			return true;
196
		if (obj == null)
197
			return false;
198
		if (getClass() != obj.getClass())
199
			return false;
200
		Address other = (Address) obj;
201
		if (city == null) {
202
			if (other.city != null)
203
				return false;
204
		} else if (!city.equals(other.city))
205
			return false;
206
		if (country == null) {
207
			if (other.country != null)
208
				return false;
209
		} else if (!country.equals(other.country))
210
			return false;
211
		if (createTimestamp == null) {
212
			if (other.createTimestamp != null)
213
				return false;
214
		} else if (!createTimestamp.equals(other.createTimestamp))
215
			return false;
216
		if (enabled != other.enabled)
217
			return false;
218
		if (id != other.id)
219
			return false;
220
		if (landmark == null) {
221
			if (other.landmark != null)
222
				return false;
223
		} else if (!landmark.equals(other.landmark))
224
			return false;
225
		if (line1 == null) {
226
			if (other.line1 != null)
227
				return false;
228
		} else if (!line1.equals(other.line1))
229
			return false;
230
		if (line2 == null) {
231
			if (other.line2 != null)
232
				return false;
233
		} else if (!line2.equals(other.line2))
234
			return false;
235
		if (name == null) {
236
			if (other.name != null)
237
				return false;
238
		} else if (!name.equals(other.name))
239
			return false;
240
		if (phoneNumber == null) {
241
			if (other.phoneNumber != null)
242
				return false;
243
		} else if (!phoneNumber.equals(other.phoneNumber))
244
			return false;
245
		if (pinCode == null) {
246
			if (other.pinCode != null)
247
				return false;
248
		} else if (!pinCode.equals(other.pinCode))
249
			return false;
250
		if (retailerId != other.retailerId)
251
			return false;
252
		if (state == null) {
253
			if (other.state != null)
254
				return false;
255
		} else if (!state.equals(other.state))
256
			return false;
257
		if (updateTimestamp == null) {
258
			if (other.updateTimestamp != null)
259
				return false;
260
		} else if (!updateTimestamp.equals(other.updateTimestamp))
261
			return false;
262
		return true;
263
	}
264
	@Override
21545 ashik.ali 265
	public String toString() {
266
		return "Address [id=" + id + ", name=" + name + ", line1=" + line1 + ", line2=" + line2 + ", landmark="
267
				+ landmark + ", city=" + city + ", state=" + state + ", pinCode=" + pinCode + ", country=" + country
268
				+ ", phoneNumber=" + phoneNumber + ", enabled=" + enabled + ", createTimestamp=" + createTimestamp
21602 ashik.ali 269
				+ ", updateTimestamp=" + updateTimestamp + "]";
21545 ashik.ali 270
	}
271
 
272
 
273
}