1packageorg.apache.jetspeed.om.apps.coffees;
234import java.math.BigDecimal;
5import java.sql.Connection;
6import java.util.ArrayList;
7import java.util.Collections;
8import java.util.Date;
9import java.util.List;
1011import org.apache.commons.lang.ObjectUtils;
12import org.apache.torque.TorqueException;
13import org.apache.torque.om.BaseObject;
14import org.apache.torque.om.ComboKey;
15import org.apache.torque.om.DateKey;
16import org.apache.torque.om.NumberKey;
17import org.apache.torque.om.ObjectKey;
18import org.apache.torque.om.SimpleKey;
19import org.apache.torque.om.StringKey;
20import org.apache.torque.om.Persistent;
21import org.apache.torque.util.Criteria;
22import org.apache.torque.util.Transaction;
232425/***26 * This class was autogenerated by Torque on:27 *28 * [Thu Apr 22 23:12:36 EDT 2004]29 *30 * You should not use this class directly. It should not even be31 * extended all references should be to Coffees32 */33publicabstractclassBaseCoffeesextends BaseObject
34 {
35/*** The Peer class */36privatestaticfinalCoffeesPeer peer =
37newCoffeesPeer();
383940/*** The value for the coffeeId field */41privateint coffeeId;
4243/*** The value for the coffeeName field */44private String coffeeName;
4546/*** The value for the supplierId field */47privateint supplierId;
4849/*** The value for the price field */50privatedouble price;
5152/*** The value for the sales field */53privateint sales;
5455/*** The value for the total field */56privateint total;
575859/***60 * Get the CoffeeId61 * @return int62 */63publicint getCoffeeId()
64 {
65return coffeeId;
66 }
676869/***70 * Set the value of CoffeeId71 */72publicvoid setCoffeeId(int v )
73 {
7475if (this.coffeeId != v)
76 {
77this.coffeeId = v;
78 setModified(true);
79 }
808182 }
838485/***86 * Get the CoffeeName87 * @return String88 */89public String getCoffeeName()
90 {
91return coffeeName;
92 }
939495/***96 * Set the value of CoffeeName97 */98publicvoid setCoffeeName(String v )
99 {
100101if (!ObjectUtils.equals(this.coffeeName, v))
102 {
103this.coffeeName = v;
104 setModified(true);
105 }
106107108 }
109110111/***112 * Get the SupplierId113 * @return int114 */115publicint getSupplierId()
116 {
117return supplierId;
118 }
119120121/***122 * Set the value of SupplierId123 */124publicvoid setSupplierId(int v )
125 {
126127if (this.supplierId != v)
128 {
129this.supplierId = v;
130 setModified(true);
131 }
132133134 }
135136137/***138 * Get the Price139 * @return double140 */141publicdouble getPrice()
142 {
143return price;
144 }
145146147/***148 * Set the value of Price149 */150publicvoid setPrice(double v )
151 {
152153if (this.price != v)
154 {
155this.price = v;
156 setModified(true);
157 }
158159160 }
161162163/***164 * Get the Sales165 * @return int166 */167publicint getSales()
168 {
169return sales;
170 }
171172173/***174 * Set the value of Sales175 */176publicvoid setSales(int v )
177 {
178179if (this.sales != v)
180 {
181this.sales = v;
182 setModified(true);
183 }
184185186 }
187188189/***190 * Get the Total191 * @return int192 */193publicint getTotal()
194 {
195return total;
196 }
197198199/***200 * Set the value of Total201 */202publicvoid setTotal(int v )
203 {
204205if (this.total != v)
206 {
207this.total = v;
208 setModified(true);
209 }
210211212 }
213214215216217privatestatic List fieldNames = null;
218219/***220 * Generate a list of field names.221 */222publicstaticsynchronized List getFieldNames()
223 {
224if (fieldNames == null)
225 {
226 fieldNames = new ArrayList();
227 fieldNames.add("CoffeeId");
228 fieldNames.add("CoffeeName");
229 fieldNames.add("SupplierId");
230 fieldNames.add("Price");
231 fieldNames.add("Sales");
232 fieldNames.add("Total");
233 fieldNames = Collections.unmodifiableList(fieldNames);
234 }
235return fieldNames;
236 }
237238/***239 * Retrieves a field from the object by name passed in240 * as a String.241 */242public Object getByName(String name)
243 {
244if (name.equals("CoffeeId"))
245 {
246returnnew Integer(getCoffeeId());
247 }
248if (name.equals("CoffeeName"))
249 {
250return getCoffeeName();
251 }
252if (name.equals("SupplierId"))
253 {
254returnnew Integer(getSupplierId());
255 }
256if (name.equals("Price"))
257 {
258returnnew Double(getPrice());
259 }
260if (name.equals("Sales"))
261 {
262returnnew Integer(getSales());
263 }
264if (name.equals("Total"))
265 {
266returnnew Integer(getTotal());
267 }
268returnnull;
269 }
270271/***272 * Retrieves a field from the object by name passed in273 * as a String. The String must be one of the static274 * Strings defined in this Class' Peer.275 */276public Object getByPeerName(String name)
277 {
278if (name.equals(CoffeesPeer.COFFEE_ID ))
279 {
280returnnew Integer(getCoffeeId());
281 }
282if (name.equals(CoffeesPeer.COFFEE_NAME ))
283 {
284return getCoffeeName();
285 }
286if (name.equals(CoffeesPeer.SUPPLIER_ID ))
287 {
288returnnew Integer(getSupplierId());
289 }
290if (name.equals(CoffeesPeer.PRICE ))
291 {
292returnnew Double(getPrice());
293 }
294if (name.equals(CoffeesPeer.SALES ))
295 {
296returnnew Integer(getSales());
297 }
298if (name.equals(CoffeesPeer.TOTAL ))
299 {
300returnnew Integer(getTotal());
301 }
302returnnull;
303 }
304305/***306 * Retrieves a field from the object by Position as specified307 * in the xml schema. Zero-based.308 */309public Object getByPosition(int pos)
310 {
311if ( pos == 0 )
312 {
313returnnew Integer(getCoffeeId());
314 }
315if ( pos == 1 )
316 {
317return getCoffeeName();
318 }
319if ( pos == 2 )
320 {
321returnnew Integer(getSupplierId());
322 }
323if ( pos == 3 )
324 {
325returnnew Double(getPrice());
326 }
327if ( pos == 4 )
328 {
329returnnew Integer(getSales());
330 }
331if ( pos == 5 )
332 {
333returnnew Integer(getTotal());
334 }
335returnnull;
336 }
337338/***339 * Stores the object in the database. If the object is new,340 * it inserts it; otherwise an update is performed.341 */342publicvoid save() throws Exception
343 {
344 save(CoffeesPeer.getMapBuilder()
345 .getDatabaseMap().getName());
346 }
347348/***349 * Stores the object in the database. If the object is new,350 * it inserts it; otherwise an update is performed.351 * Note: this code is here because the method body is352 * auto-generated conditionally and therefore needs to be353 * in this file instead of in the super class, BaseObject.354 */355publicvoid save(String dbName) throws TorqueException
356 {
357 Connection con = null;
358try359 {
360 con = Transaction.begin(dbName);
361 save(con);
362 Transaction.commit(con);
363 }
364catch(TorqueException e)
365 {
366 Transaction.safeRollback(con);
367throw e;
368 }
369 }
370371/*** flag to prevent endless save loop, if this object is referenced372 by another object which falls in this transaction. */373privateboolean alreadyInSave = false;
374/***375 * Stores the object in the database. If the object is new,376 * it inserts it; otherwise an update is performed. This method377 * is meant to be used as part of a transaction, otherwise use378 * the save() method and the connection details will be handled379 * internally380 */381publicvoid save(Connection con) throws TorqueException
382 {
383if (!alreadyInSave)
384 {
385 alreadyInSave = true;
386387388389// If this object has been modified, then save it to the database.390if (isModified())
391 {
392if (isNew())
393 {
394 CoffeesPeer.doInsert((Coffees)this, con);
395 setNew(false);
396 }
397else398 {
399 CoffeesPeer.doUpdate((Coffees)this, con);
400 }
401402if (isCacheOnSave())
403 {
404 CoffeesManager.putInstance(this);
405 }
406 }
407408 alreadyInSave = false;
409 }
410 }
411412/***413 * Specify whether to cache the object after saving to the db.414 * This method returns false415 */416protectedboolean isCacheOnSave()
417 {
418returntrue;
419 }
420421422/***423 * Set the PrimaryKey using ObjectKey.424 *425 * @param ObjectKey coffeeId426 */427publicvoid setPrimaryKey(ObjectKey coffeeId)
428 {
429 setCoffeeId(((NumberKey)coffeeId).intValue());
430 }
431432/***433 * Set the PrimaryKey using a String.434 */435publicvoid setPrimaryKey(String key)
436 {
437 setCoffeeId(Integer.parseInt(key));
438 }
439440441/***442 * returns an id that differentiates this object from others443 * of its class.444 */445public ObjectKey getPrimaryKey()
446 {
447return SimpleKey.keyFor(getCoffeeId());
448 }
449450451/***452 * Makes a copy of this object.453 * It creates a new object filling in the simple attributes.454 * It then fills all the association collections.455 */456publicCoffees copy() throws TorqueException
457 {
458Coffees copyObj = newCoffees();
459 copyObj.setCoffeeId(coffeeId);
460 copyObj.setCoffeeName(coffeeName);
461 copyObj.setSupplierId(supplierId);
462 copyObj.setPrice(price);
463 copyObj.setSales(sales);
464 copyObj.setTotal(total);
465466 copyObj.setCoffeeId(0);
467468return copyObj;
469 }
470471/***472 * returns a peer instance associated with this om. Since Peer classes473 * are not to have any instance attributes, this method returns the474 * same instance for all member of this class. The method could therefore475 * be static, but this would prevent one from overriding the behavior.476 */477publicCoffeesPeer getPeer()
478 {
479return peer;
480 }
481 }