Discount.java
5.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fi.insomnia.bortal.model;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
/**
*
* @author jkj
*/
@Entity
@Table(name = "discounts")
@NamedQueries({
@NamedQuery(name = "Discount.findAll", query = "SELECT d FROM Discount d"),
@NamedQuery(name = "Discount.findByDiscountsId", query = "SELECT d FROM Discount d WHERE d.discountsId = :discountsId"),
@NamedQuery(name = "Discount.findByPercentage", query = "SELECT d FROM Discount d WHERE d.percentage = :percentage"),
@NamedQuery(name = "Discount.findByCode", query = "SELECT d FROM Discount d WHERE d.code = :code"),
@NamedQuery(name = "Discount.findByDetails", query = "SELECT d FROM Discount d WHERE d.details = :details"),
@NamedQuery(name = "Discount.findByAmountMin", query = "SELECT d FROM Discount d WHERE d.amountMin = :amountMin"),
@NamedQuery(name = "Discount.findByAmountMax", query = "SELECT d FROM Discount d WHERE d.amountMax = :amountMax"),
@NamedQuery(name = "Discount.findByActive", query = "SELECT d FROM Discount d WHERE d.active = :active"),
@NamedQuery(name = "Discount.findByMaxNum", query = "SELECT d FROM Discount d WHERE d.maxNum = :maxNum"),
@NamedQuery(name = "Discount.findByPerUser", query = "SELECT d FROM Discount d WHERE d.perUser = :perUser")})
public class Discount implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(name = "discounts_id", nullable = false)
private Integer discountsId;
@Basic(optional = false)
@Column(name = "percentage", nullable = false)
private BigInteger percentage;
@Column(name = "code", length = 2147483647)
private String code;
@Column(name = "details", length = 2147483647)
private String details;
@Basic(optional = false)
@Column(name = "amount_min", nullable = false)
private int amountMin;
@Basic(optional = false)
@Column(name = "amount_max", nullable = false)
private int amountMax;
@Basic(optional = false)
@Column(name = "active", nullable = false)
private boolean active;
@Basic(optional = false)
@Column(name = "max_num", nullable = false)
private int maxNum;
@Basic(optional = false)
@Column(name = "per_user", nullable = false)
private int perUser;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "discountsId")
private List<DiscountInstance> discountInstanceList;
public Discount() {
}
public Discount(Integer discountsId) {
this.discountsId = discountsId;
}
public Discount(Integer discountsId, BigInteger percentage, int amountMin, int amountMax, boolean active, int maxNum, int perUser) {
this.discountsId = discountsId;
this.percentage = percentage;
this.amountMin = amountMin;
this.amountMax = amountMax;
this.active = active;
this.maxNum = maxNum;
this.perUser = perUser;
}
public Integer getDiscountsId() {
return discountsId;
}
public void setDiscountsId(Integer discountsId) {
this.discountsId = discountsId;
}
public BigInteger getPercentage() {
return percentage;
}
public void setPercentage(BigInteger percentage) {
this.percentage = percentage;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getDetails() {
return details;
}
public void setDetails(String details) {
this.details = details;
}
public int getAmountMin() {
return amountMin;
}
public void setAmountMin(int amountMin) {
this.amountMin = amountMin;
}
public int getAmountMax() {
return amountMax;
}
public void setAmountMax(int amountMax) {
this.amountMax = amountMax;
}
public boolean getActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
public int getMaxNum() {
return maxNum;
}
public void setMaxNum(int maxNum) {
this.maxNum = maxNum;
}
public int getPerUser() {
return perUser;
}
public void setPerUser(int perUser) {
this.perUser = perUser;
}
public List<DiscountInstance> getDiscountInstanceList() {
return discountInstanceList;
}
public void setDiscountInstanceList(List<DiscountInstance> discountInstanceList) {
this.discountInstanceList = discountInstanceList;
}
@Override
public int hashCode() {
int hash = 0;
hash += (discountsId != null ? discountsId.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Discount)) {
return false;
}
Discount other = (Discount) object;
if ((this.discountsId == null && other.discountsId != null) || (this.discountsId != null && !this.discountsId.equals(other.discountsId))) {
return false;
}
return true;
}
@Override
public String toString() {
return "fi.insomnia.bortal.model.Discount[discountsId=" + discountsId + "]";
}
}