KickJava   Java API By Example, From Geeks To Geeks.

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


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 /**
39  * This class was autogenerated by Torque on:
40  *
41  * [Wed May 04 09:10:56 CEST 2005]
42  *
43  */

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

59     public static MapBuilder getMapBuilder()
60         throws TorqueException
61     {
62         return getMapBuilder(ServiceMapBuilder.CLASS_NAME);
63     }
64
65       /** the column name for the SERVICE_ID field */
66     public static final String JavaDoc SERVICE_ID;
67       /** the column name for the SERVICE_CODE field */
68     public static final String JavaDoc SERVICE_CODE;
69       /** the column name for the STATUS field */
70     public static final String JavaDoc STATUS;
71       /** the column name for the PRIORITY field */
72     public static final String JavaDoc PRIORITY;
73       /** the column name for the ISSUED_DATE field */
74     public static final String JavaDoc ISSUED_DATE;
75       /** the column name for the CLOSED_DATE field */
76     public static final String JavaDoc CLOSED_DATE;
77       /** the column name for the CUSTOMER_ID field */
78     public static final String JavaDoc CUSTOMER_ID;
79       /** the column name for the RECIPIENT_ID field */
80     public static final String JavaDoc RECIPIENT_ID;
81       /** the column name for the PROJECT_ID field */
82     public static final String JavaDoc PROJECT_ID;
83       /** the column name for the SORDER_ID field */
84     public static final String JavaDoc SORDER_ID;
85       /** the column name for the INVOICE_CODE field */
86     public static final String JavaDoc INVOICE_CODE;
87       /** the column name for the SUBJECT field */
88     public static final String JavaDoc SUBJECT;
89       /** the column name for the NOTES field */
90     public static final String JavaDoc NOTES;
91       /** the column name for the CREATED field */
92     public static final String JavaDoc CREATED;
93       /** the column name for the MODIFIED field */
94     public static final String JavaDoc MODIFIED;
95       /** the column name for the CREATED_BY field */
96     public static final String JavaDoc CREATED_BY;
97       /** the column name for the MODIFIED_BY field */
98     public static final String JavaDoc MODIFIED_BY;
99   
100     static
101     {
102           SERVICE_ID = "SERVICE.SERVICE_ID";
103           SERVICE_CODE = "SERVICE.SERVICE_CODE";
104           STATUS = "SERVICE.STATUS";
105           PRIORITY = "SERVICE.PRIORITY";
106           ISSUED_DATE = "SERVICE.ISSUED_DATE";
107           CLOSED_DATE = "SERVICE.CLOSED_DATE";
108           CUSTOMER_ID = "SERVICE.CUSTOMER_ID";
109           RECIPIENT_ID = "SERVICE.RECIPIENT_ID";
110           PROJECT_ID = "SERVICE.PROJECT_ID";
111           SORDER_ID = "SERVICE.SORDER_ID";
112           INVOICE_CODE = "SERVICE.INVOICE_CODE";
113           SUBJECT = "SERVICE.SUBJECT";
114           NOTES = "SERVICE.NOTES";
115           CREATED = "SERVICE.CREATED";
116           MODIFIED = "SERVICE.MODIFIED";
117           CREATED_BY = "SERVICE.CREATED_BY";
118           MODIFIED_BY = "SERVICE.MODIFIED_BY";
119           if (Torque.isInit())
120         {
121             try
122             {
123                 getMapBuilder(ServiceMapBuilder.CLASS_NAME);
124             }
125             catch (Exception JavaDoc e)
126             {
127                 log.error("Could not initialize Peer", e);
128             }
129         }
130         else
131         {
132             Torque.registerMapBuilder(ServiceMapBuilder.CLASS_NAME);
133         }
134     }
135  
136     /** number of columns for this peer */
137     public static final int numColumns = 17;
138
139     /** A class that can be returned by this peer. */
140     protected static final String JavaDoc CLASSNAME_DEFAULT =
141         "org.campware.cream.om.Service";
142
143     /** A class that can be returned by this peer. */
144     protected static final Class JavaDoc CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT);
145
146     /**
147      * Class object initialization method.
148      *
149      * @param className name of the class to initialize
150      * @return the initialized class
151      */

152     private static Class JavaDoc initClass(String JavaDoc className)
153     {
154         Class JavaDoc c = null;
155         try
156         {
157             c = Class.forName(className);
158         }
159         catch (Throwable JavaDoc t)
160         {
161             log.error("A FATAL ERROR has occurred which should not "
162                 + "have happened under any circumstance. Please notify "
163                 + "the Torque developers <torque-dev@db.apache.org> "
164                 + "and give as many details as possible (including the error "
165                 + "stack trace).", t);
166
167             // Error objects should always be propogated.
168
if (t instanceof Error JavaDoc)
169             {
170                 throw (Error JavaDoc) t.fillInStackTrace();
171             }
172         }
173         return c;
174     }
175
176     /**
177      * Get the list of objects for a ResultSet. Please not that your
178      * resultset MUST return columns in the right order. You can use
179      * getFieldNames() in BaseObject to get the correct sequence.
180      *
181      * @param results the ResultSet
182      * @return the list of objects
183      * @throws TorqueException Any exceptions caught during processing will be
184      * rethrown wrapped into a TorqueException.
185      */

