KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > demo > Customer


1 /*
2  * Customer.java
3  *
4  * Created on May 25, 2006, 11:31 AM
5  *
6  * To change this template, choose Tools | Template Manager
7  * and open the template in the editor.
8  */

9
10 package org.demo;
11
12 import java.io.Serializable JavaDoc;
13 import javax.persistence.CascadeType;
14 import javax.persistence.Column;
15 import javax.persistence.Entity;
16 import javax.persistence.Id;
17 import javax.persistence.JoinColumn;
18 import javax.persistence.ManyToOne;
19 import javax.persistence.NamedQueries;
20 import javax.persistence.NamedQuery;
21 import javax.persistence.OneToMany;
22 import javax.persistence.Table;
23
24 /**
25  *
26  * @author ak199487
27  */

28 @Entity
29 @Table(name = "CUSTOMER")
30 @NamedQueries( {@NamedQuery(name = "Customer.findByCustomerId", query = "SELECT c FROM Customer c WHERE c.customerId = :customerId"), @NamedQuery(name = "Customer.findByZip", query = "SELECT c FROM Customer c WHERE c.zip = :zip"), @NamedQuery(name = "Customer.findByName", query = "SELECT c FROM Customer c WHERE c.name = :name"), @NamedQuery(name = "Customer.findByAddressline1", query = "SELECT c FROM Customer c WHERE c.addressline1 = :addressline1"), @NamedQuery(name = "Customer.findByAddressline2", query = "SELECT c FROM Customer c WHERE c.addressline2 = :addressline2"), @NamedQuery(name = "Customer.findByCity", query = "SELECT c FROM Customer c WHERE c.city = :city"), @NamedQuery(name = "Customer.findByState", query = "SELECT c FROM Customer c WHERE c.state = :state"), @NamedQuery(name = "Customer.findByPhone", query = "SELECT c FROM Customer c WHERE c.phone = :phone"), @NamedQuery(name = "Customer.findByFax", query = "SELECT c FROM Customer c WHERE c.fax = :fax"), @NamedQuery(name = "Customer.findByEmail", query = "SELECT c FROM Customer c WHERE c.email = :email"), @NamedQuery(name = "Customer.findByCreditLimit", query = "SELECT c FROM Customer c WHERE c.creditLimit = :creditLimit")})
31 public class Customer implements Serializable JavaDoc {
32
33     @Id
34     @Column(name = "CUSTOMER_ID", nullable = false)
35     private Integer JavaDoc customerId;
36
37     @Column(name = "ZIP", nullable = false)
38     private String JavaDoc zip;
39
40     @Column(name = "NAME")
41     private String JavaDoc name;
42
43     @Column(name = "ADDRESSLINE1")
44     private String JavaDoc addressline1;
45
46     @Column(name = "ADDRESSLINE2")
47     private String JavaDoc addressline2;
48
49     @Column(name = "CITY")
50     private String JavaDoc city;
51
52     @Column(name = "STATE")
53     private String JavaDoc state;
54
55     @Column(name = "PHONE")
56     private String JavaDoc phone;
57
58     @Column(name = "FAX")
59     private String JavaDoc fax;
60
61     @Column(name = "EMAIL")
62     private String JavaDoc email;
63
64     @Column(name = "CREDIT_LIMIT")
65     private Integer JavaDoc creditLimit;
66
67     @JoinColumn(name = "DISCOUNT_CODE")
68     @ManyToOne
69     private DiscountCode discountCode;
70
71     @OneToMany(cascade = CascadeType.ALL, mappedBy = "customerId")
72     private java.util.Collection JavaDoc <org.demo.Orders> orders;
73     
74     /** Creates a new instance of Customer */
75     public Customer() {
76     }
77
78     public Customer(Integer JavaDoc customerId) {
79         this.customerId = customerId;
80     }
81
82     public Customer(Integer JavaDoc customerId, String JavaDoc zip) {
83         this.customerId = customerId;
84         this.zip = zip;
85     }
86
87     public Integer JavaDoc getCustomerId() {
88         return this.customerId;
89     }
90
91     public void setCustomerId(Integer JavaDoc customerId) {
92         this.customerId = customerId;
93     }
94
95     public String JavaDoc getZip() {
96         return this.zip;
97     }
98
99     public void setZip(String JavaDoc zip) {
100         this.zip = zip;
101     }
102
103     public String JavaDoc getName() {
104         return this.name;
105     }
106
107     public void setName(String JavaDoc name) {
108         this.name = name;
109     }
110
111     public String JavaDoc getAddressline1() {
112         return this.addressline1;
113     }
114
115     public void setAddressline1(String JavaDoc addressline1) {
116         this.addressline1 = addressline1;
117     }
118
119     public String JavaDoc getAddressline2() {
120         return this.addressline2;
121     }
122
123     public void setAddressline2(String JavaDoc addressline2) {
124         this.addressline2 = addressline2;
125     }
126
127     public String JavaDoc getCity() {
128         return this.city;
129     }
130
131     public void setCity(String JavaDoc city) {
132         this.city = city;
133     }
134
135     public String JavaDoc getState() {
136         return this.state;
137     }
138
139     public void setState(String JavaDoc state) {
140         this.state = state;
141     }
142
143     public String JavaDoc getPhone() {
144         return this.phone;
145     }
146
147     public void setPhone(String JavaDoc phone) {
148         this.phone = phone;
149     }
150
151     public String JavaDoc getFax() {
152         return this.fax;
153     }
154
155     public void setFax(String JavaDoc fax) {
156         this.fax = fax;
157     }
158
159     public String JavaDoc getEmail() {
160         return this.email;
161     }
162
163     public void setEmail(String JavaDoc email) {
164         this.email = email;
165     }
166
167     public Integer JavaDoc getCreditLimit() {
168         return this.creditLimit;
169     }
170
171     public void setCreditLimit(Integer JavaDoc creditLimit) {
172         this.creditLimit = creditLimit;
173     }
174
175     public DiscountCode getDiscountCode() {
176         return this.discountCode;
177     }
178
179     public void setDiscountCode(DiscountCode discountCode) {
180         this.discountCode = discountCode;
181     }
182
183     public java.util.Collection JavaDoc <org.demo.Orders> getOrders() {
184         return this.orders;
185     }
186
187     public void setOrders(java.util.Collection JavaDoc <org.demo.Orders> orders) {
188         this.orders = orders;
189     }
190
191     public int hashCode() {
192         int hash = 0;
193         hash += (this.customerId != null ? this.customerId.hashCode() : 0);
194         return hash;
195     }
196
197     public boolean equals(Object JavaDoc object) {
198         if (!(object instanceof Customer)) {
199             return false;
200         }
201         Customer other = (Customer)object;
202         if (this.customerId != other.customerId && (this.customerId == null || !this.customerId.equals(other.customerId))) return false;
203         return true;
204     }
205
206     public String JavaDoc toString() {
207         //TODO change toString() implementation to return a better display name
208
return "" + this.customerId;
209     }
210     
211 }
212
Popular Tags