KickJava   Java API By Example, From Geeks To Geeks.

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


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 BasePaymentPeer
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 = "PAYMENT";
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(PaymentMapBuilder.CLASS_NAME);
63     }
64
65       /** the column name for the PAYMENT_ID field */
66     public static final String JavaDoc PAYMENT_ID;
67       /** the column name for the PAYMENT_CODE field */
68     public static final String JavaDoc PAYMENT_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 PROJECT_ID field */
80     public static final String JavaDoc PROJECT_ID;
81       /** the column name for the SORDER_ID field */
82     public static final String JavaDoc SORDER_ID;
83       /** the column name for the INVOICE_CODE field */
84     public static final String JavaDoc INVOICE_CODE;
85       /** the column name for the PAY_TERM field */
86     public static final String JavaDoc PAY_TERM;
87       /** the column name for the PAY_METHOD field */
88     public static final String JavaDoc PAY_METHOD;
89       /** the column name for the CURRENCY_ID field */
90     public static final String JavaDoc CURRENCY_ID;
91       /** the column name for the CURRENCY_RATE field */
92     public static final String JavaDoc CURRENCY_RATE;
93       /** the column name for the CURRENCY_AMOUNT field */
94     public static final String JavaDoc CURRENCY_AMOUNT;
95       /** the column name for the TOTAL_AMOUNT field */
96     public static final String JavaDoc TOTAL_AMOUNT;
97       /** the column name for the SUBJECT field */
98     public static final String JavaDoc SUBJECT;
99       /** the column name for the NOTES field */
100     public static final String JavaDoc NOTES;
101       /** the column name for the CREATED field */
102     public static final String JavaDoc CREATED;
103       /** the column name for the MODIFIED field */
104     public static final String JavaDoc MODIFIED;
105       /** the column name for the CREATED_BY field */
106     public static final String JavaDoc CREATED_BY;
107       /** the column name for the MODIFIED_BY field */
108     public static final String JavaDoc MODIFIED_BY;
109   
110     static
111     {
112           PAYMENT_ID = "PAYMENT.PAYMENT_ID";
113           PAYMENT_CODE = "PAYMENT.PAYMENT_CODE";
114           STATUS = "PAYMENT.STATUS";
115           PRIORITY = "PAYMENT.PRIORITY";
116           ISSUED_DATE = "PAYMENT.ISSUED_DATE";
117           CLOSED_DATE = "PAYMENT.CLOSED_DATE";
118           CUSTOMER_ID = "PAYMENT.CUSTOMER_ID";
119           PROJECT_ID = "PAYMENT.PROJECT_ID";
120           SORDER_ID = "PAYMENT.SORDER_ID";
121           INVOICE_CODE = "PAYMENT.INVOICE_CODE";
122           PAY_TERM = "PAYMENT.PAY_TERM";
123           PAY_METHOD = "PAYMENT.PAY_METHOD";
124           CURRENCY_ID = "PAYMENT.CURRENCY_ID";
125           CURRENCY_RATE = "PAYMENT.CURRENCY_RATE";
126           CURRENCY_AMOUNT = "PAYMENT.CURRENCY_AMOUNT";
127           TOTAL_AMOUNT = "PAYMENT.TOTAL_AMOUNT";
128           SUBJECT = "PAYMENT.SUBJECT";
129           NOTES = "PAYMENT.NOTES";
130           CREATED = "PAYMENT.CREATED";
131           MODIFIED = "PAYMENT.MODIFIED";
132           CREATED_BY = "PAYMENT.CREATED_BY";
133           MODIFIED_BY = "PAYMENT.MODIFIED_BY";
134           if (Torque.isInit())
135         {
136             try
137             {
138                 getMapBuilder(PaymentMapBuilder.CLASS_NAME);
139             }
140             catch (Exception JavaDoc e)
141             {
142                 log.error("Could not initialize Peer", e);
143             }
144         }
145         else
146         {
147             Torque.registerMapBuilder(PaymentMapBuilder.CLASS_NAME);
148         }
149     }
150  
151     /** number of columns for this peer */
152     public static final int numColumns = 22;
153
154     /** A class that can be returned by this peer. */
155     protected static final String JavaDoc CLASSNAME_DEFAULT =
156         "org.campware.cream.om.Payment";
157
158     /** A class that can be returned by this peer. */
159     protected static final Class JavaDoc CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT);
160
161     /**
162      * Class object initialization method.
163      *
164      * @param className name of the class to initialize
165      * @return the initialized class
166      */

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

201     public static List JavaDoc resultSet2Objects(java.sql.ResultSet JavaDoc results)
202             throws TorqueException
203     {
204         try
205         {
206             QueryDataSet qds = null;
207             List JavaDoc rows = null;
208             try
209             {
210                 qds = new QueryDataSet(results);
211                 rows = getSelectResults(qds);
212             }
213             finally
214             {
215                 if (qds != null)
216                 {
217                     qds.close();
218                 }
219             }
220
221             return populateObjects(rows);
222         }
223         catch (SQLException JavaDoc e)
224         {
225             throw new TorqueException(e);
226         }
227         catch (DataSetException e)
228         {
229             throw new TorqueException(e);
230         }
231     }
232
233
234   
235     /**
236      * Method to do inserts.
237      *
238      * @param criteria object used to create the INSERT statement.
239      * @throws TorqueException Any exceptions caught during processing will be
240      * rethrown wrapped into a TorqueException.
241      */

242     public static ObjectKey doInsert(Criteria criteria)
243         throws TorqueException
244     {
245         return BasePaymentPeer
246             .doInsert(criteria, (Connection JavaDoc) null);
247     }
248
249     /**
250      * Method to do inserts. This method is to be used during a transaction,
251      * otherwise use the doInsert(Criteria) method. It will take care of
252      * the connection details internally.
253      *
254      * @param criteria object used to create the INSERT statement.
255      * @param con the connection to use
256      * @throws TorqueException Any exceptions caught during processing will be
257      * rethrown wrapped into a TorqueException.
258      */

259     public static ObjectKey doInsert(Criteria criteria, Connection JavaDoc con)
260         throws TorqueException
261     {
262                                                                                                                                       
263         setDbName(criteria);
264
265         if (con == null)
266         {
267             return BasePeer.doInsert(criteria);
268         }
269         else
270         {
271             return BasePeer.doInsert(criteria, con);
272         }
273     }
274
275     /**
276      * Add all the columns needed to create a new object.
277      *
278      * @param criteria object containing the columns to add.
279      * @throws TorqueException Any exceptions caught during processing will be
280      * rethrown wrapped into a TorqueException.
281      */

