KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > demo > DiscountCode


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

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 JavaDoc {
31
32     @Id
33     @Column(name = "DISCOUNT_CODE", nullable = false)
34     private String JavaDoc discountCode;
35
36     @Column(name = "RATE")
37     private BigDecimal JavaDoc rate;
38
39     @OneToMany(cascade = CascadeType.ALL, mappedBy = "discountCode")
40     private java.util.Collection JavaDoc <org.demo.Customer> customer;
41     
42     /** Creates a new instance of DiscountCode */
43     public DiscountCode() {
44     }
45
46     public DiscountCode(String JavaDoc discountCode) {
47         this.discountCode = discountCode;
48     }
49
50     public String JavaDoc getDiscountCode() {
51         return this.discountCode;
52     }
53
54     public void setDiscountCode(String JavaDoc discountCode) {
55         this.discountCode = discountCode;
56     }
57
58     public BigDecimal JavaDoc getRate() {
59         return this.rate;
60     }
61
62     public void setRate(BigDecimal JavaDoc rate) {
63         this.rate = rate;
64     }
65
66     public java.util.Collection JavaDoc <org.demo.Customer> getCustomer() {
67         return this.customer;
68     }
69
70     public void setCustomer(java.util.Collection JavaDoc <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 JavaDoc 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 JavaDoc toString() {
90         //TODO change toString() implementation to return a better display name
91
return "" + this.discountCode;
92     }
93     
94 }
95
Popular Tags