KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > common > ejbs > entity > customer > ProductOrder


1 /**
2  * EasyBeans
3  * Copyright (C) 2006 Bull S.A.S.
4  * Contact: easybeans@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: ProductOrder.java 822 2006-07-04 14:35:35Z pinheirg $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.common.ejbs.entity.customer;
26
27 import java.io.Serializable JavaDoc;
28 import java.util.List JavaDoc;
29
30 import javax.persistence.CascadeType;
31 import javax.persistence.Entity;
32 import javax.persistence.Id;
33 import javax.persistence.ManyToOne;
34 import javax.persistence.OneToMany;
35
36 /**
37  * The order.
38  * @author Gisele Pinheiro Souza
39  * @author Eduardo Studzinski Estima de Castro
40  */

41 @Entity
42 public class ProductOrder implements Serializable JavaDoc {
43
44     /**
45      * The serial version.
46      */

47     private static final long serialVersionUID = 6701790488965035830L;
48
49     /**
50      * The order identifier.
51      */

52     private long id;
53
54     /**
55      * The order description.
56      */

57     private String JavaDoc description;
58
59     /**
60      * The customer.
61      */

62     private Customer customer;
63
64     /**
65      * The products bought in this order.
66      */

67     private List JavaDoc<Product> products;
68
69     /**
70      * Creates an instance of Order.
71      * @param id the identifier.
72      * @param description the order description.
73      * @param customer the customer.
74      * @param products the products that was bought in this order.
75      */

76     public ProductOrder(final long id, final String JavaDoc description, final Customer customer, final List JavaDoc<Product> products) {
77         this.id = id;
78         this.description = description;
79         this.customer = customer;
80         this.products = products;
81     }
82
83     /**
84      * Creates a new instance of Order.
85      */

86     public ProductOrder() {
87
88     }
89
90     /**
91      * Gets the customer.
92      * @return the customer.
93      */

94     public Customer getCustomer() {
95         return customer;
96     }
97
98     /**
99      * Sets the customer.
100      * @param customer the customer.
101      */

102     @ManyToOne
103     public void setCustomer(final Customer customer) {
104         this.customer = customer;
105     }
106
107     /**
108      * Gets the order description.
109      * @return the description.
110      */

111     public String JavaDoc getDescription() {
112         return description;
113     }
114
115     /**
116      * Sets the order description.
117      * @param description the description.
118      */

119     public void setDescription(final String JavaDoc description) {
120         this.description = description;
121     }
122
123     /**
124      * Gets the order identifier.
125      * @return the identifier.
126      */

127     @Id
128     public long getId() {
129         return id;
130     }
131
132     /**
133      * Sets the order identifier.
134      * @param id the identifier.
135      */

136     public void setId(final long id) {
137         this.id = id;
138     }
139
140     /**
141      * Gets the products that were bought in this order.
142      * @return the products.
143      */

144     @OneToMany(mappedBy = "order", cascade = CascadeType.REMOVE)
145     public List JavaDoc<Product> getProducts() {
146         return products;
147     }
148
149     /**
150      * Sets the products that were bought in this order.
151      * @param products the products bought.
152      */

153     public void setProducts(final List JavaDoc<Product> products) {
154         this.products = products;
155     }
156
157 }
158
Popular Tags