1 9 10 package org.demo; 11 12 import java.io.Serializable ; 13 import java.math.BigDecimal ; 14 import javax.persistence.CascadeType; 15 import javax.persistence.Column; 16 import javax.persistence.Entity; 17 import javax.persistence.Id; 18 import javax.persistence.NamedQueries; 19 import javax.persistence.NamedQuery; 20 import javax.persistence.OneToMany; 21 import javax.persistence.Table; 22 23 27 @Entity 28 @Table(name = "DISCOUNT_CODE") 29 @NamedQueries( {@NamedQuery(name = "DiscountCode.findByDiscountCode", query = "SELECT d FROM DiscountCode d WHERE d.discountCode = :discountCode"), @NamedQuery(name = "DiscountCode.findByRate", query = "SELECT d FROM DiscountCode d WHERE d.rate = :rate")}) 30 public class DiscountCode implements Serializable { 31 32 @Id 33 @Column(name = "DISCOUNT_CODE", nullable = false) 34 private String discountCode; 35 36 @Column(name = "RATE") 37 private BigDecimal rate; 38 39 @OneToMany(cascade = CascadeType.ALL, mappedBy = "discountCode") 40 private java.util.Collection <org.demo.Customer> customer; 41 42 43 public DiscountCode() { 44 } 45 46 public DiscountCode(String discountCode) { 47 this.discountCode = discountCode; 48 } 49 50 public String getDiscountCode() { 51 return this.discountCode; 52 } 53 54 public void setDiscountCode(String discountCode) { 55 this.discountCode = discountCode; 56 } 57 58 public BigDecimal getRate() { 59 return this.rate; 60 } 61 62 public void setRate(BigDecimal rate) { 63 this.rate = rate; 64 } 65 66 public java.util.Collection <org.demo.Customer> getCustomer() { 67 return this.customer; 68 } 69 70 public void setCustomer(java.util.Collection <org.demo.Customer> customer) { 71 this.customer = customer; 72 } 73 74 public int hashCode() { 75 int hash = 0; 76 hash += (this.discountCode != null ? this.discountCode.hashCode() : 0); 77 return hash; 78 } 79 80 public boolean equals(Object object) { 81 if (!(object instanceof DiscountCode)) { 82 return false; 83 } 84 DiscountCode other = (DiscountCode)object; 85 if (this.discountCode != other.discountCode && (this.discountCode == null || !this.discountCode.equals(other.discountCode))) return false; 86 return true; 87 } 88 89 public String toString() { 90 return "" + this.discountCode; 92 } 93 94 } 95 | Popular Tags |