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.NamedQueries; 18 import javax.persistence.NamedQuery; 19 import javax.persistence.OneToMany; 20 import javax.persistence.Table; 21 22 26 @Entity 27 @Table(name = "PRODUCT_CODE") 28 @NamedQueries( {@NamedQuery(name = "ProductCode.findByProdCode", query = "SELECT p FROM ProductCode p WHERE p.prodCode = :prodCode"), @NamedQuery(name = "ProductCode.findByDiscountCode", query = "SELECT p FROM ProductCode p WHERE p.discountCode = :discountCode"), @NamedQuery(name = "ProductCode.findByDescription", query = "SELECT p FROM ProductCode p WHERE p.description = :description")}) 29 public class ProductCode implements Serializable { 30 31 @Id 32 @Column(name = "PROD_CODE", nullable = false) 33 private String prodCode; 34 35 @Column(name = "DISCOUNT_CODE", nullable = false) 36 private char discountCode; 37 38 @Column(name = "DESCRIPTION") 39 private String description; 40 41 @OneToMany(cascade = CascadeType.ALL, mappedBy = "productCode") 42 private java.util.Collection <org.demo.Product> product; 43 44 45 public ProductCode() { 46 } 47 48 public ProductCode(String prodCode) { 49 this.prodCode = prodCode; 50 } 51 52 public ProductCode(String prodCode, char discountCode) { 53 this.prodCode = prodCode; 54 this.discountCode = discountCode; 55 } 56 57 public String getProdCode() { 58 return this.prodCode; 59 } 60 61 public void setProdCode(String prodCode) { 62 this.prodCode = prodCode; 63 } 64 65 public char getDiscountCode() { 66 return this.discountCode; 67 } 68 69 public void setDiscountCode(char discountCode) { 70 this.discountCode = discountCode; 71 } 72 73 public String getDescription() { 74 return this.description; 75 } 76 77 public void setDescription(String description) { 78 this.description = description; 79 } 80 81 public java.util.Collection <org.demo.Product> getProduct() { 82 return this.product; 83 } 84 85 public void setProduct(java.util.Collection <org.demo.Product> product) { 86 this.product = product; 87 } 88 89 public int hashCode() { 90 int hash = 0; 91 hash += (this.prodCode != null ? this.prodCode.hashCode() : 0); 92 return hash; 93 } 94 95 public boolean equals(Object object) { 96 if (!(object instanceof ProductCode)) { 97 return false; 98 } 99 ProductCode other = (ProductCode)object; 100 if (this.prodCode != other.prodCode && (this.prodCode == null || !this.prodCode.equals(other.prodCode))) return false; 101 return true; 102 } 103 104 public String toString() { 105 return "" + this.prodCode; 107 } 108 109 } 110 | Popular Tags |