282     public static void addSelectColumns(Criteria criteria)
283             throws TorqueException
284     {
285           criteria.addSelectColumn(PAYMENT_ID);
286           criteria.addSelectColumn(PAYMENT_CODE);
287           criteria.addSelectColumn(STATUS);
288           criteria.addSelectColumn(PRIORITY);
289           criteria.addSelectColumn(ISSUED_DATE);
290           criteria.addSelectColumn(CLOSED_DATE);
291           criteria.addSelectColumn(CUSTOMER_ID);
292           criteria.addSelectColumn(PROJECT_ID);
293           criteria.addSelectColumn(SORDER_ID);
294           criteria.addSelectColumn(INVOICE_CODE);
295           criteria.addSelectColumn(PAY_TERM);
296           criteria.addSelectColumn(PAY_METHOD);
297           criteria.addSelectColumn(CURRENCY_ID);
298           criteria.addSelectColumn(CURRENCY_RATE);
299           criteria.addSelectColumn(CURRENCY_AMOUNT);
300           criteria.addSelectColumn(TOTAL_AMOUNT);
301           criteria.addSelectColumn(SUBJECT);
302           criteria.addSelectColumn(NOTES);
303           criteria.addSelectColumn(CREATED);
304           criteria.addSelectColumn(MODIFIED);
305           criteria.addSelectColumn(CREATED_BY);
306           criteria.addSelectColumn(MODIFIED_BY);
307       }
308
309     /**
310      * Create a new object of type cls from a resultset row starting
311      * from a specified offset. This is done so that you can select
312      * other rows than just those needed for this object. You may
313      * for example want to create two objects from the same row.
314      *
315      * @throws TorqueException Any exceptions caught during processing will be
316      * rethrown wrapped into a TorqueException.
317      */

318     public static Payment row2Object(Record row,
319                                              int offset,
320                                              Class JavaDoc cls)
321         throws TorqueException
322     {
323         try
324         {
325             Payment obj = (Payment) cls.newInstance();
326             PaymentPeer.populateObject(row, offset, obj);
327                   obj.setModified(false);
328               obj.setNew(false);
329
330             return obj;
331         }
332         catch (InstantiationException JavaDoc e)
333         {
334             throw new TorqueException(e);
335         }
336         catch (IllegalAccessException JavaDoc e)
337         {
338             throw new TorqueException(e);
339         }
340     }
341
342     /**
343      * Populates an object from a resultset row starting
344      * from a specified offset. This is done so that you can select
345      * other rows than just those needed for this object. You may
346      * for example want to create two objects from the same row.
347      *
348      * @throws TorqueException Any exceptions caught during processing will be
349      * rethrown wrapped into a TorqueException.
350      */

351     public static void populateObject(Record row,
352                                       int offset,
353                                       Payment obj)
354         throws TorqueException
355     {
356         try
357         {
358                 obj.setPaymentId(row.getValue(offset + 0).asInt());
359                   obj.setPaymentCode(row.getValue(offset + 1).asString());
360                   obj.setStatus(row.getValue(offset + 2).asInt());
361                   obj.setPriority(row.getValue(offset + 3).asInt());
362                   obj.setIssuedDate(row.getValue(offset + 4).asUtilDate());
363                   obj.setClosedDate(row.getValue(offset + 5).asUtilDate());
364                   obj.setCustomerId(row.getValue(offset + 6).asInt());
365                   obj.setProjectId(row.getValue(offset + 7).asInt());
366                   obj.setSorderId(row.getValue(offset + 8).asInt());
367                   obj.setInvoiceCode(row.getValue(offset + 9).asString());
368                   obj.setPayTerm(row.getValue(offset + 10).asInt());
369                   obj.setPayMethod(row.getValue(offset + 11).asInt());
370                   obj.setCurrencyId(row.getValue(offset + 12).asInt());
371                   obj.setCurrencyRate(row.getValue(offset + 13).asBigDecimal());
372                   obj.setCurrencyAmount(row.getValue(offset + 14).asBigDecimal());
373                   obj.setTotalAmount(row.getValue(offset + 15).asBigDecimal());
374                   obj.setSubject(row.getValue(offset + 16).asString());
375                   obj.setNotes(row.getValue(offset + 17).asString());
376                   obj.setCreated(row.getValue(offset + 18).asUtilDate());
377                   obj.setModified(row.getValue(offset + 19).asUtilDate());
378                   obj.setCreatedBy(row.getValue(offset + 20).asString());
379                   obj.setModifiedBy(row.getValue(offset + 21).asString());
380               }
381         catch (DataSetException e)
382         {
383             throw new TorqueException(e);
384         }
385     }
386
387     /**
388      * Method to do selects.
389      *
390      * @param criteria object used to create the SELECT statement.
391      * @return List of selected Objects
392      * @throws TorqueException Any exceptions caught during processing will be
393      * rethrown wrapped into a TorqueException.
394      */

395     public static List JavaDoc doSelect(Criteria criteria) throws TorqueException
396     {
397         return populateObjects(doSelectVillageRecords(criteria));
398     }
399
400     /**
401      * Method to do selects within a transaction.
402      *
403      * @param criteria object used to create the SELECT statement.
404      * @param con the connection to use
405      * @return List of selected Objects
406      * @throws TorqueException Any exceptions caught during processing will be
407      * rethrown wrapped into a TorqueException.
408      */

409     public static List JavaDoc doSelect(Criteria criteria, Connection JavaDoc con)
410         throws TorqueException
411     {
412         return populateObjects(doSelectVillageRecords(criteria, con));
413     }
414
415     /**
416      * Grabs the raw Village records to be formed into objects.
417      * This method handles connections internally. The Record objects
418      * returned by this method should be considered readonly. Do not
419      * alter the data and call save(), your results may vary, but are
420      * certainly likely to result in hard to track MT bugs.
421      *
422      * @throws TorqueException Any exceptions caught during processing will be
423      * rethrown wrapped into a TorqueException.
424      */

425     public static List JavaDoc doSelectVillageRecords(Criteria criteria)
426         throws TorqueException
427     {
428         return BasePaymentPeer
429             .doSelectVillageRecords(criteria, (Connection JavaDoc) null);
430     }
431
432     /**
433      * Grabs the raw Village records to be formed into objects.
434      * This method should be used for transactions
435      *
436      * @param criteria object used to create the SELECT statement.
437      * @param con the connection to use
438      * @throws TorqueException Any exceptions caught during processing will be
439      * rethrown wrapped into a TorqueException.
440      */

441     public static List JavaDoc doSelectVillageRecords(Criteria criteria, Connection JavaDoc con)
442         throws TorqueException
443     {
444         if (criteria.getSelectColumns().size() == 0)
445         {
446             addSelectColumns(criteria);
447         }
448
449                                                                                                                                       
450         setDbName(criteria);
451
452         // BasePeer returns a List of Value (Village) arrays. The array
453
// order follows the order columns were placed in the Select clause.
454
if (con == null)
455         {
456             return BasePeer.doSelect(criteria);
457         }
458         else
459         {
460             return BasePeer.doSelect(criteria, con);
461         }
462     }
463
464     /**
465      * The returned List will contain objects of the default type or
466      * objects that inherit from the default.
467      *
468      * @throws TorqueException Any exceptions caught during processing will be
469      * rethrown wrapped into a TorqueException.
470      */