186     public static List JavaDoc resultSet2Objects(java.sql.ResultSet JavaDoc results)
187             throws TorqueException
188     {
189         try
190         {
191             QueryDataSet qds = null;
192             List JavaDoc rows = null;
193             try
194             {
195                 qds = new QueryDataSet(results);
196                 rows = getSelectResults(qds);
197             }
198             finally
199             {
200                 if (qds != null)
201                 {
202                     qds.close();
203                 }
204             }
205
206             return populateObjects(rows);
207         }
208         catch (SQLException JavaDoc e)
209         {
210             throw new TorqueException(e);
211         }
212         catch (DataSetException e)
213         {
214             throw new TorqueException(e);
215         }
216     }
217
218
219   
220     /**
221      * Method to do inserts.
222      *
223      * @param criteria object used to create the INSERT statement.
224      * @throws TorqueException Any exceptions caught during processing will be
225      * rethrown wrapped into a TorqueException.
226      */

227     public static ObjectKey doInsert(Criteria criteria)
228         throws TorqueException
229     {
230         return BaseServicePeer
231             .doInsert(criteria, (Connection JavaDoc) null);
232     }
233
234     /**
235      * Method to do inserts. This method is to be used during a transaction,
236      * otherwise use the doInsert(Criteria) method. It will take care of
237      * the connection details internally.
238      *
239      * @param criteria object used to create the INSERT statement.
240      * @param con the connection to use
241      * @throws TorqueException Any exceptions caught during processing will be
242      * rethrown wrapped into a TorqueException.
243      */

244     public static ObjectKey doInsert(Criteria criteria, Connection JavaDoc con)
245         throws TorqueException
246     {
247                                                                                                         
248         setDbName(criteria);
249
250         if (con == null)
251         {
252             return BasePeer.doInsert(criteria);
253         }
254         else
255         {
256             return BasePeer.doInsert(criteria, con);
257         }
258     }
259
260     /**
261      * Add all the columns needed to create a new object.
262      *
263      * @param criteria object containing the columns to add.
264      * @throws TorqueException Any exceptions caught during processing will be
265      * rethrown wrapped into a TorqueException.
266      */

267     public static void addSelectColumns(Criteria criteria)
268             throws TorqueException
269     {
270           criteria.addSelectColumn(SERVICE_ID);
271           criteria.addSelectColumn(SERVICE_CODE);
272           criteria.addSelectColumn(STATUS);
273           criteria.addSelectColumn(PRIORITY);
274           criteria.addSelectColumn(ISSUED_DATE);
275           criteria.addSelectColumn(CLOSED_DATE);
276           criteria.addSelectColumn(CUSTOMER_ID);
277           criteria.addSelectColumn(RECIPIENT_ID);
278           criteria.addSelectColumn(PROJECT_ID);
279           criteria.addSelectColumn(SORDER_ID);
280           criteria.addSelectColumn(INVOICE_CODE);
281           criteria.addSelectColumn(SUBJECT);
282           criteria.addSelectColumn(NOTES);
283           criteria.addSelectColumn(CREATED);
284           criteria.addSelectColumn(MODIFIED);
285           criteria.addSelectColumn(CREATED_BY);
286           criteria.addSelectColumn(MODIFIED_BY);
287       }
288
289     /**
290      * Create a new object of type cls from a resultset row starting
291      * from a specified offset. This is done so that you can select
292      * other rows than just those needed for this object. You may
293      * for example want to create two objects from the same row.
294      *
295      * @throws TorqueException Any exceptions caught during processing will be
296      * rethrown wrapped into a TorqueException.
297      */

298     public static Service row2Object(Record row,
299                                              int offset,
300                                              Class JavaDoc cls)
301         throws TorqueException
302     {
303         try
304         {
305             Service obj = (Service) cls.newInstance();
306             ServicePeer.populateObject(row, offset, obj);
307                   obj.setModified(false);
308               obj.setNew(false);
309
310             return obj;
311         }
312         catch (InstantiationException JavaDoc e)
313         {
314             throw new TorqueException(e);
315         }
316         catch (IllegalAccessException JavaDoc e)
317         {
318             throw new TorqueException(e);
319         }
320     }
321
322     /**
323      * Populates an object from a resultset row starting
324      * from a specified offset. This is done so that you can select
325      * other rows than just those needed for this object. You may
326      * for example want to create two objects from the same row.
327      *
328      * @throws TorqueException Any exceptions caught during processing will be
329      * rethrown wrapped into a TorqueException.
330      */

331     public static void populateObject(Record row,
332                                       int offset,
333                                       Service obj)
334         throws TorqueException
335     {
336         try
337         {
338                 obj.setServiceId(row.getValue(offset + 0).asInt());
339                   obj.setServiceCode(row.getValue(offset + 1).asString());
340                   obj.setStatus(row.getValue(offset + 2).asInt());
341                   obj.setPriority(row.getValue(offset + 3).asInt());
342                   obj.setIssuedDate(row.getValue(offset + 4).asUtilDate());
343                   obj.setClosedDate(row.getValue(offset + 5).asUtilDate());
344                   obj.setCustomerId(row.getValue(offset + 6).asInt());
345                   obj.setRecipientId(row.getValue(offset + 7).asInt());
346                   obj.setProjectId(row.getValue(offset + 8).asInt());
347                   obj.setSorderId(row.getValue(offset + 9).asInt());
348                   obj.setInvoiceCode(row.getValue(offset + 10).asString());
349                   obj.setSubject(row.getValue(offset + 11).asString());
350                   obj.setNotes(row.getValue(offset + 12).asString());
351                   obj.setCreated(row.getValue(offset + 13).asUtilDate());
352                   obj.setModified(row.getValue(offset + 14).asUtilDate());
353                   obj.setCreatedBy(row.getValue(offset + 15).asString());
354                   obj.setModifiedBy(row.getValue(offset + 16).asString());
355               }
356         catch (DataSetException e)
357         {
358             throw new TorqueException(e);
359         }
360     }
361
362     /**
363      * Method to do selects.
364      *
365      * @param criteria object used to create the SELECT statement.
366      * @return List of selected Objects
367      * @throws TorqueException Any exceptions caught during processing will be
368      * rethrown wrapped into a TorqueException.
369      */

