KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > demo > ProductCode


1 /*
2  * ProductCode.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.NamedQueries;
18 import javax.persistence.NamedQuery;
19 import javax.persistence.OneToMany;
20 import javax.persistence.Table;
21
22 /**
23  *
24  * @author ak199487
25  */

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 JavaDoc {
30
31     @Id
32     @Column(name = "PROD_CODE", nullable = false)
33     private String JavaDoc prodCode;
34
35     @Column(name = "DISCOUNT_CODE", nullable = false)
36     private char discountCode;
37
38     @Column(name = "DESCRIPTION")
39     private String JavaDoc description;
40
41     @OneToMany(cascade = CascadeType.ALL, mappedBy = "productCode")
42     private java.util.Collection JavaDoc <org.demo.Product> product;
43     
44     /** Creates a new instance of ProductCode */
45     public ProductCode() {
46     }
47
48     public ProductCode(String JavaDoc prodCode) {
49         this.prodCode = prodCode;
50     }
51
52     public ProductCode(String JavaDoc prodCode, char discountCode) {
53         this.prodCode = prodCode;
54         this.discountCode = discountCode;
55     }
56
57     public String JavaDoc getProdCode() {
58         return this.prodCode;
59     }
60
61     public void setProdCode(String JavaDoc 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 JavaDoc getDescription() {
74         return this.description;
75     }
76
77     public void setDescription(String JavaDoc description) {
78         this.description = description;
79     }
80
81     public java.util.Collection JavaDoc <org.demo.Product> getProduct() {
82         return this.product;
83     }
84
85     public void setProduct(java.util.Collection JavaDoc <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 JavaDoc 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 JavaDoc toString() {
105         //TODO change toString() implementation to return a better display name
106
return "" + this.prodCode;
107     }
108     
109 }
110
Popular Tags