471     public static List JavaDoc populateObjects(List JavaDoc records)
472         throws TorqueException
473     {
474         List JavaDoc results = new ArrayList JavaDoc(records.size());
475
476         // populate the object(s)
477
for (int i = 0; i < records.size(); i++)
478         {
479             Record row = (Record) records.get(i);
480               results.add(PaymentPeer.row2Object(row, 1,
481                 PaymentPeer.getOMClass()));
482           }
483         return results;
484     }
485  
486
487     /**
488      * The class that the Peer will make instances of.
489      * If the BO is abstract then you must implement this method
490      * in the BO.
491      *
492      * @throws TorqueException Any exceptions caught during processing will be
493      * rethrown wrapped into a TorqueException.
494      */

495     public static Class JavaDoc getOMClass()
496         throws TorqueException
497     {
498         return CLASS_DEFAULT;
499     }
500
501     /**
502      * Method to do updates.
503      *
504      * @param criteria object containing data that is used to create the UPDATE
505      * statement.
506      * @throws TorqueException Any exceptions caught during processing will be
507      * rethrown wrapped into a TorqueException.
508      */

509     public static void doUpdate(Criteria criteria) throws TorqueException
510     {
511          BasePaymentPeer
512             .doUpdate(criteria, (Connection JavaDoc) null);
513     }
514
515     /**
516      * Method to do updates. This method is to be used during a transaction,
517      * otherwise use the doUpdate(Criteria) method. It will take care of
518      * the connection details internally.
519      *
520      * @param criteria object containing data that is used to create the UPDATE
521      * statement.
522      * @param con the connection to use
523      * @throws TorqueException Any exceptions caught during processing will be
524      * rethrown wrapped into a TorqueException.
525      */

526     public static void doUpdate(Criteria criteria, Connection JavaDoc con)
527         throws TorqueException
528     {
529         Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
530                    selectCriteria.put(PAYMENT_ID, criteria.remove(PAYMENT_ID));
531                                                                                                                                                                                                                         
532         setDbName(criteria);
533
534         if (con == null)
535         {
536             BasePeer.doUpdate(selectCriteria, criteria);
537         }
538         else
539         {
540             BasePeer.doUpdate(selectCriteria, criteria, con);
541         }
542     }
543
544     /**
545      * Method to do deletes.
546      *
547      * @param criteria object containing data that is used DELETE from database.
548      * @throws TorqueException Any exceptions caught during processing will be
549      * rethrown wrapped into a TorqueException.
550      */

551      public static void doDelete(Criteria criteria) throws TorqueException
552      {
553          PaymentPeer
554             .doDelete(criteria, (Connection JavaDoc) null);
555      }
556
557     /**
558      * Method to do deletes. This method is to be used during a transaction,
559      * otherwise use the doDelete(Criteria) method. It will take care of
560      * the connection details internally.
561      *
562      * @param criteria object containing data that is used DELETE from database.
563      * @param con the connection to use
564      * @throws TorqueException Any exceptions caught during processing will be
565      * rethrown wrapped into a TorqueException.
566      */

567      public static void doDelete(Criteria criteria, Connection JavaDoc con)
568         throws TorqueException
569      {
570                                                                                                                                       
571         setDbName(criteria);
572
573         if (con == null)
574         {
575             BasePeer.doDelete(criteria);
576         }
577         else
578         {
579             BasePeer.doDelete(criteria, con);
580         }
581      }
582
583     /**
584      * Method to do selects
585      *
586      * @throws TorqueException Any exceptions caught during processing will be
587      * rethrown wrapped into a TorqueException.
588      */

589     public static List JavaDoc doSelect(Payment obj) throws TorqueException
590     {
591         return doSelect(buildSelectCriteria(obj));
592     }
593
594     /**
595      * Method to do inserts
596      *
597      * @throws TorqueException Any exceptions caught during processing will be
598      * rethrown wrapped into a TorqueException.
599      */

600     public static void doInsert(Payment obj) throws TorqueException
601     {
602           obj.setPrimaryKey(doInsert(buildCriteria(obj)));
603           obj.setNew(false);
604         obj.setModified(false);
605     }
606
607     /**
608      * @param obj the data object to update in the database.
609      * @throws TorqueException Any exceptions caught during processing will be
610      * rethrown wrapped into a TorqueException.
611      */

612     public static void doUpdate(Payment obj) throws TorqueException
613     {
614         doUpdate(buildCriteria(obj));
615         obj.setModified(false);
616     }
617
618     /**
619      * @param obj the data object to delete in the database.
620      * @throws TorqueException Any exceptions caught during processing will be
621      * rethrown wrapped into a TorqueException.
622      */

623     public static void doDelete(Payment obj) throws TorqueException
624     {
625         doDelete(buildSelectCriteria(obj));
626     }
627
628     /**
629      * Method to do inserts. This method is to be used during a transaction,
630      * otherwise use the doInsert(Payment) method. It will take
631      * care of the connection details internally.
632      *
633      * @param obj the data object to insert into the database.
634      * @param con the connection to use
635      * @throws TorqueException Any exceptions caught during processing will be
636      * rethrown wrapped into a TorqueException.
637      */

638     public static void doInsert(Payment obj, Connection JavaDoc con)
639         throws TorqueException
640     {
641           obj.setPrimaryKey(doInsert(buildCriteria(obj), con));
642           obj.setNew(false);
643         obj.setModified(false);
644     }
645
646     /**
647      * Method to do update. This method is to be used during a transaction,
648      * otherwise use the doUpdate(Payment) method. It will take
649      * care of the connection details internally.
650      *
651      * @param obj the data object to update in the database.
652      * @param con the connection to use
653      * @throws TorqueException Any exceptions caught during processing will be
654      * rethrown wrapped into a TorqueException.
655      */

656     public static void doUpdate(Payment obj, Connection JavaDoc con)
657         throws TorqueException
658     {
659         doUpdate(buildCriteria(obj), con);
660         obj.setModified(false);
661     }
662
663     /**
664      * Method to delete. This method is to be used during a transaction,
665      * otherwise use the doDelete(Payment) method. It will take
666      * care of the connection details internally.
667      *
668      * @param obj the data object to delete in the database.
669      * @param con the connection to use
670      * @throws TorqueException Any exceptions caught during processing will be
671      * rethrown wrapped into a TorqueException.
672      */

673     public static void doDelete(Payment obj, Connection JavaDoc con)
674         throws TorqueException
675     {
676         doDelete(buildSelectCriteria(obj), con);
677     }
678
679     /**
680      * Method to do deletes.
681      *
682      * @param pk ObjectKey that is used DELETE from database.
683      * @throws TorqueException Any exceptions caught during processing will be
684      * rethrown wrapped into a TorqueException.
685      */

