KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > olstore > entity > ItemBean


1 /**
2  * Copyright (c) 2004 Red Hat, Inc. All rights reserved.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17  * USA
18  *
19  * Component of: Red Hat Application Server
20  *
21  * Initial Developers: Aizaz Ahmed
22  * Vivek Lakshmanan
23  * Andrew Overholt
24  * Matthew Wringe
25  *
26  */

27 /*
28  * ItemBean.java
29  *
30  * Created on Aug 16, 2004
31  *
32  */

33 package olstore.entity;
34
35 import javax.ejb.EntityBean;
36
37 import olstore.entity.TypeLocal;
38
39 import java.util.Collection;
40 import java.math.BigDecimal;
41
42 /**
43  * @ejb.bean name="Item"
44  * description="This bean is used to store information about sales items."
45  * type="CMP"
46  * schema="olstore_item"
47  * primkey-field="itemId"
48  * reentrant="false"
49  * cmp-version="2.x"
50  * view-type="local"
51  * local-jndi-name="ItemLocal_L"
52  *
53  * @ejb.relation
54  * name="User-Item"
55  * role-name="Items-belong-to-Users"
56  * target-ejb="User"
57  * target-multiple="yes"
58  *
59  * @ejb.relation
60  * name="Order-Item"
61  * role-name="Items-belong-to-Orders"
62  * target-ejb="Order"
63  *
64  * @ejb.transaction
65  * type="Required"
66  *
67  *--
68  * This is needed for JOnAS.
69  * If you are not using JOnAS you can safely remove the tags below.
70  * @jonas.bean ejb-name="Item"
71  * jndi-name="ItemLocal"
72  * @jonas.jdbc-mapping jndi-name="jdbc_1" jdbc-table-name="olstore_item"
73  * automatic-pk="true"
74  * --
75  *
76  * @ejb.persistence
77  *
78  * @ejb.finder
79  * query="SELECT OBJECT(a) FROM olstore_item as a"
80  * signature="java.util.Collection findAll()"
81  *
82  * @ejb.finder
83  * query="SELECT OBJECT(c) FROM olstore_item AS c WHERE c.name = ?1"
84  * signature="java.util.Collection findByName(java.lang.String name)"
85  *
86  * @ejb.finder
87  * query="SELECT OBJECT(c) FROM olstore_item AS c WHERE c.itemId = ?1"
88  * signature="olstore.entity.Item findByPrimaryKey(java.lang.Integer itemId)"
89  *
90  * @ejb.finder
91  * query="SELECT OBJECT(c) FROM olstore_item AS c WHERE c.mainPage = 'true'"
92  * signature="java.util.Collection findByMainPage()"
93  *
94  * @ejb.finder
95  * query="SELECT OBJECT(c) FROM olstore_item AS c WHERE c.specialOffer = 'true' AND c.mainPage = 'true'"
96  * signature="java.util.Collection findByMainPageAndSpecialOffer()"
97  *
98  * @ejb.finder
99  * query="SELECT OBJECT(c) FROM olstore_item AS c WHERE c.typeId.name = ?1"
100  * signature="java.util.Collection findByType(java.lang.String type)"
101  *
102  * @ejb.finder
103  * query="SELECT OBJECT(c) FROM olstore_item AS c WHERE c.typeId.name = ?1 AND c.specialOffer = 'true'"
104  * signature="java.util.Collection findByTypeAndSpecialOffer(java.lang.String typeIdName)"
105  *
106  * @ejb.finder
107  * query="SELECT DISTINCT OBJECT(p) FROM olstore_user u, IN ( u.friends ) AS f, IN ( f.user.purchased ) AS p WHERE u.username = ?2 AND p.typeId.name = ?1"
108  * signature="java.util.Collection findByTypeAndFriendsOf(java.lang.String typeIdName, java.lang.String username)"
109  *
110  * @ejb.finder
111  * query="SELECT DISTINCT OBJECT(p) FROM olstore_user u, IN ( u.friends ) AS f, IN ( f.user.purchased ) AS p WHERE u.username = ?1 AND p.mainPage = 'true'"
112  * signature="java.util.Collection findByMainPageAndFriendsOf(java.lang.String username)"
113  *
114  * @ejb.finder
115  * query="SELECT OBJECT(c) FROM olstore_item AS c WHERE c.specialOffer = 'true'"
116  * signature="java.util.Collection findBySpecialOffer()"
117  *
118  *
119  *--
120  * This is needed for JOnAS.
121  * If you are not using JOnAS you can safely remove the tags below.
122  * @jonas.finder-method-jdbc-mapping method-name="findAll"
123  * jdbc-where-clause=""
124  * @jonas.jdbc-mapping jndi-name="jdbc_1"
125  * jdbc-table-name="olstore_item"
126  *
127  *--
128  *
129  **/

