1 9 10 package org.demo; 11 12 import java.io.Serializable ; 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 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 { 32 33 @Id 34 @Column(name = "CUSTOMER_ID", nullable = false) 35 private Integer customerId; 36 37 @Column(name = "ZIP", nullable = false) 38 private String zip; 39 40 @Column(name = "NAME") 41 private String name; 42 43 @Column(name = "ADDRESSLINE1") 44 private String addressline1; 45 46 @Column(name = "ADDRESSLINE2") 47 private String addressline2; 48 49 @Column(name = "CITY") 50 private String city; 51 52 @Column(name = "STATE") 53 private String state; 54 55 @Column(name = "PHONE") 56 private String phone; 57 58 @Column(name = "FAX") 59 private String fax; 60 61 @Column(name = "EMAIL") 62 private String email; 63 64 @Column(name = "CREDIT_LIMIT") 65 private Integer 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 <org.demo.Orders> orders; 73 74 75 public Customer() { 76 } 77 78 public Customer(Integer customerId) { 79 this.customerId = customerId; 80 } 81 82 public Customer(Integer customerId, String zip) { 83 this.customerId = customerId; 84 this.zip = zip; 85 } 86 87 public Integer getCustomerId() { 88 return this.customerId; 89 } 90 91 public void setCustomerId(Integer customerId) { 92 this.customerId = customerId; 93 } 94 95 public String getZip() { 96 return this.zip; 97 } 98 99 public void setZip(String zip) { 100 this.zip = zip; 101 } 102 103 public String getName() { 104 return this.name; 105 } 106 107 public void setName(String name) { 108 this.name = name; 109 } 110 111 public String getAddressline1() { 112 return this.addressline1; 113 } 114 115 public void setAddressline1(String addressline1) { 116 this.addressline1 = addressline1; 117 } 118 119 public String getAddressline2() { 120 return this.addressline2; 121 } 122 123 public void setAddressline2(String addressline2) { 124 this.addressline2 = addressline2; 125 } 126 127 public String getCity() { 128 return this.city; 129 } 130 131 public void setCity(String city) { 132 this.city = city; 133 } 134 135 public String getState() { 136 return this.state; 137 } 138 139 public void setState(String state) { 140 this.state = state; 141 } 142 143 public String getPhone() { 144 return this.phone; 145 } 146 147 public void setPhone(String phone) { 148 this.phone = phone; 149 } 150 151 public String getFax() { 152 return this.fax; 153 } 154 155 public void setFax(String fax) { 156 this.fax = fax; 157 } 158 159 public String getEmail() { 160 return this.email; 161 } 162 163 public void setEmail(String email) { 164 this.email = email; 165 } 166 167 public Integer getCreditLimit() { 168 return this.creditLimit; 169 } 170 171 public void setCreditLimit(Integer 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 <org.demo.Orders> getOrders() { 184 return this.orders; 185 } 186 187 public void setOrders(java.util.Collection <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 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 toString() { 207 return "" + this.customerId; 209 } 210 211 } 212 | Popular Tags |