686     public static void doDelete(ObjectKey pk) throws TorqueException
687     {
688         BasePaymentPeer
689            .doDelete(pk, (Connection JavaDoc) null);
690     }
691
692     /**
693      * Method to delete. This method is to be used during a transaction,
694      * otherwise use the doDelete(ObjectKey) method. It will take
695      * care of the connection details internally.
696      *
697      * @param pk the primary key for the object to delete in the database.
698      * @param con the connection to use
699      * @throws TorqueException Any exceptions caught during processing will be
700      * rethrown wrapped into a TorqueException.
701      */

702     public static void doDelete(ObjectKey pk, Connection JavaDoc con)
703         throws TorqueException
704     {
705         doDelete(buildCriteria(pk), con);
706     }
707
708     /** Build a Criteria object from an ObjectKey */
709     public static Criteria buildCriteria( ObjectKey pk )
710     {
711         Criteria criteria = new Criteria();
712               criteria.add(PAYMENT_ID, pk);
713           return criteria;
714      }
715
716     /** Build a Criteria object from the data object for this peer */
717     public static Criteria buildCriteria( Payment obj )
718     {
719         Criteria criteria = new Criteria(DATABASE_NAME);
720               if (!obj.isNew())
721             criteria.add(PAYMENT_ID, obj.getPaymentId());
722               criteria.add(PAYMENT_CODE, obj.getPaymentCode());
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(PROJECT_ID, obj.getProjectId());
729               criteria.add(SORDER_ID, obj.getSorderId());
730               criteria.add(INVOICE_CODE, obj.getInvoiceCode());
731               criteria.add(PAY_TERM, obj.getPayTerm());
732               criteria.add(PAY_METHOD, obj.getPayMethod());
733               criteria.add(CURRENCY_ID, obj.getCurrencyId());
734               criteria.add(CURRENCY_RATE, obj.getCurrencyRate());
735               criteria.add(CURRENCY_AMOUNT, obj.getCurrencyAmount());
736               criteria.add(TOTAL_AMOUNT, obj.getTotalAmount());
737               criteria.add(SUBJECT, obj.getSubject());
738               criteria.add(NOTES, obj.getNotes());
739               criteria.add(CREATED, obj.getCreated());
740               criteria.add(MODIFIED, obj.getModified());
741               criteria.add(CREATED_BY, obj.getCreatedBy());
742               criteria.add(MODIFIED_BY, obj.getModifiedBy());
743           return criteria;
744     }
745
746     /** Build a Criteria object from the data object for this peer, skipping all binary columns */
747     public static Criteria buildSelectCriteria( Payment obj )
748     {
749         Criteria criteria = new Criteria(DATABASE_NAME);
750               if (!obj.isNew())
751                     criteria.add(PAYMENT_ID, obj.getPaymentId());
752                           criteria.add(PAYMENT_CODE, obj.getPaymentCode());
753                           criteria.add(STATUS, obj.getStatus());
754                           criteria.add(PRIORITY, obj.getPriority());
755                           criteria.add(ISSUED_DATE, obj.getIssuedDate());
756                           criteria.add(CLOSED_DATE, obj.getClosedDate());
757                           criteria.add(CUSTOMER_ID, obj.getCustomerId());
758                           criteria.add(PROJECT_ID, obj.getProjectId());
759                           criteria.add(SORDER_ID, obj.getSorderId());
760                           criteria.add(INVOICE_CODE, obj.getInvoiceCode());
761                           criteria.add(PAY_TERM, obj.getPayTerm());
762                           criteria.add(PAY_METHOD, obj.getPayMethod());
763                           criteria.add(CURRENCY_ID, obj.getCurrencyId());
764                           criteria.add(CURRENCY_RATE, obj.getCurrencyRate());
765                           criteria.add(CURRENCY_AMOUNT, obj.getCurrencyAmount());
766                           criteria.add(TOTAL_AMOUNT, obj.getTotalAmount());
767                           criteria.add(SUBJECT, obj.getSubject());
768                           criteria.add(NOTES, obj.getNotes());
769                           criteria.add(CREATED, obj.getCreated());
770                           criteria.add(MODIFIED, obj.getModified());
771                           criteria.add(CREATED_BY, obj.getCreatedBy());
772                           criteria.add(MODIFIED_BY, obj.getModifiedBy());
773               return criteria;
774     }
775  
776     
777         /**
778      * Retrieve a single object by pk
779      *
780      * @param pk the primary key
781      * @throws TorqueException Any exceptions caught during processing will be
782      * rethrown wrapped into a TorqueException.
783      * @throws NoRowsException Primary key was not found in database.
784      * @throws TooManyRowsException Primary key was not found in database.
785      */

786     public static Payment retrieveByPK(int pk)
787         throws TorqueException, NoRowsException, TooManyRowsException
788     {
789         return retrieveByPK(SimpleKey.keyFor(pk));
790     }
791
792     /**
793      * Retrieve a single object by pk
794      *
795      * @param pk the primary key
796      * @param con the connection to use
797      * @throws TorqueException Any exceptions caught during processing will be
798      * rethrown wrapped into a TorqueException.
799      * @throws NoRowsException Primary key was not found in database.
800      * @throws TooManyRowsException Primary key was not found in database.
801      */

802     public static Payment retrieveByPK(int pk, Connection JavaDoc con)
803         throws TorqueException, NoRowsException, TooManyRowsException
804     {
805         return retrieveByPK(SimpleKey.keyFor(pk), con);
806     }
807   
808     /**
809      * Retrieve a single object by pk
810      *
811      * @param pk the primary key
812      * @throws TorqueException Any exceptions caught during processing will be
813      * rethrown wrapped into a TorqueException.
814      * @throws NoRowsException Primary key was not found in database.
815      * @throws TooManyRowsException Primary key was not found in database.
816      */

817     public static Payment retrieveByPK(ObjectKey pk)
818         throws TorqueException, NoRowsException, TooManyRowsException
819     {
820         Connection JavaDoc db = null;
821         Payment retVal = null;
822         try
823         {
824             db = Torque.getConnection(DATABASE_NAME);
825             retVal = retrieveByPK(pk, db);
826         }
827         finally
828         {
829             Torque.closeConnection(db);
830         }
831         return(retVal);
832     }
833
834     /**
835      * Retrieve a single object by pk
836      *
837      * @param pk the primary key
838      * @param con the connection to use
839      * @throws TorqueException Any exceptions caught during processing will be
840      * rethrown wrapped into a TorqueException.
841      * @throws NoRowsException Primary key was not found in database.
842      * @throws TooManyRowsException Primary key was not found in database.
843      */

