KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > campware > cream > om > BaseProductPeer


1 package org.campware.cream.om;
2
3 import java.math.BigDecimal JavaDoc;
4 import java.sql.Connection JavaDoc;
5 import java.sql.SQLException JavaDoc;
6 import java.util.ArrayList JavaDoc;
7 import java.util.Date JavaDoc;
8 import java.util.Iterator JavaDoc;
9 import java.util.LinkedList JavaDoc;
10 import java.util.List JavaDoc;
11
12 import org.apache.torque.NoRowsException;
13 import org.apache.torque.TooManyRowsException;
14 import org.apache.torque.Torque;
15 import org.apache.torque.TorqueException;
16 import org.apache.torque.map.MapBuilder;
17 import org.apache.torque.map.TableMap;
18 import org.apache.torque.om.DateKey;
19 import org.apache.torque.om.NumberKey;
20 import org.apache.torque.om.StringKey;
21 import org.apache.torque.om.ObjectKey;
22 import org.apache.torque.om.SimpleKey;
23 import org.apache.torque.util.BasePeer;
24 import org.apache.torque.util.Criteria;
25
26 import com.workingdogs.village.DataSetException;
27 import com.workingdogs.village.QueryDataSet;
28 import com.workingdogs.village.Record;
29
30 // Local classes
31
import org.campware.cream.om.map.*;
32
33
34   
35   
36   
37 /**
38  * This class was autogenerated by Torque on:
39  *
40  * [Wed May 04 09:10:56 CEST 2005]
41  *
42  */

43 public abstract class BaseProductPeer
44     extends BasePeer
45 {
46
47     /** the default database name for this class */
48     public static final String JavaDoc DATABASE_NAME = "cream";
49
50      /** the table name for this class */
51     public static final String JavaDoc TABLE_NAME = "PRODUCT";
52
53     /**
54      * @return the map builder for this peer
55      * @throws TorqueException Any exceptions caught during processing will be
56      * rethrown wrapped into a TorqueException.
57      */

58     public static MapBuilder getMapBuilder()
59         throws TorqueException
60     {
61         return getMapBuilder(ProductMapBuilder.CLASS_NAME);
62     }
63
64       /** the column name for the PRODUCT_ID field */
65     public static final String JavaDoc PRODUCT_ID;
66       /** the column name for the PRODUCT_CODE field */
67     public static final String JavaDoc PRODUCT_CODE;
68       /** the column name for the STATUS field */
69     public static final String JavaDoc STATUS;
70       /** the column name for the PRIORITY field */
71     public static final String JavaDoc PRIORITY;
72       /** the column name for the PRODUCT_TYPE field */
73     public static final String JavaDoc PRODUCT_TYPE;
74       /** the column name for the PRODUCT_CAT_ID field */
75     public static final String JavaDoc PRODUCT_CAT_ID;
76       /** the column name for the PRODUCT_DESCRIPTION field */
77     public static final String JavaDoc PRODUCT_DESCRIPTION;
78       /** the column name for the PRODUCT_DISPLAY field */
79     public static final String JavaDoc PRODUCT_DISPLAY;
80       /** the column name for the BASE_PRICE field */
81     public static final String JavaDoc BASE_PRICE;
82       /** the column name for the UOM_ID field */
83     public static final String JavaDoc UOM_ID;
84       /** the column name for the WEB_URL field */
85     public static final String JavaDoc WEB_URL;
86       /** the column name for the SHOW_ON_PRICELIST field */
87     public static final String JavaDoc SHOW_ON_PRICELIST;
88       /** the column name for the VENDOR_ID field */
89     public static final String JavaDoc VENDOR_ID;
90       /** the column name for the VENDORS_CODE field */
91     public static final String JavaDoc VENDORS_CODE;
92       /** the column name for the EAN_UPC_CODE field */
93     public static final String JavaDoc EAN_UPC_CODE;
94       /** the column name for the LOCATION field */
95     public static final String JavaDoc LOCATION;
96       /** the column name for the CUSTOM_1 field */
97     public static final String JavaDoc CUSTOM_1;
98       /** the column name for the CUSTOM_2 field */
99     public static final String JavaDoc CUSTOM_2;
100       /** the column name for the CUSTOM_3 field */
101     public static final String JavaDoc CUSTOM_3;
102       /** the column name for the CUSTOM_4 field */
103     public static final String JavaDoc CUSTOM_4;
104       /** the column name for the CUSTOM_5 field */
105     public static final String JavaDoc CUSTOM_5;
106       /** the column name for the CUSTOM_6 field */
107     public static final String JavaDoc CUSTOM_6;
108       /** the column name for the NOTES field */
109     public static final String JavaDoc NOTES;
110       /** the column name for the CREATED field */
111     public static final String JavaDoc CREATED;
112       /** the column name for the MODIFIED field */
113     public static final String JavaDoc MODIFIED;
114       /** the column name for the CREATED_BY field */
115     public static final String JavaDoc CREATED_BY;
116       /** the column name for the MODIFIED_BY field */
117     public static final String JavaDoc MODIFIED_BY;
118   
119     static
120     {
121           PRODUCT_ID = "PRODUCT.PRODUCT_ID";
122           PRODUCT_CODE = "PRODUCT.PRODUCT_CODE";
123           STATUS = "PRODUCT.STATUS";
124           PRIORITY = "PRODUCT.PRIORITY";
125           PRODUCT_TYPE = "PRODUCT.PRODUCT_TYPE";
126           PRODUCT_CAT_ID = "PRODUCT.PRODUCT_CAT_ID";
127           PRODUCT_DESCRIPTION = "PRODUCT.PRODUCT_DESCRIPTION";
128           PRODUCT_DISPLAY = "PRODUCT.PRODUCT_DISPLAY";
129           BASE_PRICE = "PRODUCT.BASE_PRICE";
130           UOM_ID = "PRODUCT.UOM_ID";
131           WEB_URL = "PRODUCT.WEB_URL";
132           SHOW_ON_PRICELIST = "PRODUCT.SHOW_ON_PRICELIST";
133           VENDOR_ID = "PRODUCT.VENDOR_ID";
134           VENDORS_CODE = "PRODUCT.VENDORS_CODE";
135           EAN_UPC_CODE = "PRODUCT.EAN_UPC_CODE";
136           LOCATION = "PRODUCT.LOCATION";
137           CUSTOM_1 = "PRODUCT.CUSTOM_1";
138           CUSTOM_2 = "PRODUCT.CUSTOM_2";
139           CUSTOM_3 = "PRODUCT.CUSTOM_3";
140           CUSTOM_4 = "PRODUCT.CUSTOM_4";
141           CUSTOM_5 = "PRODUCT.CUSTOM_5";
142           CUSTOM_6 = "PRODUCT.CUSTOM_6";
143           NOTES = "PRODUCT.NOTES";
144           CREATED = "PRODUCT.CREATED";
145           MODIFIED = "PRODUCT.MODIFIED";
146           CREATED_BY = "PRODUCT.CREATED_BY";
147           MODIFIED_BY = "PRODUCT.MODIFIED_BY";
148           if (Torque.isInit())
149         {
150             try
151             {
152                 getMapBuilder(ProductMapBuilder.CLASS_NAME);
153             }
154             catch (Exception JavaDoc e)
155             {
156                 log.error("Could not initialize Peer", e);
157             }
158         }
159         else
160         {
161             Torque.registerMapBuilder(ProductMapBuilder.CLASS_NAME);
162         }
163     }
164  
165     /** number of columns for this peer */
166     public static final int numColumns = 27;
167
168     /** A class that can be returned by this peer. */
169     protected static final String JavaDoc CLASSNAME_DEFAULT =
170         "org.campware.cream.om.Product";
171
172     /** A class that can be returned by this peer. */
173     protected static final Class JavaDoc CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT);
174
175     /**
176      * Class object initialization method.
177      *
178      * @param className name of the class to initialize
179      * @return the initialized class
180      */