130
131 public abstract class ItemBean implements EntityBean {
132     
133     /**
134      * The ejbCreate method.
135      *
136      * @ejb.create-method
137      */

138     public java.lang.Integer ejbCreate(String name, BigDecimal price) throws javax.ejb.CreateException {
139         setName(name);
140         setPrice(price);
141         return null;
142     }
143     
144     /**
145      * The container invokes this method immediately after it calls ejbCreate.
146      *
147      */

148     public void ejbPostCreate(String name, BigDecimal price) throws javax.ejb.CreateException {
149     }
150     
151     /**
152      * Returns the name
153      * @return the name
154      *
155      * @ejb.persistent-field
156      * @ejb.persistence
157      * column-name="name"
158      * sql-type="VARCHAR"
159      *
160      * @ejb.interface-method
161      *
162      *
163      */

164     public abstract java.lang.String getName();
165     
166     /**
167      * Sets the name
168      *
169      * @param java.lang.String the new name value
170      *
171      * @ejb.interface-method
172      */

173     public abstract void setName(java.lang.String name);
174     
175     /**
176      * Returns the shortDesc
177      * @return the shortDesc
178      *
179      * @ejb.persistent-field
180      * @ejb.persistence
181      * column-name="shortDesc"
182      * sql-type="VARCHAR"
183      *
184      * @ejb.interface-method
185      *
186      */

187     public abstract java.lang.String getShortDesc();
188     
189     /**
190      * Sets the shortDesc
191      *
192      * @param java.lang.String the new shortDesc value
193      *
194      * @ejb.interface-method
195      */

196     public abstract void setShortDesc(java.lang.String shortDesc);
197     
198     /**
199      * Returns the longDesc
200      * @return the longDesc
201      *
202      * @ejb.persistent-field
203      * @ejb.persistence
204      * column-name="longDesc"
205      * sql-type="VARCHAR"
206      *
207      * @ejb.interface-method
208      *
209      */

210     public abstract java.lang.String getLongDesc();
211     
212     /**
213      * Sets the longDesc
214      *
215      * @param java.lang.String the new longDesc value
216      *
217      * @ejb.interface-method
218      */

219     public abstract void setLongDesc(java.lang.String longDesc);
220     
221     /**
222      * Returns whether or not the item should appear on the main page
223      * @return the mainPage
224      *
225      * @ejb.persistent-field
226      * @ejb.persistence
227      * column-name="mainPage"
228      * sql-type="BOOLEAN"
229      *
230      * @ejb.interface-method
231      *
232      */

233     public abstract java.lang.Boolean getMainPage();
234     
235     /**
236      * Sets whether or not the item should appear on the main page
237      *
238      * @param java.lang.Boolean mainPage
239      *
240      * @ejb.interface-method
241      */

242     public abstract void setMainPage(java.lang.Boolean mainPage);
243     
244     /**
245      * Returns whether or not the item is a special offer.
246      * @return specialOffer
247      *
248      * @ejb.persistent-field
249      * @ejb.persistence
250      * column-name="specialOffer"
251      * sql-type="BOOLEAN"
252      *
253      * @ejb.interface-method
254      *
255      */

256     public abstract java.lang.Boolean getSpecialOffer();
257     
258     /**
259      * Sets whether or not the item should appear on the main page
260      *
261      * @param java.lang.Boolean the new specialOffer value
262      *
263      * @ejb.interface-method
264      */

265     public abstract void setSpecialOffer(java.lang.Boolean specialOffer);
266     
267     /**
268      * Returns the itemId
269      * @return the itemId
270      *
271      * @ejb.persistent-field
272      * @ejb.persistence
273      * column-name="itemId"
274      * sql-type="INTEGER"
275      * @ejb.pk-field
276      * @ejb.interface-method
277      *
278      */

279     public abstract java.lang.Integer getItemId();
280     
281     /**
282      * Sets the itemId
283      *
284      * @param java.lang.Integer the new itemId value
285      *
286      * @ejb.interface-method
287      */

288     public abstract void setItemId(java.lang.Integer itemId);
289     
290     /**
291      * Returns the price
292      * @return the price
293      *
294      * @ejb.persistent-field
295      * @ejb.persistence
296      * column-name="price"
297      * sql-type="NUMERIC"
298      *
299      * @ejb.interface-method
300      *
301      */

302     public abstract BigDecimal getPrice();
303     
304     /**
305      * Sets the price
306      *
307      * @param BigDecimal the new price value
308      *
309      * @ejb.interface-method
310      */

311     public abstract void setPrice(BigDecimal price);
312     
313     /**
314      * Returns the typeId of the item
315      *
316      * @return TypeId
317      *
318      * @ejb.interface-method
319      *
320      * @ejb.relation
321      * name="Item-Type"
322      * target-ejb="Type"
323      * role-name="Item-belongs-to-Type"
324      * target-multiple="yes"
325      *
326      */

327     
328     public abstract TypeLocal getTypeId ();
329     
330     /**
331      * Sets the TypeId
332      *
333      * @param type
334      *
335      * @ejb.interface-method
336      */

337     
338     public abstract void setTypeId (TypeLocal type);
339     
340     /**
341      * Returns the properties of the item
342      *
343      * @return Properties
344      *
345      * @ejb.interface-method
346      *
347      * @ejb.relation
348      * name="Item-Property"
349      * target-ejb="Property"
350      * role-name="Item-has-many-Properties"
351      *
352      */

353     
354     public abstract Collection getProperties ();
355     
356     /**
357      *
358      * @param properties
359      *
360      * @ejb.interface-method
361      *
362      */

363     
364     public abstract void setProperties (Collection properties);
365     
366     /**
367      * Returns the pictures of the item
368      *
369      * @return Pictures
370      *
371      * @ejb.interface-method
372      *
373      * @ejb.relation
374      * name="Item-Picture"
375      * target-ejb="Picture"
376      * role-name="Item-has-many-Pictures"
377      *
378      */

379     
380     public abstract Collection getPictures ();
381     
382     /**
383      *
384      * @param pictures
385      *
386      * @ejb.interface-method
387      *
388      */

389     
390     public abstract void setPictures (Collection pictures);
391            
392 }
393
Popular Tags