844     public static Payment retrieveByPK(ObjectKey pk, Connection JavaDoc con)
845         throws TorqueException, NoRowsException, TooManyRowsException
846     {
847         Criteria criteria = buildCriteria(pk);
848         List JavaDoc v = doSelect(criteria, con);
849         if (v.size() == 0)
850         {
851             throw new NoRowsException("Failed to select a row.");
852         }
853         else if (v.size() > 1)
854         {
855             throw new TooManyRowsException("Failed to select only one row.");
856         }
857         else
858         {
859             return (Payment)v.get(0);
860         }
861     }
862
863     /**
864      * Retrieve a multiple objects by pk
865      *
866      * @param pks List of primary keys
867      * @throws TorqueException Any exceptions caught during processing will be
868      * rethrown wrapped into a TorqueException.
869      */

870     public static List JavaDoc retrieveByPKs(List JavaDoc pks)
871         throws TorqueException
872     {
873         Connection JavaDoc db = null;
874         List JavaDoc retVal = null;
875         try
876         {
877            db = Torque.getConnection(DATABASE_NAME);
878            retVal = retrieveByPKs(pks, db);
879         }
880         finally
881         {
882             Torque.closeConnection(db);
883         }
884         return(retVal);
885     }
886
887     /**
888      * Retrieve a multiple objects by pk
889      *
890      * @param pks List of primary keys
891      * @param dbcon the connection to use
892      * @throws TorqueException Any exceptions caught during processing will be
893      * rethrown wrapped into a TorqueException.
894      */

895     public static List JavaDoc retrieveByPKs( List JavaDoc pks, Connection JavaDoc dbcon )
896         throws TorqueException
897     {
898         List JavaDoc objs = null;
899         if (pks == null || pks.size() == 0)
900         {
901             objs = new LinkedList JavaDoc();
902         }
903         else
904         {
905             Criteria criteria = new Criteria();
906               criteria.addIn( PAYMENT_ID, pks );
907           objs = doSelect(criteria, dbcon);
908         }
909         return objs;
910     }
911
912  
913
914
915
916                 
917                                               
918                 
919                 
920
921     /**
922      * selects a collection of Payment objects pre-filled with their
923      * Customer objects.
924      *
925      * This method is protected by default in order to keep the public
926      * api reasonable. You can provide public methods for those you
927      * actually need in PaymentPeer.
928      *
929      * @throws TorqueException Any exceptions caught during processing will be
930      * rethrown wrapped into a TorqueException.
931      */

932     protected static List JavaDoc doSelectJoinCustomer(Criteria criteria)
933         throws TorqueException
934     {
935         setDbName(criteria);
936
937         PaymentPeer.addSelectColumns(criteria);
938         int offset = numColumns + 1;
939         CustomerPeer.addSelectColumns(criteria);
940
941
942                         criteria.addJoin(PaymentPeer.CUSTOMER_ID,
943             CustomerPeer.CUSTOMER_ID);
944         
945
946                                                                                                                                                                                                                                                                                                                                                                                                                     
947         List JavaDoc rows = BasePeer.doSelect(criteria);
948         List JavaDoc results = new ArrayList JavaDoc();
949
950         for (int i = 0; i < rows.size(); i++)
951         {
952             Record row = (Record) rows.get(i);
953
954                             Class JavaDoc omClass = PaymentPeer.getOMClass();
955                     Payment obj1 = (Payment) PaymentPeer
956                 .row2Object(row, 1, omClass);
957                      omClass = CustomerPeer.getOMClass();
958                     Customer obj2 = (Customer)CustomerPeer
959                 .row2Object(row, offset, omClass);
960
961             boolean newObject = true;
962             for (int j = 0; j < results.size(); j++)
963             {
964                 Payment temp_obj1 = (Payment)results.get(j);
965                 Customer temp_obj2 = (Customer)temp_obj1.getCustomer();
966                 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
967                 {
968                     newObject = false;
969                               temp_obj2.addPayment(obj1);
970                               break;
971                 }
972             }
973                       if (newObject)
974             {
975                 obj2.initPayments();
976                 obj2.addPayment(obj1);
977             }
978                       results.add(obj1);
979         }
980         return results;
981     }
982                                                             
983                 
984                 
985
986     /**
987      * selects a collection of Payment objects pre-filled with their
988      * Project objects.
989      *
990      * This method is protected by default in order to keep the public
991      * api reasonable. You can provide public methods for those you
992      * actually need in PaymentPeer.
993      *
994      * @throws TorqueException Any exceptions caught during processing will be
995      * rethrown wrapped into a TorqueException.
996      */

997     protected static List JavaDoc doSelectJoinProject(Criteria criteria)
998         throws TorqueException
999     {
1000        setDbName(criteria);
1001
1002        PaymentPeer.addSelectColumns(criteria);
1003        int offset = numColumns + 1;
1004        ProjectPeer.addSelectColumns(criteria);
1005
1006
1007                        criteria.addJoin(PaymentPeer.PROJECT_ID,
1008            ProjectPeer.PROJECT_ID);
1009        
1010
1011                                                                                                                                                                                                                                                                                                                                                                                                                    
1012        List JavaDoc rows = BasePeer.doSelect(criteria);
1013        List JavaDoc results = new ArrayList JavaDoc();
1014
1015        for (int i = 0; i < rows.size(); i++)
1016        {
1017            Record row = (Record) rows.get(i);
1018
1019                            Class JavaDoc omClass = PaymentPeer.getOMClass();
1020                    Payment obj1 = (Payment) PaymentPeer
1021                .row2Object(row, 1, omClass);
1022                     omClass = ProjectPeer.getOMClass();
1023                    Project obj2 = (Project)ProjectPeer
1024                .row2Object(row, offset, omClass);
1025
1026            boolean newObject = true;
1027            for (int j = 0; j < results.size(); j++)
1028            {
1029                Payment temp_obj1 = (Payment)results.get(j);
1030                Project temp_obj2 = (Project)temp_obj1.getProject();
1031                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1032                {
1033                    newObject = false;
1034                              temp_obj2.addPayment(obj1);
1035                              break;
1036                }
1037            }
1038                      if (newObject)
1039            {
1040                obj2.initPayments();
1041                obj2.addPayment(obj1);
1042            }
1043                      results.add(obj1);
1044        }
1045        return results;
1046    }
1047                                                            
1048                
1049                
1050
1051    /**
1052     * selects a collection of Payment objects pre-filled with their
1053     * Sorder objects.
1054     *
1055     * This method is protected by default in order to keep the public
1056     * api reasonable. You can provide public methods for those you
1057     * actually need in PaymentPeer.
1058     *
1059     * @throws TorqueException Any exceptions caught during processing will be
1060     * rethrown wrapped into a TorqueException.
1061     */