370     public static List JavaDoc doSelect(Criteria criteria) throws TorqueException
371     {
372         return populateObjects(doSelectVillageRecords(criteria));
373     }
374
375     /**
376      * Method to do selects within a transaction.
377      *
378      * @param criteria object used to create the SELECT statement.
379      * @param con the connection to use
380      * @return List of selected Objects
381      * @throws TorqueException Any exceptions caught during processing will be
382      * rethrown wrapped into a TorqueException.
383      */

384     public static List JavaDoc doSelect(Criteria criteria, Connection JavaDoc con)
385         throws TorqueException
386     {
387         return populateObjects(doSelectVillageRecords(criteria, con));
388     }
389
390     /**
391      * Grabs the raw Village records to be formed into objects.
392      * This method handles connections internally. The Record objects
393      * returned by this method should be considered readonly. Do not
394      * alter the data and call save(), your results may vary, but are
395      * certainly likely to result in hard to track MT bugs.
396      *
397      * @throws TorqueException Any exceptions caught during processing will be
398      * rethrown wrapped into a TorqueException.
399      */

400     public static List JavaDoc doSelectVillageRecords(Criteria criteria)
401         throws TorqueException
402     {
403         return BaseServicePeer
404             .doSelectVillageRecords(criteria, (Connection JavaDoc) null);
405     }
406
407     /**
408      * Grabs the raw Village records to be formed into objects.
409      * This method should be used for transactions
410      *
411      * @param criteria object used to create the SELECT statement.
412      * @param con the connection to use
413      * @throws TorqueException Any exceptions caught during processing will be
414      * rethrown wrapped into a TorqueException.
415      */

416     public static List JavaDoc doSelectVillageRecords(Criteria criteria, Connection JavaDoc con)
417         throws TorqueException
418     {
419         if (criteria.getSelectColumns().size() == 0)
420         {
421             addSelectColumns(criteria);
422         }
423
424                                                                                                         
425         setDbName(criteria);
426
427         // BasePeer returns a List of Value (Village) arrays. The array
428
// order follows the order columns were placed in the Select clause.
429
if (con == null)
430         {
431             return BasePeer.doSelect(criteria);
432         }
433         else
434         {
435             return BasePeer.doSelect(criteria, con);
436         }
437     }
438
439     /**
440      * The returned List will contain objects of the default type or
441      * objects that inherit from the default.
442      *
443      * @throws TorqueException Any exceptions caught during processing will be
444      * rethrown wrapped into a TorqueException.
445      */

446     public static List JavaDoc populateObjects(List JavaDoc records)
447         throws TorqueException
448     {
449         List JavaDoc results = new ArrayList JavaDoc(records.size());
450
451         // populate the object(s)
452
for (int i = 0; i < records.size(); i++)
453         {
454             Record row = (Record) records.get(i);
455               results.add(ServicePeer.row2Object(row, 1,
456                 ServicePeer.getOMClass()));
457           }
458         return results;
459     }
460  
461
462     /**
463      * The class that the Peer will make instances of.
464      * If the BO is abstract then you must implement this method
465      * in the BO.
466      *
467      * @throws TorqueException Any exceptions caught during processing will be
468      * rethrown wrapped into a TorqueException.
469      */

470     public static Class JavaDoc getOMClass()
471         throws TorqueException
472     {
473         return CLASS_DEFAULT;
474     }
475
476     /**
477      * Method to do updates.
478      *
479      * @param criteria object containing data that is used to create the UPDATE
480      * statement.
481      * @throws TorqueException Any exceptions caught during processing will be
482      * rethrown wrapped into a TorqueException.
483      */

484     public static void doUpdate(Criteria criteria) throws TorqueException
485     {
486          BaseServicePeer
487             .doUpdate(criteria, (Connection JavaDoc) null);
488     }
489
490     /**
491      * Method to do updates. This method is to be used during a transaction,
492      * otherwise use the doUpdate(Criteria) method. It will take care of
493      * the connection details internally.
494      *
495      * @param criteria object containing data that is used to create the UPDATE
496      * statement.
497      * @param con the connection to use
498      * @throws TorqueException Any exceptions caught during processing will be
499      * rethrown wrapped into a TorqueException.
500      */

501     public static void doUpdate(Criteria criteria, Connection JavaDoc con)
502         throws TorqueException
503     {
504         Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
505                    selectCriteria.put(SERVICE_ID, criteria.remove(SERVICE_ID));
506                                                                                                                                                                       
507         setDbName(criteria);
508
509         if (con == null)
510         {
511             BasePeer.doUpdate(selectCriteria, criteria);
512         }
513         else
514         {
515             BasePeer.doUpdate(selectCriteria, criteria, con);
516         }
517     }
518
519     /**
520      * Method to do deletes.
521      *
522      * @param criteria object containing data that is used DELETE from database.
523      * @throws TorqueException Any exceptions caught during processing will be
524      * rethrown wrapped into a TorqueException.
525      */

