001: /**
002: * Copyright (c) 2004 Red Hat, Inc. All rights reserved.
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
017: * USA
018: *
019: * Component of: Red Hat Application Server
020: *
021: * Initial Developers: Aizaz Ahmed
022: * Vivek Lakshmanan
023: * Andrew Overholt
024: * Matthew Wringe
025: *
026: */package olstore.entity;
027:
028: import javax.ejb.EntityBean;
029:
030: import olstore.entity.ItemLocal;
031: import olstore.entity.UserLocal;
032:
033: import java.math.BigDecimal;
034:
035: /**
036: * @ejb.bean name="Order"
037: * description="This bean is used to store information about an order."
038: * type="CMP"
039: * schema="olstore_order"
040: * primkey-field="orderId"
041: * reentrant="false"
042: * cmp-version="2.x"
043: * view-type="local"
044: * local-jndi-name="OrderLocal_L"
045: *
046: * @ejb.transaction
047: * type="Required"
048: *
049: *--
050: * This is needed for JOnAS.
051: * If you are not using JOnAS you can safely remove the tags below.
052: * @jonas.bean ejb-name="Order"
053: * jndi-name="OrderLocal"
054: * @jonas.jdbc-mapping jndi-name="jdbc_1" jdbc-table-name="olstore_order"
055: * automatic-pk="true"
056: * --
057: *
058: * @ejb.persistence
059: *
060: * @ejb.finder
061: * query="SELECT OBJECT(a) FROM olstore_order as a"
062: * signature="java.util.Collection findAll()"
063: *
064: * @ejb.finder
065: * query="SELECT OBJECT(a) FROM olstore_order as a WHERE NOT (a.status = ?1)"
066: * signature="java.util.Collection findByStatus(java.lang.String status)"
067: *
068: * @ejb.finder
069: * query="SELECT OBJECT(a) FROM olstore_order as a WHERE a.orderId = ?1"
070: * signature="olstore.entity.Order findByPrimaryKey(java.lang.Integer orderId)"
071: *
072: *--
073: * This is needed for JOnAS.
074: * If you are not using JOnAS you can safely remove the tags below.
075: * @jonas.finder-method-jdbc-mapping method-name="findAll"
076: * jdbc-where-clause=""
077: * @jonas.jdbc-mapping jndi-name="jdbc_1"
078: * jdbc-table-name="olstore_order"
079: *
080: *--
081: *
082: **/
083:
084: public abstract class OrderBean implements EntityBean {
085:
086: /**
087: * The ejbCreate method.
088: *
089: * @ejb.create-method
090: */
091: public java.lang.Integer ejbCreate(UserLocal user, ItemLocal item,
092: Integer quantity, String status, String dateReceived,
093: BigDecimal pricePaid) throws javax.ejb.CreateException {
094: setQuantity(quantity);
095: setStatus(status);
096: setDateReceived(dateReceived);
097: setPricePaid(pricePaid);
098:
099: return null;
100: }
101:
102: /**
103: * The container invokes this method immediately after it calls ejbCreate.
104: *
105: */
106: public void ejbPostCreate(UserLocal user, ItemLocal item,
107: Integer quantity, String status, String dateReceived,
108: BigDecimal pricePaid) throws javax.ejb.CreateException {
109: setUser(user);
110: setItem(item);
111: }
112:
113: /**
114: * Returns the orderId
115: * @return the orderId
116: *
117: * @ejb.persistent-field
118: * @ejb.persistence
119: * column-name="orderId"
120: * sql-type="INTEGER"
121: * @ejb.pk-field
122: * @ejb.interface-method
123: *
124: */
125: public abstract java.lang.Integer getOrderId();
126:
127: /**
128: * Sets the orderId
129: *
130: * @param java.lang.Integer the new orderId value
131: *
132: * @ejb.interface-method
133: */
134: public abstract void setOrderId(java.lang.Integer orderId);
135:
136: /**
137: * Returns the quantity
138: * @return the quantity
139: *
140: * @ejb.persistent-field
141: * @ejb.persistence
142: * column-name="quantity"
143: * sql-type="INTEGER"
144: *
145: * @ejb.interface-method
146: *
147: */
148: public abstract java.lang.Integer getQuantity();
149:
150: /**
151: * Sets the quantity
152: *
153: * @param java.lang.Integer the new quantity value
154: *
155: * @ejb.interface-method
156: */
157: public abstract void setQuantity(java.lang.Integer quantity);
158:
159: /**
160: * Returns the status
161: * @return the status
162: *
163: * @ejb.persistent-field
164: * @ejb.persistence
165: * column-name="status"
166: * sql-type="VARCHAR"
167: *
168: * @ejb.interface-method
169: *
170: */
171: public abstract java.lang.String getStatus();
172:
173: /**
174: * Sets the status
175: *
176: * @param java.lang.String the new status value
177: *
178: * @ejb.interface-method
179: */
180: public abstract void setStatus(java.lang.String status);
181:
182: /**
183: * Returns the dateReceived
184: * @return the dateReceived
185: *
186: * @ejb.persistent-field
187: * @ejb.persistence
188: * column-name="dateReceived"
189: * sql-type="VARCHAR"
190: *
191: * @ejb.interface-method
192: *
193: */
194: public abstract java.lang.String getDateReceived();
195:
196: /**
197: * Sets the dateReceived
198: *
199: * @param java.lang.String the new dateReceived value
200: *
201: * @ejb.interface-method
202: */
203: public abstract void setDateReceived(java.lang.String dateReceived);
204:
205: /**
206: * Returns the pricePaid
207: * @return the pricePaid
208: *
209: * @ejb.persistent-field
210: * @ejb.persistence
211: * column-name="pricePaid"
212: * sql-type="NUMERIC"
213: *
214: * @ejb.interface-method
215: *
216: */
217: public abstract BigDecimal getPricePaid();
218:
219: /**
220: * Sets the pricePaid
221: *
222: * @param java.lang.Float the new pricePaid value
223: *
224: * @ejb.interface-method
225: */
226: public abstract void setPricePaid(BigDecimal pricePaid);
227:
228: /**
229: * Returns the User for this Order
230: *
231: * @return the User for this Order
232: *
233: * @ejb.relation
234: * name="User-Order"
235: * role-name="Order-has-a-User"
236: * target-ejb="User"
237: * @ejb.interface-method
238: *
239: */
240:
241: public abstract UserLocal getUser();
242:
243: public abstract void setUser(UserLocal user);
244:
245: /**
246: * Returns the item for this Order
247: *
248: * @return the item for this Order
249: *
250: * @ejb.relation
251: * name="Order-Item"
252: * role-name="Order-has-many-Items"
253: * target-ejb="Item"
254: * target-multiple="yes"
255: *
256: * @ejb.interface-method
257: */
258:
259: public abstract ItemLocal getItem();
260:
261: public abstract void setItem(ItemLocal user);
262:
263: }
|