181     private static Class JavaDoc initClass(String JavaDoc className)
182     {
183         Class JavaDoc c = null;
184         try
185         {
186             c = Class.forName(className);
187         }
188         catch (Throwable JavaDoc t)
189         {
190             log.error("A FATAL ERROR has occurred which should not "
191                 + "have happened under any circumstance. Please notify "
192                 + "the Torque developers <torque-dev@db.apache.org> "
193                 + "and give as many details as possible (including the error "
194                 + "stack trace).", t);
195
196             // Error objects should always be propogated.
197
if (t instanceof Error JavaDoc)
198             {
199                 throw (Error JavaDoc) t.fillInStackTrace();
200             }
201         }
202         return c;
203     }
204
205     /**
206      * Get the list of objects for a ResultSet. Please not that your
207      * resultset MUST return columns in the right order. You can use
208      * getFieldNames() in BaseObject to get the correct sequence.
209      *
210      * @param results the ResultSet
211      * @return the list of objects
212      * @throws TorqueException Any exceptions caught during processing will be
213      * rethrown wrapped into a TorqueException.
214      */

215     public static List JavaDoc resultSet2Objects(java.sql.ResultSet JavaDoc results)
216             throws TorqueException
217     {
218         try
219         {
220             QueryDataSet qds = null;
221             List JavaDoc rows = null;
222             try
223             {
224                 qds = new QueryDataSet(results);
225                 rows = getSelectResults(qds);
226             }
227             finally
228             {
229                 if (qds != null)
230                 {
231                     qds.close();
232                 }
233             }
234
235             return populateObjects(rows);
236         }
237         catch (SQLException JavaDoc e)
238         {
239             throw new TorqueException(e);
240         }
241         catch (DataSetException e)
242         {
243             throw new TorqueException(e);
244         }
245     }
246
247
248   
249     /**
250      * Method to do inserts.
251      *
252      * @param criteria object used to create the INSERT statement.
253      * @throws TorqueException Any exceptions caught during processing will be
254      * rethrown wrapped into a TorqueException.
255      */

256     public static ObjectKey doInsert(Criteria criteria)
257         throws TorqueException
258     {
259         return BaseProductPeer
260             .doInsert(criteria, (Connection JavaDoc) null);
261     }
262
263     /**
264      * Method to do inserts. This method is to be used during a transaction,
265      * otherwise use the doInsert(Criteria) method. It will take care of
266      * the connection details internally.
267      *
268      * @param criteria object used to create the INSERT statement.
269      * @param con the connection to use
270      * @throws TorqueException Any exceptions caught during processing will be
271      * rethrown wrapped into a TorqueException.
272      */

273     public static ObjectKey doInsert(Criteria criteria, Connection JavaDoc con)
274         throws TorqueException
275     {
276                                                                                                                                                                     
277         setDbName(criteria);
278
279         if (con == null)
280         {
281             return BasePeer.doInsert(criteria);
282         }
283         else
284         {
285             return BasePeer.doInsert(criteria, con);
286         }
287     }
288
289     /**
290      * Add all the columns needed to create a new object.
291      *
292      * @param criteria object containing the columns to add.
293      * @throws TorqueException Any exceptions caught during processing will be
294      * rethrown wrapped into a TorqueException.
295      */

296     public static void addSelectColumns(Criteria criteria)
297             throws TorqueException
298     {
299           criteria.addSelectColumn(PRODUCT_ID);
300           criteria.addSelectColumn(PRODUCT_CODE);
301           criteria.addSelectColumn(STATUS);
302           criteria.addSelectColumn(PRIORITY);
303           criteria.addSelectColumn(PRODUCT_TYPE);
304           criteria.addSelectColumn(PRODUCT_CAT_ID);
305           criteria.addSelectColumn(PRODUCT_DESCRIPTION);
306           criteria.addSelectColumn(PRODUCT_DISPLAY);
307           criteria.addSelectColumn(BASE_PRICE);
308           criteria.addSelectColumn(UOM_ID);
309           criteria.addSelectColumn(WEB_URL);
310           criteria.addSelectColumn(SHOW_ON_PRICELIST);
311           criteria.addSelectColumn(VENDOR_ID);
312           criteria.addSelectColumn(VENDORS_CODE);
313           criteria.addSelectColumn(EAN_UPC_CODE);
314           criteria.addSelectColumn(LOCATION);
315           criteria.addSelectColumn(CUSTOM_1);
316           criteria.addSelectColumn(CUSTOM_2);
317           criteria.addSelectColumn(CUSTOM_3);
318           criteria.addSelectColumn(CUSTOM_4);
319           criteria.addSelectColumn(CUSTOM_5);
320           criteria.addSelectColumn(CUSTOM_6);
321           criteria.addSelectColumn(NOTES);
322           criteria.addSelectColumn(CREATED);
323           criteria.addSelectColumn(MODIFIED);
324           criteria.addSelectColumn(CREATED_BY);
325           criteria.addSelectColumn(MODIFIED_BY);
326       }
327
328     /**
329      * Create a new object of type cls from a resultset row starting
330      * from a specified offset. This is done so that you can select
331      * other rows than just those needed for this object. You may
332      * for example want to create two objects from the same row.
333      *
334      * @throws TorqueException Any exceptions caught during processing will be
335      * rethrown wrapped into a TorqueException.
336      */

