KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > demo > Product


1 /*
2  * Product.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 java.math.BigDecimal JavaDoc;
14 import javax.persistence.CascadeType;
15 import javax.persistence.Column;
16 import javax.persistence.Entity;
17 import javax.persistence.Id;
18 import javax.persistence.JoinColumn;
19 import javax.persistence.ManyToOne;
20 import javax.persistence.NamedQueries;
21 import javax.persistence.NamedQuery;
22 import javax.persistence.OneToMany;
23 import javax.persistence.Table;
24
25 /**
26  *
27  * @author ak199487
28  */

29 @Entity
30 @Table(name = "PRODUCT")
31 @NamedQueries( {@NamedQuery(name = "Product.findByProductId", query = "SELECT p FROM Product p WHERE p.productId = :productId"), @NamedQuery(name = "Product.findByPurchaseCost", query = "SELECT p FROM Product p WHERE p.purchaseCost = :purchaseCost"), @NamedQuery(name = "Product.findByQuantityOnHand", query = "SELECT p FROM Product p WHERE p.quantityOnHand = :quantityOnHand"), @NamedQuery(name = "Product.findByMarkup", query = "SELECT p FROM Product p WHERE p.markup = :markup"), @NamedQuery(name = "Product.findByAvailable", query = "SELECT p FROM Product p WHERE p.available = :available"), @NamedQuery(name = "Product.findByDescription", query = "SELECT p FROM Product p WHERE p.description = :description")})
32 public class Product implements Serializable JavaDoc {
33
34     @Id
35     @Column(name = "PRODUCT_ID", nullable = false)
36     private Integer JavaDoc productId;
37
38     @Column(name = "PURCHASE_COST")
39     private BigDecimal JavaDoc purchaseCost;
40
41     @Column(name = "QUANTITY_ON_HAND")
42     private Integer JavaDoc quantityOnHand;
43
44     @Column(name = "MARKUP")
45     private BigDecimal JavaDoc markup;
46
47     @Column(name = "AVAILABLE")
48     private String JavaDoc available;
49
50     @Column(name = "DESCRIPTION")
51     private String JavaDoc description;
52
53     @JoinColumn(name = "MANUFACTURE_ID")
54     @ManyToOne
55     private org.demo.Manufacture manufactureId;
56
57     @JoinColumn(name = "PRODUCT_CODE")
58     @ManyToOne
59     private org.demo.ProductCode productCode;
60
61     @OneToMany(cascade = CascadeType.ALL, mappedBy = "productId")
62     private java.util.Collection JavaDoc <org.demo.Orders> orders;
63     
64     /** Creates a new instance of Product */
65     public Product() {
66     }
67
68     public Product(Integer JavaDoc productId) {
69         this.productId = productId;
70     }
71
72     public Integer JavaDoc getProductId() {
73         return this.productId;
74     }
75
76     public void setProductId(Integer JavaDoc productId) {
77         this.productId = productId;
78     }
79
80     public BigDecimal JavaDoc getPurchaseCost() {
81         return this.purchaseCost;
82     }
83
84     public void setPurchaseCost(BigDecimal JavaDoc purchaseCost) {
85         this.purchaseCost = purchaseCost;
86     }
87
88     public Integer JavaDoc getQuantityOnHand() {
89         return this.quantityOnHand;
90     }
91
92     public void setQuantityOnHand(Integer JavaDoc quantityOnHand) {
93         this.quantityOnHand = quantityOnHand;
94     }
95
96     public BigDecimal JavaDoc getMarkup() {
97         return this.markup;
98     }
99
100     public void setMarkup(BigDecimal JavaDoc markup) {
101         this.markup = markup;
102     }
103
104     public String JavaDoc getAvailable() {
105         return this.available;
106     }
107
108     public void setAvailable(String JavaDoc available) {
109         this.available = available;
110     }
111
112     public String JavaDoc getDescription() {
113         return this.description;
114     }
115
116     public void setDescription(String JavaDoc description) {
117         this.description = description;
118     }
119
120     public org.demo.Manufacture getManufactureId() {
121         return this.manufactureId;
122     }
123
124     public void setManufactureId(org.demo.Manufacture manufactureId) {
125         this.manufactureId = manufactureId;
126     }
127
128     public org.demo.ProductCode getProductCode() {
129         return this.productCode;
130     }
131
132     public void setProductCode(org.demo.ProductCode productCode) {
133         this.productCode = productCode;
134     }
135
136     public java.util.Collection JavaDoc <org.demo.Orders> getOrders() {
137         return this.orders;
138     }
139
140     public void setOrders(java.util.Collection JavaDoc <org.demo.Orders> orders) {
141         this.orders = orders;
142     }
143
144     public int hashCode() {
145         int hash = 0;
146         hash += (this.productId != null ? this.productId.hashCode() : 0);
147         return hash;
148     }
149
150     public boolean equals(Object JavaDoc object) {
151         if (!(object instanceof Product)) {
152             return false;
153         }
154         Product other = (Product)object;
155         if (this.productId != other.productId && (this.productId == null || !this.productId.equals(other.productId))) return false;
156         return true;
157     }
158
159     public String JavaDoc toString() {
160         //TODO change toString() implementation to return a better display name
161
return "" + this.productId;
162     }
163     
164 }
165
Popular Tags