526      public static void doDelete(Criteria criteria) throws TorqueException
527      {
528          ServicePeer
529             .doDelete(criteria, (Connection JavaDoc) null);
530      }
531
532     /**
533      * Method to do deletes. This method is to be used during a transaction,
534      * otherwise use the doDelete(Criteria) method. It will take care of
535      * the connection details internally.
536      *
537      * @param criteria object containing data that is used DELETE from database.
538      * @param con the connection to use
539      * @throws TorqueException Any exceptions caught during processing will be
540      * rethrown wrapped into a TorqueException.
541      */

542      public static void doDelete(Criteria criteria, Connection JavaDoc con)
543         throws TorqueException
544      {
545                                                                                                         
546         setDbName(criteria);
547
548         if (con == null)
549         {
550             BasePeer.doDelete(criteria);
551         }
552         else
553         {
554             BasePeer.doDelete(criteria, con);
555         }
556      }
557
558     /**
559      * Method to do selects
560      *
561      * @throws TorqueException Any exceptions caught during processing will be
562      * rethrown wrapped into a TorqueException.
563      */

564     public static List JavaDoc doSelect(Service obj) throws TorqueException
565     {
566         return doSelect(buildSelectCriteria(obj));
567     }
568
569     /**
570      * Method to do inserts
571      *
572      * @throws TorqueException Any exceptions caught during processing will be
573      * rethrown wrapped into a TorqueException.
574      */

575     public static void doInsert(Service obj) throws TorqueException
576     {
577           obj.setPrimaryKey(doInsert(buildCriteria(obj)));
578           obj.setNew(false);
579         obj.setModified(false);
580     }
581
582     /**
583      * @param obj the data object to update in the database.
584      * @throws TorqueException Any exceptions caught during processing will be
585      * rethrown wrapped into a TorqueException.
586      */

587     public static void doUpdate(Service obj) throws TorqueException
588     {
589         doUpdate(buildCriteria(obj));
590         obj.setModified(false);
591     }
592
593     /**
594      * @param obj the data object to delete in the database.
595      * @throws TorqueException Any exceptions caught during processing will be
596      * rethrown wrapped into a TorqueException.
597      */

598     public static void doDelete(Service obj) throws TorqueException
599     {
600         doDelete(buildSelectCriteria(obj));
601     }
602
603     /**
604      * Method to do inserts. This method is to be used during a transaction,
605      * otherwise use the doInsert(Service) method. It will take
606      * care of the connection details internally.
607      *
608      * @param obj the data object to insert into the database.
609      * @param con the connection to use
610      * @throws TorqueException Any exceptions caught during processing will be
611      * rethrown wrapped into a TorqueException.
612      */

613     public static void doInsert(Service obj, Connection JavaDoc con)
614         throws TorqueException
615     {
616           obj.setPrimaryKey(doInsert(buildCriteria(obj), con));
617           obj.setNew(false);
618         obj.setModified(false);
619     }
620
621     /**
622      * Method to do update. This method is to be used during a transaction,
623      * otherwise use the doUpdate(Service) method. It will take
624      * care of the connection details internally.
625      *
626      * @param obj the data object to update in the database.
627      * @param con the connection to use
628      * @throws TorqueException Any exceptions caught during processing will be
629      * rethrown wrapped into a TorqueException.
630      */

631     public static void doUpdate(Service obj, Connection JavaDoc con)
632         throws TorqueException
633     {
634         doUpdate(buildCriteria(obj), con);
635         obj.setModified(false);
636     }
637
638     /**
639      * Method to delete. This method is to be used during a transaction,
640      * otherwise use the doDelete(Service) method. It will take
641      * care of the connection details internally.
642      *
643      * @param obj the data object to delete in the database.
644      * @param con the connection to use
645      * @throws TorqueException Any exceptions caught during processing will be
646      * rethrown wrapped into a TorqueException.
647      */

648     public static void doDelete(Service obj, Connection JavaDoc con)
649         throws TorqueException
650     {
651         doDelete(buildSelectCriteria(obj), con);
652     }
653
654     /**
655      * Method to do deletes.
656      *
657      * @param pk ObjectKey that is used DELETE from database.
658      * @throws TorqueException Any exceptions caught during processing will be
659      * rethrown wrapped into a TorqueException.
660      */

661     public static void doDelete(ObjectKey pk) throws TorqueException
662     {
663         BaseServicePeer
664            .doDelete(pk, (Connection JavaDoc) null);
665     }
666
667     /**
668      * Method to delete. This method is to be used during a transaction,
669      * otherwise use the doDelete(ObjectKey) method. It will take
670      * care of the connection details internally.
671      *
672      * @param pk the primary key for the object to delete in the database.
673      * @param con the connection to use
674      * @throws TorqueException Any exceptions caught during processing will be
675      * rethrown wrapped into a TorqueException.
676      */