337     public static Product row2Object(Record row,
338                                              int offset,
339                                              Class JavaDoc cls)
340         throws TorqueException
341     {
342         try
343         {
344             Product obj = (Product) cls.newInstance();
345             ProductPeer.populateObject(row, offset, obj);
346                   obj.setModified(false);
347               obj.setNew(false);
348
349             return obj;
350         }
351         catch (InstantiationException JavaDoc e)
352         {
353             throw new TorqueException(e);
354         }
355         catch (IllegalAccessException JavaDoc e)
356         {
357             throw new TorqueException(e);
358         }
359     }
360
361     /**
362      * Populates an object from a resultset row starting
363      * from a specified offset. This is done so that you can select
364      * other rows than just those needed for this object. You may
365      * for example want to create two objects from the same row.
366      *
367      * @throws TorqueException Any exceptions caught during processing will be
368      * rethrown wrapped into a TorqueException.
369      */

370     public static void populateObject(Record row,
371                                       int offset,
372                                       Product obj)
373         throws TorqueException
374     {
375         try
376         {
377                 obj.setProductId(row.getValue(offset + 0).asInt());
378                   obj.setProductCode(row.getValue(offset + 1).asString());
379                   obj.setStatus(row.getValue(offset + 2).asInt());
380                   obj.setPriority(row.getValue(offset + 3).asInt());
381                   obj.setProductType(row.getValue(offset + 4).asInt());
382                   obj.setProductCatId(row.getValue(offset + 5).asInt());
383                   obj.setProductDescription(row.getValue(offset + 6).asString());
384                   obj.setProductDisplay(row.getValue(offset + 7).asString());
385                   obj.setBasePrice(row.getValue(offset + 8).asDouble());
386                   obj.setUomId(row.getValue(offset + 9).asInt());
387                   obj.setWebUrl(row.getValue(offset + 10).asString());
388                   obj.setShowOnPricelist(row.getValue(offset + 11).asInt());
389                   obj.setVendorId(row.getValue(offset + 12).asInt());
390                   obj.setVendorsCode(row.getValue(offset + 13).asString());
391                   obj.setEanUpcCode(row.getValue(offset + 14).asString());
392                   obj.setLocation(row.getValue(offset + 15).asString());
393                   obj.setCustom1(row.getValue(offset + 16).asString());
394                   obj.setCustom2(row.getValue(offset + 17).asString());
395                   obj.setCustom3(row.getValue(offset + 18).asString());
396                   obj.setCustom4(row.getValue(offset + 19).asString());
397                   obj.setCustom5(row.getValue(offset + 20).asString());
398                   obj.setCustom6(row.getValue(offset + 21).asString());
399                   obj.setNotes(row.getValue(offset + 22).asString());
400                   obj.setCreated(row.getValue(offset + 23).asUtilDate());
401                   obj.setModified(row.getValue(offset + 24).asUtilDate());
402                   obj.setCreatedBy(row.getValue(offset + 25).asString());
403                   obj.setModifiedBy(row.getValue(offset + 26).asString());
404               }
405         catch (DataSetException e)
406         {
407             throw new TorqueException(e);
408         }
409     }
410
411     /**
412      * Method to do selects.
413      *
414      * @param criteria object used to create the SELECT statement.
415      * @return List of selected Objects
416      * @throws TorqueException Any exceptions caught during processing will be
417      * rethrown wrapped into a TorqueException.
418      */

419     public static List JavaDoc doSelect(Criteria criteria) throws TorqueException
420     {
421         return populateObjects(doSelectVillageRecords(criteria));
422     }
423
424     /**
425      * Method to do selects within a transaction.
426      *
427      * @param criteria object used to create the SELECT statement.
428      * @param con the connection to use
429      * @return List of selected Objects
430      * @throws TorqueException Any exceptions caught during processing will be
431      * rethrown wrapped into a TorqueException.
432      */

433     public static List JavaDoc doSelect(Criteria criteria, Connection JavaDoc con)
434         throws TorqueException
435     {
436         return populateObjects(doSelectVillageRecords(criteria, con));
437     }
438
439     /**
440      * Grabs the raw Village records to be formed into objects.
441      * This method handles connections internally. The Record objects
442      * returned by this method should be considered readonly. Do not
443      * alter the data and call save(), your results may vary, but are
444      * certainly likely to result in hard to track MT bugs.
445      *
446      * @throws TorqueException Any exceptions caught during processing will be
447      * rethrown wrapped into a TorqueException.
448      */

449     public static List JavaDoc doSelectVillageRecords(Criteria criteria)
450         throws TorqueException
451     {
452         return BaseProductPeer
453             .doSelectVillageRecords(criteria, (Connection JavaDoc) null);
454     }
455
456     /**
457      * Grabs the raw Village records to be formed into objects.
458      * This method should be used for transactions
459      *
460      * @param criteria object used to create the SELECT statement.
461      * @param con the connection to use
462      * @throws TorqueException Any exceptions caught during processing will be
463      * rethrown wrapped into a TorqueException.
464      */

465     public static List JavaDoc doSelectVillageRecords(Criteria criteria, Connection JavaDoc con)
466         throws TorqueException
467     {
468         if (criteria.getSelectColumns().size() == 0)
469         {
470             addSelectColumns(criteria);
471         }
472
473                                                                                                                                                                     
474         setDbName(criteria);
475
476         // BasePeer returns a List of Value (Village) arrays. The array
477
// order follows the order columns were placed in the Select clause.
478
if (con == null)
479         {
480             return BasePeer.doSelect(criteria);
481         }
482         else
483         {
484             return BasePeer.doSelect(criteria, con);
485         }
486     }
487
488     /**
489      * The returned List will contain objects of the default type or
490      * objects that inherit from the default.
491      *
492      * @throws TorqueException Any exceptions caught during processing will be
493      * rethrown wrapped into a TorqueException.
494      */

495     public static List JavaDoc populateObjects(List JavaDoc records)
496         throws TorqueException
497     {
498         List JavaDoc results = new ArrayList JavaDoc(records.size());
499
500         // populate the object(s)
501
for (int i = 0; i < records.size(); i++)
502         {
503             Record row = (Record) records.get(i);
504               results.add(ProductPeer.row2Object(row, 1,
505                 ProductPeer.getOMClass()));
506           }
507         return results;
508     }
509  
510
511     /**
512      * The class that the Peer will make instances of.
513      * If the BO is abstract then you must implement this method
514      * in the BO.
515      *
516      * @throws TorqueException Any exceptions caught during processing will be
517      * rethrown wrapped into a TorqueException.
518      */

