Subversion Repositories SmartDukaan

Rev

Rev 21924 | Rev 22216 | 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;
22009 ashik.ali 7
import javax.persistence.Convert;
21545 ashik.ali 8
import javax.persistence.Entity;
9
import javax.persistence.GeneratedValue;
10
import javax.persistence.GenerationType;
11
import javax.persistence.Id;
12
import javax.persistence.NamedQueries;
13
import javax.persistence.NamedQuery;
14
import javax.persistence.Table;
15
import javax.persistence.UniqueConstraint;
16
 
22009 ashik.ali 17
import com.spice.profitmandi.dao.convertor.LocalDateTimeAttributeConverter;
18
 
21545 ashik.ali 19
/**
20
 * This class basically contains address details
21
 * 
22
 * @author ashikali
23
 *
24
 */
25
@Entity
21665 amit.gupta 26
@Table(name="user.address", schema = "user", uniqueConstraints = {@UniqueConstraint(columnNames = {"name", "line_1", "line_2", "landmark", "city", "state", "pin", "country", "phone"})})
21545 ashik.ali 27
@NamedQueries({
21666 amit.gupta 28
	@NamedQuery(name = "Address.selectCount", query = "select count(a) from Address a where a.retailerId= :retailerId"),
21674 amit.gupta 29
	@NamedQuery(name="Address.selectAll",query="select a from Address a where a.retailerId= :retailerId order by a.updateTimestamp desc"),
21545 ashik.ali 30
	@NamedQuery(name="Address.selectById",query="select a from Address a where a.id= :id"),
31
	@NamedQuery(name="Address.selectByIds",query="select a from Address a where a.id in :ids"),
32
	@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"),
33
	@NamedQuery(name="Address.deleteById",query="delete from Address a where a.id= :id"),
34
})
35
public class Address implements Serializable{
36
 
37
	private static final long serialVersionUID = 1L;
38
 
39
	public Address() {
40
	}
41
 
42
	@Id
43
	@Column(name="id", unique=true, updatable=false)
44
	@GeneratedValue(strategy = GenerationType.IDENTITY)
45
	private int id;
46
 
47
	@Column(name="name")
48
	private String name;
49
 
50
	@Column(name = "line_1")
51
	private String line1;
52
 
53
	@Column(name = "line_2")
54
	private String line2;
55
 
56
	@Column(name = "landmark")
57
	private String landmark;
58
 
59
	@Column(name = "city")
60
	private String city;
61
 
62
	@Column(name = "state")
63
	private String state;
64
 
65
	@Column(name = "pin", length = 10)
66
	private String pinCode;
67
 
68
	@Column(name = "country", length = 100)
69
	private String country;
70
 
71
	@Column(name = "phone", length = 20)
72
	private String phoneNumber;
73
 
74
	@Column(name = "enabled", columnDefinition="tinyint(1) default 0")
75
	private boolean enabled;
21666 amit.gupta 76
 
77
	@Column(name = "user_id")
78
	private int retailerId;
21545 ashik.ali 79
 
22009 ashik.ali 80
	@Convert(converter = LocalDateTimeAttributeConverter.class)
21545 ashik.ali 81
	@Column(name="added_on", updatable = false)
82
	private LocalDateTime createTimestamp = LocalDateTime.now();
83
 
22009 ashik.ali 84
	@Convert(converter = LocalDateTimeAttributeConverter.class)
21545 ashik.ali 85
	@Column(name="update_timestamp")
86
	private LocalDateTime updateTimestamp = LocalDateTime.now();
87
 
88
	public int getId() {
89
		return id;
90
	}
91
	public void setId(int id) {
92
		this.id = id;
93
	}
94
	public void setName(String name) {
95
        this.name = name;
96
    }
97
    public String getName() {
98
        return name;
99
    }
100
    public void setLine1(String line1) {
101
		this.line1 = line1;
102
	}
103
    public String getLine1() {
104
		return line1;
105
	}
106
    public void setLine2(String line2) {
107
		this.line2 = line2;
108
	}
109
    public String getLine2() {
110
		return line2;
111
	}
112
    public void setLandmark(String landmark) {
113
		this.landmark = landmark;
114
	}
115
    public String getLandmark() {
116
		return landmark;
117
	}
118
    public void setCity(String city) {
119
		this.city = city;
120
	}
121
    public String getCity() {
122
		return city;
123
	}
124
    public void setPinCode(String pinCode) {
125
		this.pinCode = pinCode;
126
	}
127
    public String getPinCode() {
128
		return pinCode;
129
	}
130
    public void setState(String state) {
131
		this.state = state;
132
	}
133
    public String getState() {
134
		return state;
135
	}
136
    public void setCountry(String country) {
137
		this.country = country;
138
	}
139
    public String getCountry() {
140
		return country;
141
	}
142
    public void setPhoneNumber(String phoneNumber) {
143
		this.phoneNumber = phoneNumber;
144
	}
145
    public String getPhoneNumber() {
146
		return phoneNumber;
147
	}
148
    public void setEnabled(boolean enabled) {
149
		this.enabled = enabled;
150
	}
151
    public boolean isEnabled() {
152
		return enabled;
153
	}
154
 
155
    public void setCreateTimestamp(LocalDateTime createTimestamp) {
156
		this.createTimestamp = createTimestamp;
157
	}
158
    public LocalDateTime getCreateTimestamp() {
159
		return createTimestamp;
160
	}
161
 
162
    public void setUpdateTimestamp(LocalDateTime updateTimestamp) {
163
		this.updateTimestamp = updateTimestamp;
164
	}
165
    public LocalDateTime getUpdateTimestamp() {
166
		return updateTimestamp;
167
	}
168
 
21666 amit.gupta 169
	public int getRetaierId() {
170
		return retailerId;
21545 ashik.ali 171
	}
21666 amit.gupta 172
	public void setRetaierId(int retailerId) {
173
		this.retailerId = retailerId;
21545 ashik.ali 174
	}
21924 ashik.ali 175
 
176
 
22009 ashik.ali 177
 
21545 ashik.ali 178
	@Override
21924 ashik.ali 179
	public int hashCode() {
180
		final int prime = 31;
181
		int result = 1;
182
		result = prime * result + id;
183
		return result;
184
	}
185
	@Override
186
	public boolean equals(Object obj) {
187
		if (this == obj)
188
			return true;
189
		if (obj == null)
190
			return false;
191
		if (getClass() != obj.getClass())
192
			return false;
193
		Address other = (Address) obj;
194
		if (id != other.id)
195
			return false;
196
		return true;
197
	}
198
	@Override
21545 ashik.ali 199
	public String toString() {
200
		return "Address [id=" + id + ", name=" + name + ", line1=" + line1 + ", line2=" + line2 + ", landmark="
201
				+ landmark + ", city=" + city + ", state=" + state + ", pinCode=" + pinCode + ", country=" + country
202
				+ ", phoneNumber=" + phoneNumber + ", enabled=" + enabled + ", createTimestamp=" + createTimestamp
21602 ashik.ali 203
				+ ", updateTimestamp=" + updateTimestamp + "]";
21545 ashik.ali 204
	}
205
 
206
 
207
}