677     public static void doDelete(ObjectKey pk, Connection JavaDoc con)
678         throws TorqueException
679     {
680         doDelete(buildCriteria(pk), con);
681     }
682
683     /** Build a Criteria object from an ObjectKey */
684     public static Criteria buildCriteria( ObjectKey pk )
685     {
686         Criteria criteria = new Criteria();
687               criteria.add(SERVICE_ID, pk);
688           return criteria;
689      }
690
691     /** Build a Criteria object from the data object for this peer */
692     public static Criteria buildCriteria( Service obj )
693     {
694         Criteria criteria = new Criteria(DATABASE_NAME);
695               if (!obj.isNew())
696             criteria.add(SERVICE_ID, obj.getServiceId());
697               criteria.add(SERVICE_CODE, obj.getServiceCode());
698               criteria.add(STATUS, obj.getStatus());
699               criteria.add(PRIORITY, obj.getPriority());
700               criteria.add(ISSUED_DATE, obj.getIssuedDate());
701               criteria.add(CLOSED_DATE, obj.getClosedDate());
702               criteria.add(CUSTOMER_ID, obj.getCustomerId());
703               criteria.add(RECIPIENT_ID, obj.getRecipientId());
704               criteria.add(PROJECT_ID, obj.getProjectId());
705               criteria.add(SORDER_ID, obj.getSorderId());
706               criteria.add(INVOICE_CODE, obj.getInvoiceCode());
707               criteria.add(SUBJECT, obj.getSubject());
708               criteria.add(NOTES, obj.getNotes());
709               criteria.add(CREATED, obj.getCreated());
710               criteria.add(MODIFIED, obj.getModified());
711               criteria.add(CREATED_BY, obj.getCreatedBy());
712               criteria.add(MODIFIED_BY, obj.getModifiedBy());
713           return criteria;
714     }
715
716     /** Build a Criteria object from the data object for this peer, skipping all binary columns */
717     public static Criteria buildSelectCriteria( Service obj )
718     {
719         Criteria criteria = new Criteria(DATABASE_NAME);
720               if (!obj.isNew())
721                     criteria.add(SERVICE_ID, obj.getServiceId());
722                           criteria.add(SERVICE_CODE, obj.getServiceCode());
723                           criteria.add(STATUS, obj.getStatus());
724                           criteria.add(PRIORITY, obj.getPriority());
725                           criteria.add(ISSUED_DATE, obj.getIssuedDate());
726                           criteria.add(CLOSED_DATE, obj.getClosedDate());
727                           criteria.add(CUSTOMER_ID, obj.getCustomerId());
728                           criteria.add(RECIPIENT_ID, obj.getRecipientId());
729                           criteria.add(PROJECT_ID, obj.getProjectId());
730                           criteria.add(SORDER_ID, obj.getSorderId());
731                           criteria.add(INVOICE_CODE, obj.getInvoiceCode());
732                           criteria.add(SUBJECT, obj.getSubject());
733                           criteria.add(NOTES, obj.getNotes());
734                           criteria.add(CREATED, obj.getCreated());
735                           criteria.add(MODIFIED, obj.getModified());
736                           criteria.add(CREATED_BY, obj.getCreatedBy());
737                           criteria.add(MODIFIED_BY, obj.getModifiedBy());
738               return criteria;
739     }
740  
741     
742         /**
743      * Retrieve a single object by pk
744      *
745      * @param pk the primary key
746      * @throws TorqueException Any exceptions caught during processing will be
747      * rethrown wrapped into a TorqueException.
748      * @throws NoRowsException Primary key was not found in database.
749      * @throws TooManyRowsException Primary key was not found in database.
750      */

751     public static Service retrieveByPK(int pk)
752         throws TorqueException, NoRowsException, TooManyRowsException
753     {
754         return retrieveByPK(SimpleKey.keyFor(pk));
755     }
756
757     /**
758      * Retrieve a single object by pk
759      *
760      * @param pk the primary key
761      * @param con the connection to use
762      * @throws TorqueException Any exceptions caught during processing will be
763      * rethrown wrapped into a TorqueException.
764      * @throws NoRowsException Primary key was not found in database.
765      * @throws TooManyRowsException Primary key was not found in database.
766      */

767     public static Service retrieveByPK(int pk, Connection JavaDoc con)
768         throws TorqueException, NoRowsException, TooManyRowsException
769     {
770         return retrieveByPK(SimpleKey.keyFor(pk), con);
771     }
772   
773     /**
774      * Retrieve a single object by pk
775      *
776      * @param pk the primary key
777      * @throws TorqueException Any exceptions caught during processing will be
778      * rethrown wrapped into a TorqueException.
779      * @throws NoRowsException Primary key was not found in database.
780      * @throws TooManyRowsException Primary key was not found in database.
781      */

782     public static Service retrieveByPK(ObjectKey pk)
783         throws TorqueException, NoRowsException, TooManyRowsException
784     {
785         Connection JavaDoc db = null;
786         Service retVal = null;
787         try
788         {
789             db = Torque.getConnection(DATABASE_NAME);
790             retVal = retrieveByPK(pk, db);
791         }
792         finally
793         {
794             Torque.closeConnection(db);
795         }
796         return(retVal);
797     }
798
799     /**
800      * Retrieve a single object by pk
801      *
802      * @param pk the primary key
803      * @param con the connection to use
804      * @throws TorqueException Any exceptions caught during processing will be
805      * rethrown wrapped into a TorqueException.
806      * @throws NoRowsException Primary key was not found in database.
807      * @throws TooManyRowsException Primary key was not found in database.
808      */