519     public static Class JavaDoc getOMClass()
520         throws TorqueException
521     {
522         return CLASS_DEFAULT;
523     }
524
525     /**
526      * Method to do updates.
527      *
528      * @param criteria object containing data that is used to create the UPDATE
529      * statement.
530      * @throws TorqueException Any exceptions caught during processing will be
531      * rethrown wrapped into a TorqueException.
532      */

533     public static void doUpdate(Criteria criteria) throws TorqueException
534     {
535          BaseProductPeer
536             .doUpdate(criteria, (Connection JavaDoc) null);
537     }
538
539     /**
540      * Method to do updates. This method is to be used during a transaction,
541      * otherwise use the doUpdate(Criteria) method. It will take care of
542      * the connection details internally.
543      *
544      * @param criteria object containing data that is used to create the UPDATE
545      * statement.
546      * @param con the connection to use
547      * @throws TorqueException Any exceptions caught during processing will be
548      * rethrown wrapped into a TorqueException.
549      */

550     public static void doUpdate(Criteria criteria, Connection JavaDoc con)
551         throws TorqueException
552     {
553         Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
554                    selectCriteria.put(PRODUCT_ID, criteria.remove(PRODUCT_ID));
555                                                                                                                                                                                                                                                                           
556         setDbName(criteria);
557
558         if (con == null)
559         {
560             BasePeer.doUpdate(selectCriteria, criteria);
561         }
562         else
563         {
564             BasePeer.doUpdate(selectCriteria, criteria, con);
565         }
566     }
567
568     /**
569      * Method to do deletes.
570      *
571      * @param criteria object containing data that is used DELETE from database.
572      * @throws TorqueException Any exceptions caught during processing will be
573      * rethrown wrapped into a TorqueException.
574      */

575      public static void doDelete(Criteria criteria) throws TorqueException
576      {
577          ProductPeer
578             .doDelete(criteria, (Connection JavaDoc) null);
579      }
580
581     /**
582      * Method to do deletes. This method is to be used during a transaction,
583      * otherwise use the doDelete(Criteria) method. It will take care of
584      * the connection details internally.
585      *
586      * @param criteria object containing data that is used DELETE from database.
587      * @param con the connection to use
588      * @throws TorqueException Any exceptions caught during processing will be
589      * rethrown wrapped into a TorqueException.
590      */

591      public static void doDelete(Criteria criteria, Connection JavaDoc con)
592         throws TorqueException
593      {
594                                                                                                                                                                     
595         setDbName(criteria);
596
597         if (con == null)
598         {
599             BasePeer.doDelete(criteria);
600         }
601         else
602         {
603             BasePeer.doDelete(criteria, con);
604         }
605      }
606
607     /**
608      * Method to do selects
609      *
610      * @throws TorqueException Any exceptions caught during processing will be
611      * rethrown wrapped into a TorqueException.
612      */

613     public static List JavaDoc doSelect(Product obj) throws TorqueException
614     {
615         return doSelect(buildSelectCriteria(obj));
616     }
617
618     /**
619      * Method to do inserts
620      *
621      * @throws TorqueException Any exceptions caught during processing will be
622      * rethrown wrapped into a TorqueException.
623      */

624     public static void doInsert(Product obj) throws TorqueException
625     {
626           obj.setPrimaryKey(doInsert(buildCriteria(obj)));
627           obj.setNew(false);
628         obj.setModified(false);
629     }
630
631     /**
632      * @param obj the data object to update in the database.
633      * @throws TorqueException Any exceptions caught during processing will be
634      * rethrown wrapped into a TorqueException.
635      */

636     public static void doUpdate(Product obj) throws TorqueException
637     {
638         doUpdate(buildCriteria(obj));
639         obj.setModified(false);
640     }
641
642     /**
643      * @param obj the data object to delete in the database.
644      * @throws TorqueException Any exceptions caught during processing will be
645      * rethrown wrapped into a TorqueException.
646      */

647     public static void doDelete(Product obj) throws TorqueException
648     {
649         doDelete(buildSelectCriteria(obj));
650     }
651
652     /**
653      * Method to do inserts. This method is to be used during a transaction,
654      * otherwise use the doInsert(Product) method. It will take
655      * care of the connection details internally.
656      *
657      * @param obj the data object to insert into the database.
658      * @param con the connection to use
659      * @throws TorqueException Any exceptions caught during processing will be
660      * rethrown wrapped into a TorqueException.
661      */

662     public static void doInsert(Product obj, Connection JavaDoc con)
663         throws TorqueException
664     {
665           obj.setPrimaryKey(doInsert(buildCriteria(obj), con));
666           obj.setNew(false);
667         obj.setModified(false);
668     }
669
670     /**
671      * Method to do update. This method is to be used during a transaction,
672      * otherwise use the doUpdate(Product) method. It will take
673      * care of the connection details internally.
674      *
675      * @param obj the data object to update in the database.
676      * @param con the connection to use
677      * @throws TorqueException Any exceptions caught during processing will be
678      * rethrown wrapped into a TorqueException.
679      */

680     public static void doUpdate(Product obj, Connection JavaDoc con)
681         throws TorqueException
682     {
683         doUpdate(buildCriteria(obj), con);
684         obj.setModified(false);
685     }
686
687     /**
688      * Method to delete. This method is to be used during a transaction,
689      * otherwise use the doDelete(Product) method. It will take
690      * care of the connection details internally.
691      *
692      * @param obj the data object to delete in the database.
693      * @param con the connection to use
694      * @throws TorqueException Any exceptions caught during processing will be
695      * rethrown wrapped into a TorqueException.
696      */

697     public static void doDelete(Product obj, Connection JavaDoc con)
698         throws TorqueException
699     {
700         doDelete(buildSelectCriteria(obj), con);
701     }
702
703     /**
704      * Method to do deletes.
705      *
706      * @param pk ObjectKey that is used DELETE from database.
707      * @throws TorqueException Any exceptions caught during processing will be
708      * rethrown wrapped into a TorqueException.
709      */