1062    protected static List JavaDoc doSelectJoinSorder(Criteria criteria)
1063        throws TorqueException
1064    {
1065        setDbName(criteria);
1066
1067        PaymentPeer.addSelectColumns(criteria);
1068        int offset = numColumns + 1;
1069        SorderPeer.addSelectColumns(criteria);
1070
1071
1072                        criteria.addJoin(PaymentPeer.SORDER_ID,
1073            SorderPeer.SORDER_ID);
1074        
1075
1076                                                                                                                                                                                                                                                                                                                                                                                                                    
1077        List JavaDoc rows = BasePeer.doSelect(criteria);
1078        List JavaDoc results = new ArrayList JavaDoc();
1079
1080        for (int i = 0; i < rows.size(); i++)
1081        {
1082            Record row = (Record) rows.get(i);
1083
1084                            Class JavaDoc omClass = PaymentPeer.getOMClass();
1085                    Payment obj1 = (Payment) PaymentPeer
1086                .row2Object(row, 1, omClass);
1087                     omClass = SorderPeer.getOMClass();
1088                    Sorder obj2 = (Sorder)SorderPeer
1089                .row2Object(row, offset, omClass);
1090
1091            boolean newObject = true;
1092            for (int j = 0; j < results.size(); j++)
1093            {
1094                Payment temp_obj1 = (Payment)results.get(j);
1095                Sorder temp_obj2 = (Sorder)temp_obj1.getSorder();
1096                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1097                {
1098                    newObject = false;
1099                              temp_obj2.addPayment(obj1);
1100                              break;
1101                }
1102            }
1103                      if (newObject)
1104            {
1105                obj2.initPayments();
1106                obj2.addPayment(obj1);
1107            }
1108                      results.add(obj1);
1109        }
1110        return results;
1111    }
1112                                                            
1113                
1114                
1115
1116    /**
1117     * selects a collection of Payment objects pre-filled with their
1118     * Currency objects.
1119     *
1120     * This method is protected by default in order to keep the public
1121     * api reasonable. You can provide public methods for those you
1122     * actually need in PaymentPeer.
1123     *
1124     * @throws TorqueException Any exceptions caught during processing will be
1125     * rethrown wrapped into a TorqueException.
1126     */

1127    protected static List JavaDoc doSelectJoinCurrency(Criteria criteria)
1128        throws TorqueException
1129    {
1130        setDbName(criteria);
1131
1132        PaymentPeer.addSelectColumns(criteria);
1133        int offset = numColumns + 1;
1134        CurrencyPeer.addSelectColumns(criteria);
1135
1136
1137                        criteria.addJoin(PaymentPeer.CURRENCY_ID,
1138            CurrencyPeer.CURRENCY_ID);
1139        
1140
1141                                                                                                                                                                                                                                                                                                                                                                                                                    
1142        List JavaDoc rows = BasePeer.doSelect(criteria);
1143        List JavaDoc results = new ArrayList JavaDoc();
1144
1145        for (int i = 0; i < rows.size(); i++)
1146        {
1147            Record row = (Record) rows.get(i);
1148
1149                            Class JavaDoc omClass = PaymentPeer.getOMClass();
1150                    Payment obj1 = (Payment) PaymentPeer
1151                .row2Object(row, 1, omClass);
1152                     omClass = CurrencyPeer.getOMClass();
1153                    Currency obj2 = (Currency)CurrencyPeer
1154                .row2Object(row, offset, omClass);
1155
1156            boolean newObject = true;
1157            for (int j = 0; j < results.size(); j++)
1158            {
1159                Payment temp_obj1 = (Payment)results.get(j);
1160                Currency temp_obj2 = (Currency)temp_obj1.getCurrency();
1161                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1162                {
1163                    newObject = false;
1164                              temp_obj2.addPayment(obj1);
1165                              break;
1166                }
1167            }
1168                      if (newObject)
1169            {
1170                obj2.initPayments();
1171                obj2.addPayment(obj1);
1172            }
1173                      results.add(obj1);
1174        }
1175        return results;
1176    }
1177                    
1178  
1179                                              
1180          
1181        
1182                                  
1183                
1184
1185    /**
1186     * selects a collection of Payment objects pre-filled with
1187     * all related objects.
1188     *
1189     * This method is protected by default in order to keep the public
1190     * api reasonable. You can provide public methods for those you
1191     * actually need in PaymentPeer.
1192     *
1193     * @throws TorqueException Any exceptions caught during processing will be
1194     * rethrown wrapped into a TorqueException.
1195     */

1196    protected static List JavaDoc doSelectJoinAllExceptCustomer(Criteria criteria)
1197        throws TorqueException
1198    {
1199        setDbName(criteria);
1200
1201        addSelectColumns(criteria);
1202        int offset2 = numColumns + 1;
1203                                    
1204                                                  
1205                    ProjectPeer.addSelectColumns(criteria);
1206        int offset3 = offset2 + ProjectPeer.numColumns;
1207                                                                
1208                    SorderPeer.addSelectColumns(criteria);
1209        int offset4 = offset3 + SorderPeer.numColumns;
1210                                                                
1211                    CurrencyPeer.addSelectColumns(criteria);
1212        int offset5 = offset4 + CurrencyPeer.numColumns;
1213                                                                                                                                                                                                                                                                                                                                                                                                                                                                
1214        List JavaDoc rows = BasePeer.doSelect(criteria);
1215        List JavaDoc results = new ArrayList JavaDoc();
1216
1217        for (int i = 0; i < rows.size(); i++)
1218        {
1219            Record row = (Record)rows.get(i);
1220
1221                            Class JavaDoc omClass = PaymentPeer.getOMClass();
1222                    Payment obj1 = (Payment)PaymentPeer
1223                .row2Object(row, 1, omClass);
1224                                                
1225                                                                  
1226                                                        
1227                            
1228              
1229                           omClass = ProjectPeer.getOMClass();
1230                          Project obj2 = (Project)ProjectPeer
1231                .row2Object( row, offset2, omClass);
1232
1233               boolean newObject = true;
1234            for (int j = 0; j < results.size(); j++)
1235            {
1236                Payment temp_obj1 = (Payment)results.get(j);
1237                Project temp_obj2 = (Project)temp_obj1.getProject();
1238                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1239                {
1240                    newObject = false;
1241                                    temp_obj2.addPayment(obj1);
1242                                    break;
1243                }
1244            }
1245                            if (newObject)
1246            {
1247                obj2.initPayments();
1248                obj2.addPayment(obj1);
1249            }
1250                                                                                    
1251                                                        
1252                            
1253              
1254                           omClass = SorderPeer.getOMClass();
1255                          Sorder obj3 = (Sorder)SorderPeer
1256                .row2Object( row, offset3, omClass);
1257
1258               newObject = true;
1259            for (int j = 0; j < results.size(); j++)
1260            {
1261                Payment temp_obj1 = (Payment)results.get(j);
1262                Sorder temp_obj3 = (Sorder)temp_obj1.getSorder();
1263                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1264                {
1265                    newObject = false;
1266                                    temp_obj3.addPayment(obj1);
1267                                    break;
1268                }
1269            }
1270                            if (newObject)
1271            {
1272                obj3.initPayments();
1273                obj3.addPayment(obj1);
1274            }
1275                                                                                    
1276                                                        
1277                            
1278              
1279                           omClass = CurrencyPeer.getOMClass();
1280                          Currency obj4 = (Currency)CurrencyPeer
1281                .row2Object( row, offset4, omClass);
1282
1283               newObject = true;
1284            for (int j = 0; j < results.size(); j++)
1285            {
1286                Payment temp_obj1 = (Payment)results.get(j);
1287                Currency temp_obj4 = (Currency)temp_obj1.getCurrency();
1288                if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey()))
1289                {
1290                    newObject = false;
1291                                    temp_obj4.addPayment(obj1);
1292                                    break;
1293                }
1294            }
1295                            if (newObject)
1296            {
1297                obj4.initPayments();
1298                obj4.addPayment(obj1);
1299            }
1300                                                                results.add(obj1);
1301        }
1302        return results;
1303    }
1304        
1305        
1306                                  
1307                
1308
1309    /**
1310     * selects a collection of Payment objects pre-filled with
1311     * all related objects.
1312     *
1313     * This method is protected by default in order to keep the public
1314     * api reasonable. You can provide public methods for those you
1315     * actually need in PaymentPeer.
1316     *
1317     * @throws TorqueException Any exceptions caught during processing will be
1318     * rethrown wrapped into a TorqueException.
1319     */

