Subversion Repositories SmartDukaan

Rev

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