710     public static void doDelete(ObjectKey pk) throws TorqueException
711     {
712         BaseProductPeer
713            .doDelete(pk, (Connection JavaDoc) null);
714     }
715
716     /**
717      * Method to delete. This method is to be used during a transaction,
718      * otherwise use the doDelete(ObjectKey) method. It will take
719      * care of the connection details internally.
720      *
721      * @param pk the primary key for the object to delete in the database.
722      * @param con the connection to use
723      * @throws TorqueException Any exceptions caught during processing will be
724      * rethrown wrapped into a TorqueException.
725      */

726     public static void doDelete(ObjectKey pk, Connection JavaDoc con)
727         throws TorqueException
728     {
729         doDelete(buildCriteria(pk), con);
730     }
731
732     /** Build a Criteria object from an ObjectKey */
733     public static Criteria buildCriteria( ObjectKey pk )
734     {
735         Criteria criteria = new Criteria();
736               criteria.add(PRODUCT_ID, pk);
737           return criteria;
738      }
739
740     /** Build a Criteria object from the data object for this peer */
741     public static Criteria buildCriteria( Product obj )
742     {
743         Criteria criteria = new Criteria(DATABASE_NAME);
744               if (!obj.isNew())
745             criteria.add(PRODUCT_ID, obj.getProductId());
746               criteria.add(PRODUCT_CODE, obj.getProductCode());
747               criteria.add(STATUS, obj.getStatus());
748               criteria.add(PRIORITY, obj.getPriority());
749               criteria.add(PRODUCT_TYPE, obj.getProductType());
750               criteria.add(PRODUCT_CAT_ID, obj.getProductCatId());
751               criteria.add(PRODUCT_DESCRIPTION, obj.getProductDescription());
752               criteria.add(PRODUCT_DISPLAY, obj.getProductDisplay());
753               criteria.add(BASE_PRICE, obj.getBasePrice());
754               criteria.add(UOM_ID, obj.getUomId());
755               criteria.add(WEB_URL, obj.getWebUrl());
756               criteria.add(SHOW_ON_PRICELIST, obj.getShowOnPricelist());
757               criteria.add(VENDOR_ID, obj.getVendorId());
758               criteria.add(VENDORS_CODE, obj.getVendorsCode());
759               criteria.add(EAN_UPC_CODE, obj.getEanUpcCode());
760               criteria.add(LOCATION, obj.getLocation());
761               criteria.add(CUSTOM_1, obj.getCustom1());
762               criteria.add(CUSTOM_2, obj.getCustom2());
763               criteria.add(CUSTOM_3, obj.getCustom3());
764               criteria.add(CUSTOM_4, obj.getCustom4());
765               criteria.add(CUSTOM_5, obj.getCustom5());
766               criteria.add(CUSTOM_6, obj.getCustom6());
767               criteria.add(NOTES, obj.getNotes());
768               criteria.add(CREATED, obj.getCreated());
769               criteria.add(MODIFIED, obj.getModified());
770               criteria.add(CREATED_BY, obj.getCreatedBy());
771               criteria.add(MODIFIED_BY, obj.getModifiedBy());
772           return criteria;
773     }
774
775     /** Build a Criteria object from the data object for this peer, skipping all binary columns */
776     public static Criteria buildSelectCriteria( Product obj )
777     {
778         Criteria criteria = new Criteria(DATABASE_NAME);
779               if (!obj.isNew())
780                     criteria.add(PRODUCT_ID, obj.getProductId());
781                           criteria.add(PRODUCT_CODE, obj.getProductCode());
782                           criteria.add(STATUS, obj.getStatus());
783                           criteria.add(PRIORITY, obj.getPriority());
784                           criteria.add(PRODUCT_TYPE, obj.getProductType());
785                           criteria.add(PRODUCT_CAT_ID, obj.getProductCatId());
786                           criteria.add(PRODUCT_DESCRIPTION, obj.getProductDescription());
787                           criteria.add(PRODUCT_DISPLAY, obj.getProductDisplay());
788                           criteria.add(BASE_PRICE, obj.getBasePrice());
789                           criteria.add(UOM_ID, obj.getUomId());
790                           criteria.add(WEB_URL, obj.getWebUrl());
791                           criteria.add(SHOW_ON_PRICELIST, obj.getShowOnPricelist());
792                           criteria.add(VENDOR_ID, obj.getVendorId());
793                           criteria.add(VENDORS_CODE, obj.getVendorsCode());
794                           criteria.add(EAN_UPC_CODE, obj.getEanUpcCode());
795                           criteria.add(LOCATION, obj.getLocation());
796                           criteria.add(CUSTOM_1, obj.getCustom1());
797                           criteria.add(CUSTOM_2, obj.getCustom2());
798                           criteria.add(CUSTOM_3, obj.getCustom3());
799                           criteria.add(CUSTOM_4, obj.getCustom4());
800                           criteria.add(CUSTOM_5, obj.getCustom5());
801                           criteria.add(CUSTOM_6, obj.getCustom6());
802                           criteria.add(NOTES, obj.getNotes());
803                           criteria.add(CREATED, obj.getCreated());
804                           criteria.add(MODIFIED, obj.getModified());
805                           criteria.add(CREATED_BY, obj.getCreatedBy());
806                           criteria.add(MODIFIED_BY, obj.getModifiedBy());
807               return criteria;
808     }
809  
810     
811         /**
812      * Retrieve a single object by pk
813      *
814      * @param pk the primary key
815      * @throws TorqueException Any exceptions caught during processing will be
816      * rethrown wrapped into a TorqueException.
817      * @throws NoRowsException Primary key was not found in database.
818      * @throws TooManyRowsException Primary key was not found in database.
819      */

820     public static Product retrieveByPK(int pk)
821         throws TorqueException, NoRowsException, TooManyRowsException
822     {
823         return retrieveByPK(SimpleKey.keyFor(pk));
824     }
825
826     /**
827      * Retrieve a single object by pk
828      *
829      * @param pk the primary key
830      * @param con the connection to use
831      * @throws TorqueException Any exceptions caught during processing will be
832      * rethrown wrapped into a TorqueException.
833      * @throws NoRowsException Primary key was not found in database.
834      * @throws TooManyRowsException Primary key was not found in database.
835      */

836     public static Product retrieveByPK(int pk, Connection JavaDoc con)
837         throws TorqueException, NoRowsException, TooManyRowsException
838     {
839         return retrieveByPK(SimpleKey.keyFor(pk), con);
840     }
841   
842     /**
843      * Retrieve a single object by pk
844      *
845      * @param pk the primary key
846      * @throws TorqueException Any exceptions caught during processing will be
847      * rethrown wrapped into a TorqueException.
848      * @throws NoRowsException Primary key was not found in database.
849      * @throws TooManyRowsException Primary key was not found in database.
850      */