809     public static Service retrieveByPK(ObjectKey pk, Connection JavaDoc con)
810         throws TorqueException, NoRowsException, TooManyRowsException
811     {
812         Criteria criteria = buildCriteria(pk);
813         List JavaDoc v = doSelect(criteria, con);
814         if (v.size() == 0)
815         {
816             throw new NoRowsException("Failed to select a row.");
817         }
818         else if (v.size() > 1)
819         {
820             throw new TooManyRowsException("Failed to select only one row.");
821         }
822         else
823         {
824             return (Service)v.get(0);
825         }
826     }
827
828     /**
829      * Retrieve a multiple objects by pk
830      *
831      * @param pks List of primary keys
832      * @throws TorqueException Any exceptions caught during processing will be
833      * rethrown wrapped into a TorqueException.
834      */

835     public static List JavaDoc retrieveByPKs(List JavaDoc pks)
836         throws TorqueException
837     {
838         Connection JavaDoc db = null;
839         List JavaDoc retVal = null;
840         try
841         {
842            db = Torque.getConnection(DATABASE_NAME);
843            retVal = retrieveByPKs(pks, db);
844         }
845         finally
846         {
847             Torque.closeConnection(db);
848         }
849         return(retVal);
850     }
851
852     /**
853      * Retrieve a multiple objects by pk
854      *
855      * @param pks List of primary keys
856      * @param dbcon the connection to use
857      * @throws TorqueException Any exceptions caught during processing will be
858      * rethrown wrapped into a TorqueException.
859      */

860     public static List JavaDoc retrieveByPKs( List JavaDoc pks, Connection JavaDoc dbcon )
861         throws TorqueException
862     {
863         List JavaDoc objs = null;
864         if (pks == null || pks.size() == 0)
865         {
866             objs = new LinkedList JavaDoc();
867         }
868         else
869         {
870             Criteria criteria = new Criteria();
871               criteria.addIn( SERVICE_ID, pks );
872           objs = doSelect(criteria, dbcon);
873         }
874         return objs;
875     }
876
877  
878
879
880
881                 
882                                                         
883                 
884                 
885
886     /**
887      * selects a collection of Service objects pre-filled with their
888      * Customer objects.
889      *
890      * This method is protected by default in order to keep the public
891      * api reasonable. You can provide public methods for those you
892      * actually need in ServicePeer.
893      *
894      * @throws TorqueException Any exceptions caught during processing will be
895      * rethrown wrapped into a TorqueException.
896      */

897     protected static List JavaDoc doSelectJoinCustomerRelatedByCustomerId(Criteria criteria)
898         throws TorqueException
899     {
900         setDbName(criteria);
901
902         ServicePeer.addSelectColumns(criteria);
903         int offset = numColumns + 1;
904         CustomerPeer.addSelectColumns(criteria);
905
906
907                         criteria.addJoin(ServicePeer.CUSTOMER_ID,
908             CustomerPeer.CUSTOMER_ID);
909         
910
911                                                                                                                                                                                                                                                                                                                           
912         List JavaDoc rows = BasePeer.doSelect(criteria);
913         List JavaDoc results = new ArrayList JavaDoc();
914
915         for (int i = 0; i < rows.size(); i++)
916         {
917             Record row = (Record) rows.get(i);
918
919                             Class JavaDoc omClass = ServicePeer.getOMClass();
920                     Service obj1 = (Service) ServicePeer
921                 .row2Object(row, 1, omClass);
922                      omClass = CustomerPeer.getOMClass();
923                     Customer obj2 = (Customer)CustomerPeer
924                 .row2Object(row, offset, omClass);
925
926             boolean newObject = true;
927             for (int j = 0; j < results.size(); j++)
928             {
929                 Service temp_obj1 = (Service)results.get(j);
930                 Customer temp_obj2 = (Customer)temp_obj1.getCustomerRelatedByCustomerId();
931                 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
932                 {
933                     newObject = false;
934                               temp_obj2.addServiceRelatedByCustomerId(obj1);
935                               break;
936                 }
937             }
938                       if (newObject)
939             {
940                 obj2.initServicesRelatedByCustomerId();
941                 obj2.addServiceRelatedByCustomerId(obj1);
942             }
943                       results.add(obj1);
944         }
945         return results;
946     }
947                                                                       
948                 
949                 
950
951     /**
952      * selects a collection of Service objects pre-filled with their
953      * Customer objects.
954      *
955      * This method is protected by default in order to keep the public
956      * api reasonable. You can provide public methods for those you
957      * actually need in ServicePeer.
958      *
959      * @throws TorqueException Any exceptions caught during processing will be
960      * rethrown wrapped into a TorqueException.
961      */

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

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

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

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