1320    protected static List JavaDoc doSelectJoinAllExceptProject(Criteria criteria)
1321        throws TorqueException
1322    {
1323        setDbName(criteria);
1324
1325        addSelectColumns(criteria);
1326        int offset2 = numColumns + 1;
1327                                    
1328                    CustomerPeer.addSelectColumns(criteria);
1329        int offset3 = offset2 + CustomerPeer.numColumns;
1330                                                                
1331                                                  
1332                    SorderPeer.addSelectColumns(criteria);
1333        int offset4 = offset3 + SorderPeer.numColumns;
1334                                                                
1335                    CurrencyPeer.addSelectColumns(criteria);
1336        int offset5 = offset4 + CurrencyPeer.numColumns;
1337                                                                                                                                                                                                                                                                                                                                                                                                                                                                
1338        List JavaDoc rows = BasePeer.doSelect(criteria);
1339        List JavaDoc results = new ArrayList JavaDoc();
1340
1341        for (int i = 0; i < rows.size(); i++)
1342        {
1343            Record row = (Record)rows.get(i);
1344
1345                            Class JavaDoc omClass = PaymentPeer.getOMClass();
1346                    Payment obj1 = (Payment)PaymentPeer
1347                .row2Object(row, 1, omClass);
1348                                                
1349                                                        
1350                            
1351              
1352                           omClass = CustomerPeer.getOMClass();
1353                          Customer obj2 = (Customer)CustomerPeer
1354                .row2Object( row, offset2, omClass);
1355
1356               boolean newObject = true;
1357            for (int j = 0; j < results.size(); j++)
1358            {
1359                Payment temp_obj1 = (Payment)results.get(j);
1360                Customer temp_obj2 = (Customer)temp_obj1.getCustomer();
1361                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1362                {
1363                    newObject = false;
1364                                    temp_obj2.addPayment(obj1);
1365                                    break;
1366                }
1367            }
1368                            if (newObject)
1369            {
1370                obj2.initPayments();
1371                obj2.addPayment(obj1);
1372            }
1373                                                                                    
1374                                                                  
1375                                                        
1376                            
1377              
1378                           omClass = SorderPeer.getOMClass();
1379                          Sorder obj3 = (Sorder)SorderPeer
1380                .row2Object( row, offset3, omClass);
1381
1382               newObject = true;
1383            for (int j = 0; j < results.size(); j++)
1384            {
1385                Payment temp_obj1 = (Payment)results.get(j);
1386                Sorder temp_obj3 = (Sorder)temp_obj1.getSorder();
1387                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1388                {
1389                    newObject = false;
1390                                    temp_obj3.addPayment(obj1);
1391                                    break;
1392                }
1393            }
1394                            if (newObject)
1395            {
1396                obj3.initPayments();
1397                obj3.addPayment(obj1);
1398            }
1399                                                                                    
1400                                                        
1401                            
1402              
1403                           omClass = CurrencyPeer.getOMClass();
1404                          Currency obj4 = (Currency)CurrencyPeer
1405                .row2Object( row, offset4, omClass);
1406
1407               newObject = true;
1408            for (int j = 0; j < results.size(); j++)
1409            {
1410                Payment temp_obj1 = (Payment)results.get(j);
1411                Currency temp_obj4 = (Currency)temp_obj1.getCurrency();
1412                if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey()))
1413                {
1414                    newObject = false;
1415                                    temp_obj4.addPayment(obj1);
1416                                    break;
1417                }
1418            }
1419                            if (newObject)
1420            {
1421                obj4.initPayments();
1422                obj4.addPayment(obj1);
1423            }
1424                                                                results.add(obj1);
1425        }
1426        return results;
1427    }
1428        
1429        
1430                                  
1431                
1432
1433    /**
1434     * selects a collection of Payment objects pre-filled with
1435     * all related objects.
1436     *
1437     * This method is protected by default in order to keep the public
1438     * api reasonable. You can provide public methods for those you
1439     * actually need in PaymentPeer.
1440     *
1441     * @throws TorqueException Any exceptions caught during processing will be
1442     * rethrown wrapped into a TorqueException.
1443     */