851     public static Product retrieveByPK(ObjectKey pk)
852         throws TorqueException, NoRowsException, TooManyRowsException
853     {
854         Connection JavaDoc db = null;
855         Product retVal = null;
856         try
857         {
858             db = Torque.getConnection(DATABASE_NAME);
859             retVal = retrieveByPK(pk, db);
860         }
861         finally
862         {
863             Torque.closeConnection(db);
864         }
865         return(retVal);
866     }
867
868     /**
869      * Retrieve a single object by pk
870      *
871      * @param pk the primary key
872      * @param con the connection to use
873      * @throws TorqueException Any exceptions caught during processing will be
874      * rethrown wrapped into a TorqueException.
875      * @throws NoRowsException Primary key was not found in database.
876      * @throws TooManyRowsException Primary key was not found in database.
877      */

878     public static Product retrieveByPK(ObjectKey pk, Connection JavaDoc con)
879         throws TorqueException, NoRowsException, TooManyRowsException
880     {
881         Criteria criteria = buildCriteria(pk);
882         List JavaDoc v = doSelect(criteria, con);
883         if (v.size() == 0)
884         {
885             throw new NoRowsException("Failed to select a row.");
886         }
887         else if (v.size() > 1)
888         {
889             throw new TooManyRowsException("Failed to select only one row.");
890         }
891         else
892         {
893             return (Product)v.get(0);
894         }
895     }
896
897     /**
898      * Retrieve a multiple objects by pk
899      *
900      * @param pks List of primary keys
901      * @throws TorqueException Any exceptions caught during processing will be
902      * rethrown wrapped into a TorqueException.
903      */

904     public static List JavaDoc retrieveByPKs(List JavaDoc pks)
905         throws TorqueException
906     {
907         Connection JavaDoc db = null;
908         List JavaDoc retVal = null;
909         try
910         {
911            db = Torque.getConnection(DATABASE_NAME);
912            retVal = retrieveByPKs(pks, db);
913         }
914         finally
915         {
916             Torque.closeConnection(db);
917         }
918         return(retVal);
919     }
920
921     /**
922      * Retrieve a multiple objects by pk
923      *
924      * @param pks List of primary keys
925      * @param dbcon the connection to use
926      * @throws TorqueException Any exceptions caught during processing will be
927      * rethrown wrapped into a TorqueException.
928      */

929     public static List JavaDoc retrieveByPKs( List JavaDoc pks, Connection JavaDoc dbcon )
930         throws TorqueException
931     {
932         List JavaDoc objs = null;
933         if (pks == null || pks.size() == 0)
934         {
935             objs = new LinkedList JavaDoc();
936         }
937         else
938         {
939             Criteria criteria = new Criteria();
940               criteria.addIn( PRODUCT_ID, pks );
941           objs = doSelect(criteria, dbcon);
942         }
943         return objs;
944     }
945
946  
947
948
949
950               
951                                               
952                 
953                 
954
955     /**
956      * selects a collection of Product objects pre-filled with their
957      * ProductCategory objects.
958      *
959      * This method is protected by default in order to keep the public
960      * api reasonable. You can provide public methods for those you
961      * actually need in ProductPeer.
962      *
963      * @throws TorqueException Any exceptions caught during processing will be
964      * rethrown wrapped into a TorqueException.
965      */

966     protected static List JavaDoc doSelectJoinProductCategory(Criteria criteria)
967         throws TorqueException
968     {
969         setDbName(criteria);
970
971         ProductPeer.addSelectColumns(criteria);
972         int offset = numColumns + 1;
973         ProductCategoryPeer.addSelectColumns(criteria);
974
975
976                         criteria.addJoin(ProductPeer.PRODUCT_CAT_ID,
977             ProductCategoryPeer.PRODUCT_CAT_ID);
978         
979
980                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
981         List JavaDoc rows = BasePeer.doSelect(criteria);
982         List JavaDoc results = new ArrayList JavaDoc();
983
984         for (int i = 0; i < rows.size(); i++)
985         {
986             Record row = (Record) rows.get(i);
987
988                             Class JavaDoc omClass = ProductPeer.getOMClass();
989                     Product obj1 = (Product) ProductPeer
990                 .row2Object(row, 1, omClass);
991                      omClass = ProductCategoryPeer.getOMClass();
992                     ProductCategory obj2 = (ProductCategory)ProductCategoryPeer
993                 .row2Object(row, offset, omClass);
994
995             boolean newObject = true;
996             for (int j = 0; j < results.size(); j++)
997             {
998                 Product temp_obj1 = (Product)results.get(j);
999                 ProductCategory temp_obj2 = (ProductCategory)temp_obj1.getProductCategory();
1000                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1001                {
1002                    newObject = false;
1003                              temp_obj2.addProduct(obj1);
1004                              break;
1005                }
1006            }
1007                      if (newObject)
1008            {
1009                obj2.initProducts();
1010                obj2.addProduct(obj1);
1011            }
1012                      results.add(obj1);
1013        }
1014        return results;
1015    }
1016                                                            
1017                
1018                
1019
1020    /**
1021     * selects a collection of Product objects pre-filled with their
1022     * Uom objects.
1023     *
1024     * This method is protected by default in order to keep the public
1025     * api reasonable. You can provide public methods for those you
1026     * actually need in ProductPeer.
1027     *
1028     * @throws TorqueException Any exceptions caught during processing will be
1029     * rethrown wrapped into a TorqueException.
1030     */