1259    protected static List JavaDoc doSelectJoinAllExceptCustomerRelatedByRecipientId(Criteria criteria)
1260        throws TorqueException
1261    {
1262        setDbName(criteria);
1263
1264        addSelectColumns(criteria);
1265        int offset2 = numColumns + 1;
1266                                    
1267                                                  
1268                                                  
1269                    ProjectPeer.addSelectColumns(criteria);
1270        int offset3 = offset2 + ProjectPeer.numColumns;
1271                                                                
1272                    SorderPeer.addSelectColumns(criteria);
1273        int offset4 = offset3 + SorderPeer.numColumns;
1274                                                                                                                                                                                                                                                                                                                                                                      
1275        List JavaDoc rows = BasePeer.doSelect(criteria);
1276        List JavaDoc results = new ArrayList JavaDoc();
1277
1278        for (int i = 0; i < rows.size(); i++)
1279        {
1280            Record row = (Record)rows.get(i);
1281
1282                            Class JavaDoc omClass = ServicePeer.getOMClass();
1283                    Service obj1 = (Service)ServicePeer
1284                .row2Object(row, 1, omClass);
1285                                                
1286                                                                  
1287                                                                  
1288                                                        
1289                            
1290              
1291                           omClass = ProjectPeer.getOMClass();
1292                          Project obj2 = (Project)ProjectPeer
1293                .row2Object( row, offset2, omClass);
1294
1295               boolean newObject = true;
1296            for (int j = 0; j < results.size(); j++)
1297            {
1298                Service temp_obj1 = (Service)results.get(j);
1299                Project temp_obj2 = (Project)temp_obj1.getProject();
1300                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1301                {
1302                    newObject = false;
1303                                    temp_obj2.addService(obj1);
1304                                    break;
1305                }
1306            }
1307                            if (newObject)
1308            {
1309                obj2.initServices();
1310                obj2.addService(obj1);
1311            }
1312                                                                                    
1313                                                        
1314                            
1315              
1316                           omClass = SorderPeer.getOMClass();
1317                          Sorder obj3 = (Sorder)SorderPeer
1318                .row2Object( row, offset3, omClass);
1319
1320               newObject = true;
1321            for (int j = 0; j < results.size(); j++)
1322            {
1323                Service temp_obj1 = (Service)results.get(j);
1324                Sorder temp_obj3 = (Sorder)temp_obj1.getSorder();
1325                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1326                {
1327                    newObject = false;
1328                                    temp_obj3.addService(obj1);
1329                                    break;
1330                }
1331            }
1332                            if (newObject)
1333            {
1334                obj3.initServices();
1335                obj3.addService(obj1);
1336            }
1337                                                                results.add(obj1);
1338        }
1339        return results;
1340    }
1341        
1342        
1343                                  
1344                
1345
1346    /**
1347     * selects a collection of Service 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 ServicePeer.
1353     *
1354     * @throws TorqueException Any exceptions caught during processing will be
1355     * rethrown wrapped into a TorqueException.
1356     */

1357    protected static List JavaDoc doSelectJoinAllExceptProject(Criteria criteria)
1358        throws TorqueException
1359    {
1360        setDbName(criteria);
1361
1362        addSelectColumns(criteria);
1363        int offset2 = numColumns + 1;
1364                                    
1365                    CustomerPeer.addSelectColumns(criteria);
1366        int offset3 = offset2 + CustomerPeer.numColumns;
1367                                                                
1368                    CustomerPeer.addSelectColumns(criteria);
1369        int offset4 = offset3 + CustomerPeer.numColumns;
1370                                                                
1371                                                  
1372                    SorderPeer.addSelectColumns(criteria);
1373        int offset5 = offset4 + SorderPeer.numColumns;
1374                                                                                                                                                                                                                                                                                                                                                                      
1375        List JavaDoc rows = BasePeer.doSelect(criteria);
1376        List JavaDoc results = new ArrayList JavaDoc();
1377
1378        for (int i = 0; i < rows.size(); i++)
1379        {
1380            Record row = (Record)rows.get(i);
1381
1382                            Class JavaDoc omClass = ServicePeer.getOMClass();
1383                    Service obj1 = (Service)ServicePeer
1384                .row2Object(row, 1, omClass);
1385                                                
1386                                                                        
1387                            
1388              
1389                           omClass = CustomerPeer.getOMClass();
1390                          Customer obj2 = (Customer)CustomerPeer
1391                .row2Object( row, offset2, omClass);
1392
1393               boolean newObject = true;
1394            for (int j = 0; j < results.size(); j++)
1395            {
1396                Service temp_obj1 = (Service)results.get(j);
1397                Customer temp_obj2 = (Customer)temp_obj1.getCustomerRelatedByCustomerId();
1398                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1399                {
1400                    newObject = false;
1401                                    temp_obj2.addServiceRelatedByCustomerId(obj1);
1402                                    break;
1403                }
1404            }
1405                            if (newObject)
1406            {
1407                obj2.initServicesRelatedByCustomerId();
1408                obj2.addServiceRelatedByCustomerId(obj1);
1409            }
1410                                                                                    
1411                                                                        
1412                            
1413              
1414                           omClass = CustomerPeer.getOMClass();
1415                          Customer obj3 = (Customer)CustomerPeer
1416                .row2Object( row, offset3, omClass);
1417
1418               newObject = true;
1419            for (int j = 0; j < results.size(); j++)
1420            {
1421                Service temp_obj1 = (Service)results.get(j);
1422                Customer temp_obj3 = (Customer)temp_obj1.getCustomerRelatedByRecipientId();
1423                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1424                {
1425                    newObject = false;
1426                                    temp_obj3.addServiceRelatedByRecipientId(obj1);
1427                                    break;
1428                }
1429            }
1430                            if (newObject)
1431            {
1432                obj3.initServicesRelatedByRecipientId();
1433                obj3.addServiceRelatedByRecipientId(obj1);
1434            }
1435                                                                                    
1436                                                                  
1437                                                        
1438                            
1439              
1440                           omClass = SorderPeer.getOMClass();
1441                          Sorder obj4 = (Sorder)SorderPeer
1442                .row2Object( row, offset4, omClass);
1443
1444               newObject = true;
1445            for (int j = 0; j < results.size(); j++)
1446            {
1447                Service temp_obj1 = (Service)results.get(j);
1448                Sorder temp_obj4 = (Sorder)temp_obj1.getSorder();
1449                if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey()))
1450                {
1451                    newObject = false;
1452                                    temp_obj4.addService(obj1);
1453                                    break;
1454                }
1455            }
1456                            if (newObject)
1457            {
1458                obj4.initServices();
1459                obj4.addService(obj1);
1460            }
1461                                                                results.add(obj1);
1462        }
1463        return results;
1464    }
1465        
1466        
1467                                  
1468                
1469
1470    /**
1471     * selects a collection of Service objects pre-filled with
1472     * all related objects.
1473     *
1474     * This method is protected by default in order to keep the public
1475     * api reasonable. You can provide public methods for those you
1476     * actually need in ServicePeer.
1477     *
1478     * @throws TorqueException Any exceptions caught during processing will be
1479     * rethrown wrapped into a TorqueException.
1480     */