1444    protected static List JavaDoc doSelectJoinAllExceptSorder(Criteria criteria)
1445        throws TorqueException
1446    {
1447        setDbName(criteria);
1448
1449        addSelectColumns(criteria);
1450        int offset2 = numColumns + 1;
1451                                    
1452                    CustomerPeer.addSelectColumns(criteria);
1453        int offset3 = offset2 + CustomerPeer.numColumns;
1454                                                                
1455                    ProjectPeer.addSelectColumns(criteria);
1456        int offset4 = offset3 + ProjectPeer.numColumns;
1457                                                                
1458                                                  
1459                    CurrencyPeer.addSelectColumns(criteria);
1460        int offset5 = offset4 + CurrencyPeer.numColumns;
1461                                                                                                                                                                                                                                                                                                                                                                                                                                                                
1462        List JavaDoc rows = BasePeer.doSelect(criteria);
1463        List JavaDoc results = new ArrayList JavaDoc();
1464
1465        for (int i = 0; i < rows.size(); i++)
1466        {
1467            Record row = (Record)rows.get(i);
1468
1469                            Class JavaDoc omClass = PaymentPeer.getOMClass();
1470                    Payment obj1 = (Payment)PaymentPeer
1471                .row2Object(row, 1, omClass);
1472                                                
1473                                                        
1474                            
1475              
1476                           omClass = CustomerPeer.getOMClass();
1477                          Customer obj2 = (Customer)CustomerPeer
1478                .row2Object( row, offset2, omClass);
1479
1480               boolean newObject = true;
1481            for (int j = 0; j < results.size(); j++)
1482            {
1483                Payment temp_obj1 = (Payment)results.get(j);
1484                Customer temp_obj2 = (Customer)temp_obj1.getCustomer();
1485                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1486                {
1487                    newObject = false;
1488                                    temp_obj2.addPayment(obj1);
1489                                    break;
1490                }
1491            }
1492                            if (newObject)
1493            {
1494                obj2.initPayments();
1495                obj2.addPayment(obj1);
1496            }
1497                                                                                    
1498                                                        
1499                            
1500              
1501                           omClass = ProjectPeer.getOMClass();
1502                          Project obj3 = (Project)ProjectPeer
1503                .row2Object( row, offset3, omClass);
1504
1505               newObject = true;
1506            for (int j = 0; j < results.size(); j++)
1507            {
1508                Payment temp_obj1 = (Payment)results.get(j);
1509                Project temp_obj3 = (Project)temp_obj1.getProject();
1510                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1511                {
1512                    newObject = false;
1513                                    temp_obj3.addPayment(obj1);
1514                                    break;
1515                }
1516            }
1517                            if (newObject)
1518            {
1519                obj3.initPayments();
1520                obj3.addPayment(obj1);
1521            }
1522                                                                                    
1523                                                                  
1524                                                        
1525                            
1526              
1527                           omClass = CurrencyPeer.getOMClass();
1528                          Currency obj4 = (Currency)CurrencyPeer
1529                .row2Object( row, offset4, omClass);
1530
1531               newObject = true;
1532            for (int j = 0; j < results.size(); j++)
1533            {
1534                Payment temp_obj1 = (Payment)results.get(j);
1535                Currency temp_obj4 = (Currency)temp_obj1.getCurrency();
1536                if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey()))
1537                {
1538                    newObject = false;
1539                                    temp_obj4.addPayment(obj1);
1540                                    break;
1541                }
1542            }
1543                            if (newObject)
1544            {
1545                obj4.initPayments();
1546                obj4.addPayment(obj1);
1547            }
1548                                                                results.add(obj1);
1549        }
1550        return results;
1551    }
1552        
1553        
1554                                  
1555                
1556
1557    /**
1558     * selects a collection of Payment objects pre-filled with
1559     * all related objects.
1560     *
1561     * This method is protected by default in order to keep the public
1562     * api reasonable. You can provide public methods for those you
1563     * actually need in PaymentPeer.
1564     *
1565     * @throws TorqueException Any exceptions caught during processing will be
1566     * rethrown wrapped into a TorqueException.
1567     */

1568    protected static List JavaDoc doSelectJoinAllExceptCurrency(Criteria criteria)
1569        throws TorqueException
1570    {
1571        setDbName(criteria);
1572
1573        addSelectColumns(criteria);
1574        int offset2 = numColumns + 1;
1575                                    
1576                    CustomerPeer.addSelectColumns(criteria);
1577        int offset3 = offset2 + CustomerPeer.numColumns;
1578                                                                
1579                    ProjectPeer.addSelectColumns(criteria);
1580        int offset4 = offset3 + ProjectPeer.numColumns;
1581                                                                
1582                    SorderPeer.addSelectColumns(criteria);
1583        int offset5 = offset4 + SorderPeer.numColumns;
1584                                                                
1585                                                                                                                                                                                                                                                                                                                                                                                                                                                  
1586        List JavaDoc rows = BasePeer.doSelect(criteria);
1587        List JavaDoc results = new ArrayList JavaDoc();
1588
1589        for (int i = 0; i < rows.size(); i++)
1590        {
1591            Record row = (Record)rows.get(i);
1592
1593                            Class JavaDoc omClass = PaymentPeer.getOMClass();
1594                    Payment obj1 = (Payment)PaymentPeer
1595                .row2Object(row, 1, omClass);
1596                                                
1597                                                        
1598                            
1599              
1600                           omClass = CustomerPeer.getOMClass();
1601                          Customer obj2 = (Customer)CustomerPeer
1602                .row2Object( row, offset2, omClass);
1603
1604               boolean newObject = true;
1605            for (int j = 0; j < results.size(); j++)
1606            {
1607                Payment temp_obj1 = (Payment)results.get(j);
1608                Customer temp_obj2 = (Customer)temp_obj1.getCustomer();
1609                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1610                {
1611                    newObject = false;
1612                                    temp_obj2.addPayment(obj1);
1613                                    break;
1614                }
1615            }
1616                            if (newObject)
1617            {
1618                obj2.initPayments();
1619                obj2.addPayment(obj1);
1620            }
1621                                                                                    
1622                                                        
1623                            
1624              
1625                           omClass = ProjectPeer.getOMClass();
1626                          Project obj3 = (Project)ProjectPeer
1627                .row2Object( row, offset3, omClass);
1628
1629               newObject = true;
1630            for (int j = 0; j < results.size(); j++)
1631            {
1632                Payment temp_obj1 = (Payment)results.get(j);
1633                Project temp_obj3 = (Project)temp_obj1.getProject();
1634                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1635                {
1636                    newObject = false;
1637                                    temp_obj3.addPayment(obj1);
1638                                    break;
1639                }
1640            }
1641                            if (newObject)
1642            {
1643                obj3.initPayments();
1644                obj3.addPayment(obj1);
1645            }
1646                                                                                    
1647                                                        
1648                            
1649              
1650                           omClass = SorderPeer.getOMClass();
1651                          Sorder obj4 = (Sorder)SorderPeer
1652                .row2Object( row, offset4, omClass);
1653
1654               newObject = true;
1655            for (int j = 0; j < results.size(); j++)
1656            {
1657                Payment temp_obj1 = (Payment)results.get(j);
1658                Sorder temp_obj4 = (Sorder)temp_obj1.getSorder();
1659                if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey()))
1660                {
1661                    newObject = false;
1662                                    temp_obj4.addPayment(obj1);
1663                                    break;
1664                }
1665            }
1666                            if (newObject)
1667            {
1668                obj4.initPayments();
1669                obj4.addPayment(obj1);
1670            }
1671                                                                                    
1672                                              results.add(obj1);
1673        }
1674        return results;
1675    }
1676                    
1677  
1678      /**
1679     * Returns the TableMap related to this peer. This method is not
1680     * needed for general use but a specific application could have a need.
1681     *
1682     * @throws TorqueException Any exceptions caught during processing will be
1683     * rethrown wrapped into a TorqueException.
1684     */

1685    protected static TableMap getTableMap()
1686        throws TorqueException
1687    {
1688        return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME);
1689    }
1690   
1691    private static void setDbName(Criteria crit)
1692    {
1693        // Set the correct dbName if it has not been overridden
1694
// crit.getDbName will return the same object if not set to
1695
// another value so == check is okay and faster
1696
if (crit.getDbName() == Torque.getDefaultDB())
1697        {
1698            crit.setDbName(DATABASE_NAME);
1699        }
1700    }
1701}
1702
Free Books   Free Magazines  
Popular Tags