1031    protected static List JavaDoc doSelectJoinUom(Criteria criteria)
1032        throws TorqueException
1033    {
1034        setDbName(criteria);
1035
1036        ProductPeer.addSelectColumns(criteria);
1037        int offset = numColumns + 1;
1038        UomPeer.addSelectColumns(criteria);
1039
1040
1041                        criteria.addJoin(ProductPeer.UOM_ID,
1042            UomPeer.UOM_ID);
1043        
1044
1045                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
1046        List JavaDoc rows = BasePeer.doSelect(criteria);
1047        List JavaDoc results = new ArrayList JavaDoc();
1048
1049        for (int i = 0; i < rows.size(); i++)
1050        {
1051            Record row = (Record) rows.get(i);
1052
1053                            Class JavaDoc omClass = ProductPeer.getOMClass();
1054                    Product obj1 = (Product) ProductPeer
1055                .row2Object(row, 1, omClass);
1056                     omClass = UomPeer.getOMClass();
1057                    Uom obj2 = (Uom)UomPeer
1058                .row2Object(row, offset, omClass);
1059
1060            boolean newObject = true;
1061            for (int j = 0; j < results.size(); j++)
1062            {
1063                Product temp_obj1 = (Product)results.get(j);
1064                Uom temp_obj2 = (Uom)temp_obj1.getUom();
1065                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1066                {
1067                    newObject = false;
1068                              temp_obj2.addProduct(obj1);
1069                              break;
1070                }
1071            }
1072                      if (newObject)
1073            {
1074                obj2.initProducts();
1075                obj2.addProduct(obj1);
1076            }
1077                      results.add(obj1);
1078        }
1079        return results;
1080    }
1081                                                            
1082                
1083                
1084
1085    /**
1086     * selects a collection of Product objects pre-filled with their
1087     * Vendor objects.
1088     *
1089     * This method is protected by default in order to keep the public
1090     * api reasonable. You can provide public methods for those you
1091     * actually need in ProductPeer.
1092     *
1093     * @throws TorqueException Any exceptions caught during processing will be
1094     * rethrown wrapped into a TorqueException.
1095     */

1096    protected static List JavaDoc doSelectJoinVendor(Criteria criteria)
1097        throws TorqueException
1098    {
1099        setDbName(criteria);
1100
1101        ProductPeer.addSelectColumns(criteria);
1102        int offset = numColumns + 1;
1103        VendorPeer.addSelectColumns(criteria);
1104
1105
1106                        criteria.addJoin(ProductPeer.VENDOR_ID,
1107            VendorPeer.VENDOR_ID);
1108        
1109
1110                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
1111        List JavaDoc rows = BasePeer.doSelect(criteria);
1112        List JavaDoc results = new ArrayList JavaDoc();
1113
1114        for (int i = 0; i < rows.size(); i++)
1115        {
1116            Record row = (Record) rows.get(i);
1117
1118                            Class JavaDoc omClass = ProductPeer.getOMClass();
1119                    Product obj1 = (Product) ProductPeer
1120                .row2Object(row, 1, omClass);
1121                     omClass = VendorPeer.getOMClass();
1122                    Vendor obj2 = (Vendor)VendorPeer
1123                .row2Object(row, offset, omClass);
1124
1125            boolean newObject = true;
1126            for (int j = 0; j < results.size(); j++)
1127            {
1128                Product temp_obj1 = (Product)results.get(j);
1129                Vendor temp_obj2 = (Vendor)temp_obj1.getVendor();
1130                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1131                {
1132                    newObject = false;
1133                              temp_obj2.addProduct(obj1);
1134                              break;
1135                }
1136            }
1137                      if (newObject)
1138            {
1139                obj2.initProducts();
1140                obj2.addProduct(obj1);
1141            }
1142                      results.add(obj1);
1143        }
1144        return results;
1145    }
1146                    
1147  
1148                                    
1149          
1150        
1151                                  
1152                
1153
1154    /**
1155     * selects a collection of Product objects pre-filled with
1156     * all related objects.
1157     *
1158     * This method is protected by default in order to keep the public
1159     * api reasonable. You can provide public methods for those you
1160     * actually need in ProductPeer.
1161     *
1162     * @throws TorqueException Any exceptions caught during processing will be
1163     * rethrown wrapped into a TorqueException.
1164     */

1165    protected static List JavaDoc doSelectJoinAllExceptProductCategory(Criteria criteria)
1166        throws TorqueException
1167    {
1168        setDbName(criteria);
1169
1170        addSelectColumns(criteria);
1171        int offset2 = numColumns + 1;
1172                                    
1173                                                  
1174                    UomPeer.addSelectColumns(criteria);
1175        int offset3 = offset2 + UomPeer.numColumns;
1176                                                                
1177                    VendorPeer.addSelectColumns(criteria);
1178        int offset4 = offset3 + VendorPeer.numColumns;
1179                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
1180        List JavaDoc rows = BasePeer.doSelect(criteria);
1181        List JavaDoc results = new ArrayList JavaDoc();
1182
1183        for (int i = 0; i < rows.size(); i++)
1184        {
1185            Record row = (Record)rows.get(i);
1186
1187                            Class JavaDoc omClass = ProductPeer.getOMClass();
1188                    Product obj1 = (Product)ProductPeer
1189                .row2Object(row, 1, omClass);
1190                                                
1191                                                                  
1192                                                        
1193                            
1194              
1195                           omClass = UomPeer.getOMClass();
1196                          Uom obj2 = (Uom)UomPeer
1197                .row2Object( row, offset2, omClass);
1198
1199               boolean newObject = true;
1200            for (int j = 0; j < results.size(); j++)
1201            {
1202                Product temp_obj1 = (Product)results.get(j);
1203                Uom temp_obj2 = (Uom)temp_obj1.getUom();
1204                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1205                {
1206                    newObject = false;
1207                                    temp_obj2.addProduct(obj1);
1208                                    break;
1209                }
1210            }
1211                            if (newObject)
1212            {
1213                obj2.initProducts();
1214                obj2.addProduct(obj1);
1215            }
1216                                                                                    
1217                                                        
1218                            
1219              
1220                           omClass = VendorPeer.getOMClass();
1221                          Vendor obj3 = (Vendor)VendorPeer
1222                .row2Object( row, offset3, omClass);
1223
1224               newObject = true;
1225            for (int j = 0; j < results.size(); j++)
1226            {
1227                Product temp_obj1 = (Product)results.get(j);
1228                Vendor temp_obj3 = (Vendor)temp_obj1.getVendor();
1229                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1230                {
1231                    newObject = false;
1232                                    temp_obj3.addProduct(obj1);
1233                                    break;
1234                }
1235            }
1236                            if (newObject)
1237            {
1238                obj3.initProducts();
1239                obj3.addProduct(obj1);
1240            }
1241                                                                results.add(obj1);
1242        }
1243        return results;
1244    }
1245        
1246        
1247                                  
1248                
1249
1250    /**
1251     * selects a collection of Product objects pre-filled with
1252     * all related objects.
1253     *
1254     * This method is protected by default in order to keep the public
1255     * api reasonable. You can provide public methods for those you
1256     * actually need in ProductPeer.
1257     *
1258     * @throws TorqueException Any exceptions caught during processing will be
1259     * rethrown wrapped into a TorqueException.
1260     */