1481    protected static List JavaDoc doSelectJoinAllExceptSorder(Criteria criteria)
1482        throws TorqueException
1483    {
1484        setDbName(criteria);
1485
1486        addSelectColumns(criteria);
1487        int offset2 = numColumns + 1;
1488                                    
1489                    CustomerPeer.addSelectColumns(criteria);
1490        int offset3 = offset2 + CustomerPeer.numColumns;
1491                                                                
1492                    CustomerPeer.addSelectColumns(criteria);
1493        int offset4 = offset3 + CustomerPeer.numColumns;
1494                                                                
1495                    ProjectPeer.addSelectColumns(criteria);
1496        int offset5 = offset4 + ProjectPeer.numColumns;
1497                                                                
1498                                                                                                                                                                                                                                                                                                                                                        
1499        List JavaDoc rows = BasePeer.doSelect(criteria);
1500        List JavaDoc results = new ArrayList JavaDoc();
1501
1502        for (int i = 0; i < rows.size(); i++)
1503        {
1504            Record row = (Record)rows.get(i);
1505
1506                            Class JavaDoc omClass = ServicePeer.getOMClass();
1507                    Service obj1 = (Service)ServicePeer
1508                .row2Object(row, 1, omClass);
1509                                                
1510                                                                        
1511                            
1512              
1513                           omClass = CustomerPeer.getOMClass();
1514                          Customer obj2 = (Customer)CustomerPeer
1515                .row2Object( row, offset2, omClass);
1516
1517               boolean newObject = true;
1518            for (int j = 0; j < results.size(); j++)
1519            {
1520                Service temp_obj1 = (Service)results.get(j);
1521                Customer temp_obj2 = (Customer)temp_obj1.getCustomerRelatedByCustomerId();
1522                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1523                {
1524                    newObject = false;
1525                                    temp_obj2.addServiceRelatedByCustomerId(obj1);
1526                                    break;
1527                }
1528            }
1529                            if (newObject)
1530            {
1531                obj2.initServicesRelatedByCustomerId();
1532                obj2.addServiceRelatedByCustomerId(obj1);
1533            }
1534                                                                                    
1535                                                                        
1536                            
1537              
1538                           omClass = CustomerPeer.getOMClass();
1539                          Customer obj3 = (Customer)CustomerPeer
1540                .row2Object( row, offset3, omClass);
1541
1542               newObject = true;
1543            for (int j = 0; j < results.size(); j++)
1544            {
1545                Service temp_obj1 = (Service)results.get(j);
1546                Customer temp_obj3 = (Customer)temp_obj1.getCustomerRelatedByRecipientId();
1547                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1548                {
1549                    newObject = false;
1550                                    temp_obj3.addServiceRelatedByRecipientId(obj1);
1551                                    break;
1552                }
1553            }
1554                            if (newObject)
1555            {
1556                obj3.initServicesRelatedByRecipientId();
1557                obj3.addServiceRelatedByRecipientId(obj1);
1558            }
1559                                                                                    
1560                                                        
1561                            
1562              
1563                           omClass = ProjectPeer.getOMClass();
1564                          Project obj4 = (Project)ProjectPeer
1565                .row2Object( row, offset4, omClass);
1566
1567               newObject = true;
1568            for (int j = 0; j < results.size(); j++)
1569            {
1570                Service temp_obj1 = (Service)results.get(j);
1571                Project temp_obj4 = (Project)temp_obj1.getProject();
1572                if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey()))
1573                {
1574                    newObject = false;
1575                                    temp_obj4.addService(obj1);
1576                                    break;
1577                }
1578            }
1579                            if (newObject)
1580            {
1581                obj4.initServices();
1582                obj4.addService(obj1);
1583            }
1584                                                                                    
1585                                              results.add(obj1);
1586        }
1587        return results;
1588    }
1589                    
1590  
1591      /**
1592     * Returns the TableMap related to this peer. This method is not
1593     * needed for general use but a specific application could have a need.
1594     *
1595     * @throws TorqueException Any exceptions caught during processing will be
1596     * rethrown wrapped into a TorqueException.
1597     */

1598    protected static TableMap getTableMap()
1599        throws TorqueException
1600    {
1601        return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME);
1602    }
1603   
1604    private static void setDbName(Criteria crit)
1605    {
1606        // Set the correct dbName if it has not been overridden
1607
// crit.getDbName will return the same object if not set to
1608
// another value so == check is okay and faster
1609
if (crit.getDbName() == Torque.getDefaultDB())
1610        {
1611            crit.setDbName(DATABASE_NAME);
1612        }
1613    }
1614}
1615
Popular Tags