KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > demo > Orders


1 /*
2  * Orders.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 java.util.Date JavaDoc;
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.Table;
23 import javax.persistence.Temporal;
24 import javax.persistence.TemporalType;
25
26 /**
27  *
28  * @author ak199487
29  */

30 @Entity
31 @Table(name = "ORDERS")
32 @NamedQueries( {@NamedQuery(name = "Orders.findByOrderNum", query = "SELECT o FROM Orders o WHERE o.orderNum = :orderNum"), @NamedQuery(name = "Orders.findByQuantity", query = "SELECT o FROM Orders o WHERE o.quantity = :quantity"), @NamedQuery(name = "Orders.findByShippingCost", query = "SELECT o FROM Orders o WHERE o.shippingCost = :shippingCost"), @NamedQuery(name = "Orders.findBySalesDate", query = "SELECT o FROM Orders o WHERE o.salesDate = :salesDate"), @NamedQuery(name = "Orders.findByShippingDate", query = "SELECT o FROM Orders o WHERE o.shippingDate = :shippingDate"), @NamedQuery(name = "Orders.findByFreightCompany", query = "SELECT o FROM Orders o WHERE o.freightCompany = :freightCompany")})
33 public class Orders implements Serializable JavaDoc {
34
35     @Id
36     @Column(name = "ORDER_NUM", nullable = false)
37     private Integer JavaDoc orderNum;
38
39     @Column(name = "QUANTITY")
40     private Short JavaDoc quantity;
41
42     @Column(name = "SHIPPING_COST")
43     private BigDecimal JavaDoc shippingCost;
44
45     @Column(name = "SALES_DATE")
46     @Temporal(TemporalType.DATE)
47     private Date JavaDoc salesDate;
48
49     @Column(name = "SHIPPING_DATE")
50     @Temporal(TemporalType.DATE)
51     private Date JavaDoc shippingDate;
52
53     @Column(name = "FREIGHT_COMPANY")
54     private String JavaDoc freightCompany;
55
56     @JoinColumn(name = "CUSTOMER_ID")
57     @ManyToOne
58     private Customer customerId;
59
60     @JoinColumn(name = "PRODUCT_ID")
61     @ManyToOne
62     private Product productId;
63     
64     /** Creates a new instance of Orders */
65     public Orders() {
66     }
67
68     public Orders(Integer JavaDoc orderNum) {
69         this.orderNum = orderNum;
70     }
71
72     public Integer JavaDoc getOrderNum() {
73         return this.orderNum;
74     }
75
76     public void setOrderNum(Integer JavaDoc orderNum) {
77         this.orderNum = orderNum;
78     }
79
80     public Short JavaDoc getQuantity() {
81         return this.quantity;
82     }
83
84     public void setQuantity(Short JavaDoc quantity) {
85         this.quantity = quantity;
86     }
87
88     public BigDecimal JavaDoc getShippingCost() {
89         return this.shippingCost;
90     }
91
92     public void setShippingCost(BigDecimal JavaDoc shippingCost) {
93         this.shippingCost = shippingCost;
94     }
95
96     public Date JavaDoc getSalesDate() {
97         return this.salesDate;
98     }
99
100     public void setSalesDate(Date JavaDoc salesDate) {
101         this.salesDate = salesDate;
102     }
103
104     public Date JavaDoc getShippingDate() {
105         return this.shippingDate;
106     }
107
108     public void setShippingDate(Date JavaDoc shippingDate) {
109         this.shippingDate = shippingDate;
110     }
111
112     public String JavaDoc getFreightCompany() {
113         return this.freightCompany;
114     }
115
116     public void setFreightCompany(String JavaDoc freightCompany) {
117         this.freightCompany = freightCompany;
118     }
119
120     public Customer getCustomerId() {
121         return this.customerId;
122     }
123
124     public void setCustomerId(Customer customerId) {
125         this.customerId = customerId;
126     }
127
128     public Product getProductId() {
129         return this.productId;
130     }
131
132     public void setProductId(Product productId) {
133         this.productId = productId;
134     }
135
136     public int hashCode() {
137         int hash = 0;
138         hash += (this.orderNum != null ? this.orderNum.hashCode() : 0);
139         return hash;
140     }
141
142     public boolean equals(Object JavaDoc object) {
143         if (!(object instanceof Orders)) {
144             return false;
145         }
146         Orders other = (Orders)object;
147         if (this.orderNum != other.orderNum && (this.orderNum == null || !this.orderNum.equals(other.orderNum))) return false;
148         return true;
149     }
150
151     public String JavaDoc toString() {
152         //TODO change toString() implementation to return a better display name
153
return "" + this.orderNum;
154     }
155     
156 }
157
Popular Tags