1261    protected static List JavaDoc doSelectJoinAllExceptUom(Criteria criteria)
1262        throws TorqueException
1263    {
1264        setDbName(criteria);
1265
1266        addSelectColumns(criteria);
1267        int offset2 = numColumns + 1;
1268                                    
1269                    ProductCategoryPeer.addSelectColumns(criteria);
1270        int offset3 = offset2 + ProductCategoryPeer.numColumns;
1271                                                                
1272                                                  
1273                    VendorPeer.addSelectColumns(criteria);
1274        int offset4 = offset3 + VendorPeer.numColumns;
1275                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
1276        List JavaDoc rows = BasePeer.doSelect(criteria);
1277        List JavaDoc results = new ArrayList JavaDoc();
1278
1279        for (int i = 0; i < rows.size(); i++)
1280        {
1281            Record row = (Record)rows.get(i);
1282
1283                            Class JavaDoc omClass = ProductPeer.getOMClass();
1284                    Product obj1 = (Product)ProductPeer
1285                .row2Object(row, 1, omClass);
1286                                                
1287                                                        
1288                            
1289              
1290                           omClass = ProductCategoryPeer.getOMClass();
1291                          ProductCategory obj2 = (ProductCategory)ProductCategoryPeer
1292                .row2Object( row, offset2, omClass);
1293
1294               boolean newObject = true;
1295            for (int j = 0; j < results.size(); j++)
1296            {
1297                Product temp_obj1 = (Product)results.get(j);
1298                ProductCategory temp_obj2 = (ProductCategory)temp_obj1.getProductCategory();
1299                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1300                {
1301                    newObject = false;
1302                                    temp_obj2.addProduct(obj1);
1303                                    break;
1304                }
1305            }
1306                            if (newObject)
1307            {
1308                obj2.initProducts();
1309                obj2.addProduct(obj1);
1310            }
1311                                                                                    
1312                                                                  
1313                                                        
1314                            
1315              
1316                           omClass = VendorPeer.getOMClass();
1317                          Vendor obj3 = (Vendor)VendorPeer
1318                .row2Object( row, offset3, omClass);
1319
1320               newObject = true;
1321            for (int j = 0; j < results.size(); j++)
1322            {
1323                Product temp_obj1 = (Product)results.get(j);
1324                Vendor temp_obj3 = (Vendor)temp_obj1.getVendor();
1325                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1326                {
1327                    newObject = false;
1328                                    temp_obj3.addProduct(obj1);
1329                                    break;
1330                }
1331            }
1332                            if (newObject)
1333            {
1334                obj3.initProducts();
1335                obj3.addProduct(obj1);
1336            }
1337                                                                results.add(obj1);
1338        }
1339        return results;
1340    }
1341        
1342        
1343                                  
1344                
1345
1346    /**
1347     * selects a collection of Product objects pre-filled with
1348     * all related objects.
1349     *
1350     * This method is protected by default in order to keep the public
1351     * api reasonable. You can provide public methods for those you
1352     * actually need in ProductPeer.
1353     *
1354     * @throws TorqueException Any exceptions caught during processing will be
1355     * rethrown wrapped into a TorqueException.
1356     */

1357    protected static List JavaDoc doSelectJoinAllExceptVendor(Criteria criteria)
1358        throws TorqueException
1359    {
1360        setDbName(criteria);
1361
1362        addSelectColumns(criteria);
1363        int offset2 = numColumns + 1;
1364                                    
1365                    ProductCategoryPeer.addSelectColumns(criteria);
1366        int offset3 = offset2 + ProductCategoryPeer.numColumns;
1367                                                                
1368                    UomPeer.addSelectColumns(criteria);
1369        int offset4 = offset3 + UomPeer.numColumns;
1370                                                                
1371                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
1372        List JavaDoc rows = BasePeer.doSelect(criteria);
1373        List JavaDoc results = new ArrayList JavaDoc();
1374
1375        for (int i = 0; i < rows.size(); i++)
1376        {
1377            Record row = (Record)rows.get(i);
1378
1379                            Class JavaDoc omClass = ProductPeer.getOMClass();
1380                    Product obj1 = (Product)ProductPeer
1381                .row2Object(row, 1, omClass);
1382                                                
1383                                                        
1384                            
1385              
1386                           omClass = ProductCategoryPeer.getOMClass();
1387                          ProductCategory obj2 = (ProductCategory)ProductCategoryPeer
1388                .row2Object( row, offset2, omClass);
1389
1390               boolean newObject = true;
1391            for (int j = 0; j < results.size(); j++)
1392            {
1393                Product temp_obj1 = (Product)results.get(j);
1394                ProductCategory temp_obj2 = (ProductCategory)temp_obj1.getProductCategory();
1395                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1396                {
1397                    newObject = false;
1398                                    temp_obj2.addProduct(obj1);
1399                                    break;
1400                }
1401            }
1402                            if (newObject)
1403            {
1404                obj2.initProducts();
1405                obj2.addProduct(obj1);
1406            }
1407                                                                                    
1408                                                        
1409                            
1410              
1411                           omClass = UomPeer.getOMClass();
1412                          Uom obj3 = (Uom)UomPeer
1413                .row2Object( row, offset3, omClass);
1414
1415               newObject = true;
1416            for (int j = 0; j < results.size(); j++)
1417            {
1418                Product temp_obj1 = (Product)results.get(j);
1419                Uom temp_obj3 = (Uom)temp_obj1.getUom();
1420                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1421                {
1422                    newObject = false;
1423                                    temp_obj3.addProduct(obj1);
1424                                    break;
1425                }
1426            }
1427                            if (newObject)
1428            {
1429                obj3.initProducts();
1430                obj3.addProduct(obj1);
1431            }
1432                                                                                    
1433                                              results.add(obj1);
1434        }
1435        return results;
1436    }
1437                    
1438  
1439      /**
1440     * Returns the TableMap related to this peer. This method is not
1441     * needed for general use but a specific application could have a need.
1442     *
1443     * @throws TorqueException Any exceptions caught during processing will be
1444     * rethrown wrapped into a TorqueException.
1445     */

1446    protected static TableMap getTableMap()
1447        throws TorqueException
1448    {
1449        return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME);
1450    }
1451   
1452    private static void setDbName(Criteria crit)
1453    {
1454        // Set the correct dbName if it has not been overridden
1455
// crit.getDbName will return the same object if not set to
1456
// another value so == check is okay and faster
1457
if (crit.getDbName() == Torque.getDefaultDB())
1458        {
1459            crit.setDbName(DATABASE_NAME);
1460        }
1461    }
1462}
1463
Popular Tags