KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > tigris > scarab > om > BaseActivitySetPeer


1 package org.tigris.scarab.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.tigris.scarab.om.map.*;
32
33
34   
35   
36   
37 /**
38  */

39 public abstract class BaseActivitySetPeer
40     extends BasePeer
41 {
42
43     /** the default database name for this class */
44     public static final String JavaDoc DATABASE_NAME = "scarab";
45
46      /** the table name for this class */
47     public static final String JavaDoc TABLE_NAME = "SCARAB_TRANSACTION";
48
49     /**
50      * @return the map builder for this peer
51      * @throws TorqueException Any exceptions caught during processing will be
52      * rethrown wrapped into a TorqueException.
53      */

54     public static MapBuilder getMapBuilder()
55         throws TorqueException
56     {
57         return getMapBuilder(ActivitySetMapBuilder.CLASS_NAME);
58     }
59
60       /** the column name for the TRANSACTION_ID field */
61     public static final String JavaDoc TRANSACTION_ID;
62       /** the column name for the TYPE_ID field */
63     public static final String JavaDoc TYPE_ID;
64       /** the column name for the ATTACHMENT_ID field */
65     public static final String JavaDoc ATTACHMENT_ID;
66       /** the column name for the CREATED_BY field */
67     public static final String JavaDoc CREATED_BY;
68       /** the column name for the CREATED_DATE field */
69     public static final String JavaDoc CREATED_DATE;
70   
71     static
72     {
73           TRANSACTION_ID = "SCARAB_TRANSACTION.TRANSACTION_ID";
74           TYPE_ID = "SCARAB_TRANSACTION.TYPE_ID";
75           ATTACHMENT_ID = "SCARAB_TRANSACTION.ATTACHMENT_ID";
76           CREATED_BY = "SCARAB_TRANSACTION.CREATED_BY";
77           CREATED_DATE = "SCARAB_TRANSACTION.CREATED_DATE";
78           if (Torque.isInit())
79         {
80             try
81             {
82                 getMapBuilder(ActivitySetMapBuilder.CLASS_NAME);
83             }
84             catch (Exception JavaDoc e)
85             {
86                 log.error("Could not initialize Peer", e);
87             }
88         }
89         else
90         {
91             Torque.registerMapBuilder(ActivitySetMapBuilder.CLASS_NAME);
92         }
93     }
94  
95     /** number of columns for this peer */
96     public static final int numColumns = 5;
97
98     /** A class that can be returned by this peer. */
99     protected static final String JavaDoc CLASSNAME_DEFAULT =
100         "org.tigris.scarab.om.ActivitySet";
101
102     /** A class that can be returned by this peer. */
103     protected static final Class JavaDoc CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT);
104
105     /**
106      * Class object initialization method.
107      *
108      * @param className name of the class to initialize
109      * @return the initialized class
110      */

111     private static Class JavaDoc initClass(String JavaDoc className)
112     {
113         Class JavaDoc c = null;
114         try
115         {
116             c = Class.forName(className);
117         }
118         catch (Throwable JavaDoc t)
119         {
120             log.error("A FATAL ERROR has occurred which should not "
121                 + "have happened under any circumstance. Please notify "
122                 + "the Torque developers <torque-dev@db.apache.org> "
123                 + "and give as many details as possible (including the error "
124                 + "stack trace).", t);
125
126             // Error objects should always be propogated.
127
if (t instanceof Error JavaDoc)
128             {
129                 throw (Error JavaDoc) t.fillInStackTrace();
130             }
131         }
132         return c;
133     }
134
135     /**
136      * Get the list of objects for a ResultSet. Please not that your
137      * resultset MUST return columns in the right order. You can use
138      * getFieldNames() in BaseObject to get the correct sequence.
139      *
140      * @param results the ResultSet
141      * @return the list of objects
142      * @throws TorqueException Any exceptions caught during processing will be
143      * rethrown wrapped into a TorqueException.
144      */

145     public static List JavaDoc resultSet2Objects(java.sql.ResultSet JavaDoc results)
146             throws TorqueException
147     {
148         try
149         {
150             QueryDataSet qds = null;
151             List JavaDoc rows = null;
152             try
153             {
154                 qds = new QueryDataSet(results);
155                 rows = getSelectResults(qds);
156             }
157             finally
158             {
159                 if (qds != null)
160                 {
161                     qds.close();
162                 }
163             }
164
165             return populateObjects(rows);
166         }
167         catch (SQLException JavaDoc e)
168         {
169             throw new TorqueException(e);
170         }
171         catch (DataSetException e)
172         {
173             throw new TorqueException(e);
174         }
175     }
176
177
178   
179     /**
180      * Method to do inserts.
181      *
182      * @param criteria object used to create the INSERT statement.
183      * @throws TorqueException Any exceptions caught during processing will be
184      * rethrown wrapped into a TorqueException.
185      */

186     public static ObjectKey doInsert(Criteria criteria)
187         throws TorqueException
188     {
189         return BaseActivitySetPeer
190             .doInsert(criteria, (Connection JavaDoc) null);
191     }
192
193     /**
194      * Method to do inserts. This method is to be used during a transaction,
195      * otherwise use the doInsert(Criteria) method. It will take care of
196      * the connection details internally.
197      *
198      * @param criteria object used to create the INSERT statement.
199      * @param con the connection to use
200      * @throws TorqueException Any exceptions caught during processing will be
201      * rethrown wrapped into a TorqueException.
202      */

203     public static ObjectKey doInsert(Criteria criteria, Connection JavaDoc con)
204         throws TorqueException
205     {
206                                 
207         setDbName(criteria);
208
209         if (con == null)
210         {
211             return BasePeer.doInsert(criteria);
212         }
213         else
214         {
215             return BasePeer.doInsert(criteria, con);
216         }
217     }
218
219     /**
220      * Add all the columns needed to create a new object.
221      *
222      * @param criteria object containing the columns to add.
223      * @throws TorqueException Any exceptions caught during processing will be
224      * rethrown wrapped into a TorqueException.
225      */

226     public static void addSelectColumns(Criteria criteria)
227             throws TorqueException
228     {
229           criteria.addSelectColumn(TRANSACTION_ID);
230           criteria.addSelectColumn(TYPE_ID);
231           criteria.addSelectColumn(ATTACHMENT_ID);
232           criteria.addSelectColumn(CREATED_BY);
233           criteria.addSelectColumn(CREATED_DATE);
234       }
235
236     /**
237      * Create a new object of type cls from a resultset row starting
238      * from a specified offset. This is done so that you can select
239      * other rows than just those needed for this object. You may
240      * for example want to create two objects from the same row.
241      *
242      * @throws TorqueException Any exceptions caught during processing will be
243      * rethrown wrapped into a TorqueException.
244      */

245     public static ActivitySet row2Object(Record row,
246                                              int offset,
247                                              Class JavaDoc cls)
248         throws TorqueException
249     {
250         try
251         {
252             ActivitySet obj = (ActivitySet) cls.newInstance();
253             ActivitySetPeer.populateObject(row, offset, obj);
254                   obj.setModified(false);
255               obj.setNew(false);
256
257             return obj;
258         }
259         catch (InstantiationException JavaDoc e)
260         {
261             throw new TorqueException(e);
262         }
263         catch (IllegalAccessException JavaDoc e)
264         {
265             throw new TorqueException(e);
266         }
267     }
268
269     /**
270      * Populates an object from a resultset row starting
271      * from a specified offset. This is done so that you can select
272      * other rows than just those needed for this object. You may
273      * for example want to create two objects from the same row.
274      *
275      * @throws TorqueException Any exceptions caught during processing will be
276      * rethrown wrapped into a TorqueException.
277      */

278     public static void populateObject(Record row,
279                                       int offset,
280                                       ActivitySet obj)
281         throws TorqueException
282     {
283         try
284         {
285                 obj.setActivitySetId(row.getValue(offset + 0).asLongObj());
286                   obj.setTypeId(row.getValue(offset + 1).asIntegerObj());
287                   obj.setAttachmentId(row.getValue(offset + 2).asLongObj());
288                   obj.setCreatedBy(row.getValue(offset + 3).asIntegerObj());
289                   obj.setCreatedDate(row.getValue(offset + 4).asUtilDate());
290               }
291         catch (DataSetException e)
292         {
293             throw new TorqueException(e);
294         }
295     }
296
297     /**
298      * Method to do selects.
299      *
300      * @param criteria object used to create the SELECT statement.
301      * @return List of selected Objects
302      * @throws TorqueException Any exceptions caught during processing will be
303      * rethrown wrapped into a TorqueException.
304      */

305     public static List JavaDoc doSelect(Criteria criteria) throws TorqueException
306     {
307         return populateObjects(doSelectVillageRecords(criteria));
308     }
309
310     /**
311      * Method to do selects within a transaction.
312      *
313      * @param criteria object used to create the SELECT statement.
314      * @param con the connection to use
315      * @return List of selected Objects
316      * @throws TorqueException Any exceptions caught during processing will be
317      * rethrown wrapped into a TorqueException.
318      */

319     public static List JavaDoc doSelect(Criteria criteria, Connection JavaDoc con)
320         throws TorqueException
321     {
322         return populateObjects(doSelectVillageRecords(criteria, con));
323     }
324
325     /**
326      * Grabs the raw Village records to be formed into objects.
327      * This method handles connections internally. The Record objects
328      * returned by this method should be considered readonly. Do not
329      * alter the data and call save(), your results may vary, but are
330      * certainly likely to result in hard to track MT bugs.
331      *
332      * @throws TorqueException Any exceptions caught during processing will be
333      * rethrown wrapped into a TorqueException.
334      */

335     public static List JavaDoc doSelectVillageRecords(Criteria criteria)
336         throws TorqueException
337     {
338         return BaseActivitySetPeer
339             .doSelectVillageRecords(criteria, (Connection JavaDoc) null);
340     }
341
342     /**
343      * Grabs the raw Village records to be formed into objects.
344      * This method should be used for transactions
345      *
346      * @param criteria object used to create the SELECT statement.
347      * @param con the connection to use
348      * @throws TorqueException Any exceptions caught during processing will be
349      * rethrown wrapped into a TorqueException.
350      */

351     public static List JavaDoc doSelectVillageRecords(Criteria criteria, Connection JavaDoc con)
352         throws TorqueException
353     {
354         if (criteria.getSelectColumns().size() == 0)
355         {
356             addSelectColumns(criteria);
357         }
358
359                                 
360         setDbName(criteria);
361
362         // BasePeer returns a List of Value (Village) arrays. The array
363
// order follows the order columns were placed in the Select clause.
364
if (con == null)
365         {
366             return BasePeer.doSelect(criteria);
367         }
368         else
369         {
370             return BasePeer.doSelect(criteria, con);
371         }
372     }
373
374     /**
375      * The returned List will contain objects of the default type or
376      * objects that inherit from the default.
377      *
378      * @throws TorqueException Any exceptions caught during processing will be
379      * rethrown wrapped into a TorqueException.
380      */

381     public static List JavaDoc populateObjects(List JavaDoc records)
382         throws TorqueException
383     {
384         List JavaDoc results = new ArrayList JavaDoc(records.size());
385
386         // populate the object(s)
387
for (int i = 0; i < records.size(); i++)
388         {
389             Record row = (Record) records.get(i);
390               results.add(ActivitySetPeer.row2Object(row, 1,
391                 ActivitySetPeer.getOMClass()));
392           }
393         return results;
394     }
395  
396
397     /**
398      * The class that the Peer will make instances of.
399      * If the BO is abstract then you must implement this method
400      * in the BO.
401      *
402      * @throws TorqueException Any exceptions caught during processing will be
403      * rethrown wrapped into a TorqueException.
404      */

405     public static Class JavaDoc getOMClass()
406         throws TorqueException
407     {
408         return CLASS_DEFAULT;
409     }
410
411     /**
412      * Method to do updates.
413      *
414      * @param criteria object containing data that is used to create the UPDATE
415      * statement.
416      * @throws TorqueException Any exceptions caught during processing will be
417      * rethrown wrapped into a TorqueException.
418      */

419     public static void doUpdate(Criteria criteria) throws TorqueException
420     {
421          BaseActivitySetPeer
422             .doUpdate(criteria, (Connection JavaDoc) null);
423     }
424
425     /**
426      * Method to do updates. This method is to be used during a transaction,
427      * otherwise use the doUpdate(Criteria) method. It will take care of
428      * the connection details internally.
429      *
430      * @param criteria object containing data that is used to create the UPDATE
431      * statement.
432      * @param con the connection to use
433      * @throws TorqueException Any exceptions caught during processing will be
434      * rethrown wrapped into a TorqueException.
435      */

436     public static void doUpdate(Criteria criteria, Connection JavaDoc con)
437         throws TorqueException
438     {
439         Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
440                    selectCriteria.put(TRANSACTION_ID, criteria.remove(TRANSACTION_ID));
441                                               
442         setDbName(criteria);
443
444         if (con == null)
445         {
446             BasePeer.doUpdate(selectCriteria, criteria);
447         }
448         else
449         {
450             BasePeer.doUpdate(selectCriteria, criteria, con);
451         }
452     }
453
454     /**
455      * Method to do deletes.
456      *
457      * @param criteria object containing data that is used DELETE from database.
458      * @throws TorqueException Any exceptions caught during processing will be
459      * rethrown wrapped into a TorqueException.
460      */

461      public static void doDelete(Criteria criteria) throws TorqueException
462      {
463          ActivitySetPeer
464             .doDelete(criteria, (Connection JavaDoc) null);
465      }
466
467     /**
468      * Method to do deletes. This method is to be used during a transaction,
469      * otherwise use the doDelete(Criteria) method. It will take care of
470      * the connection details internally.
471      *
472      * @param criteria object containing data that is used DELETE from database.
473      * @param con the connection to use
474      * @throws TorqueException Any exceptions caught during processing will be
475      * rethrown wrapped into a TorqueException.
476      */

477      public static void doDelete(Criteria criteria, Connection JavaDoc con)
478         throws TorqueException
479      {
480                                 
481         setDbName(criteria);
482
483         if (con == null)
484         {
485             BasePeer.doDelete(criteria);
486         }
487         else
488         {
489             BasePeer.doDelete(criteria, con);
490         }
491      }
492
493     /**
494      * Method to do selects
495      *
496      * @throws TorqueException Any exceptions caught during processing will be
497      * rethrown wrapped into a TorqueException.
498      */

499     public static List JavaDoc doSelect(ActivitySet obj) throws TorqueException
500     {
501         return doSelect(buildSelectCriteria(obj));
502     }
503
504     /**
505      * Method to do inserts
506      *
507      * @throws TorqueException Any exceptions caught during processing will be
508      * rethrown wrapped into a TorqueException.
509      */

510     public static void doInsert(ActivitySet obj) throws TorqueException
511     {
512           obj.setPrimaryKey(doInsert(buildCriteria(obj)));
513           obj.setNew(false);
514         obj.setModified(false);
515     }
516
517     /**
518      * @param obj the data object to update in the database.
519      * @throws TorqueException Any exceptions caught during processing will be
520      * rethrown wrapped into a TorqueException.
521      */

522     public static void doUpdate(ActivitySet obj) throws TorqueException
523     {
524         doUpdate(buildCriteria(obj));
525         obj.setModified(false);
526     }
527
528     /**
529      * @param obj the data object to delete in the database.
530      * @throws TorqueException Any exceptions caught during processing will be
531      * rethrown wrapped into a TorqueException.
532      */

533     public static void doDelete(ActivitySet obj) throws TorqueException
534     {
535         doDelete(buildSelectCriteria(obj));
536     }
537
538     /**
539      * Method to do inserts. This method is to be used during a transaction,
540      * otherwise use the doInsert(ActivitySet) method. It will take
541      * care of the connection details internally.
542      *
543      * @param obj the data object to insert into the database.
544      * @param con the connection to use
545      * @throws TorqueException Any exceptions caught during processing will be
546      * rethrown wrapped into a TorqueException.
547      */

548     public static void doInsert(ActivitySet obj, Connection JavaDoc con)
549         throws TorqueException
550     {
551           obj.setPrimaryKey(doInsert(buildCriteria(obj), con));
552           obj.setNew(false);
553         obj.setModified(false);
554     }
555
556     /**
557      * Method to do update. This method is to be used during a transaction,
558      * otherwise use the doUpdate(ActivitySet) method. It will take
559      * care of the connection details internally.
560      *
561      * @param obj the data object to update in the database.
562      * @param con the connection to use
563      * @throws TorqueException Any exceptions caught during processing will be
564      * rethrown wrapped into a TorqueException.
565      */

566     public static void doUpdate(ActivitySet obj, Connection JavaDoc con)
567         throws TorqueException
568     {
569         doUpdate(buildCriteria(obj), con);
570         obj.setModified(false);
571     }
572
573     /**
574      * Method to delete. This method is to be used during a transaction,
575      * otherwise use the doDelete(ActivitySet) method. It will take
576      * care of the connection details internally.
577      *
578      * @param obj the data object to delete in the database.
579      * @param con the connection to use
580      * @throws TorqueException Any exceptions caught during processing will be
581      * rethrown wrapped into a TorqueException.
582      */

583     public static void doDelete(ActivitySet obj, Connection JavaDoc con)
584         throws TorqueException
585     {
586         doDelete(buildSelectCriteria(obj), con);
587     }
588
589     /**
590      * Method to do deletes.
591      *
592      * @param pk ObjectKey that is used DELETE from database.
593      * @throws TorqueException Any exceptions caught during processing will be
594      * rethrown wrapped into a TorqueException.
595      */

596     public static void doDelete(ObjectKey pk) throws TorqueException
597     {
598         BaseActivitySetPeer
599            .doDelete(pk, (Connection JavaDoc) null);
600     }
601
602     /**
603      * Method to delete. This method is to be used during a transaction,
604      * otherwise use the doDelete(ObjectKey) method. It will take
605      * care of the connection details internally.
606      *
607      * @param pk the primary key for the object to delete in the database.
608      * @param con the connection to use
609      * @throws TorqueException Any exceptions caught during processing will be
610      * rethrown wrapped into a TorqueException.
611      */

612     public static void doDelete(ObjectKey pk, Connection JavaDoc con)
613         throws TorqueException
614     {
615         doDelete(buildCriteria(pk), con);
616     }
617
618     /** Build a Criteria object from an ObjectKey */
619     public static Criteria buildCriteria( ObjectKey pk )
620     {
621         Criteria criteria = new Criteria();
622               criteria.add(TRANSACTION_ID, pk);
623           return criteria;
624      }
625
626     /** Build a Criteria object from the data object for this peer */
627     public static Criteria buildCriteria( ActivitySet obj )
628     {
629         Criteria criteria = new Criteria(DATABASE_NAME);
630               if (!obj.isNew())
631             criteria.add(TRANSACTION_ID, obj.getActivitySetId());
632               criteria.add(TYPE_ID, obj.getTypeId());
633               criteria.add(ATTACHMENT_ID, obj.getAttachmentId());
634               criteria.add(CREATED_BY, obj.getCreatedBy());
635               criteria.add(CREATED_DATE, obj.getCreatedDate());
636           return criteria;
637     }
638
639     /** Build a Criteria object from the data object for this peer, skipping all binary columns */
640     public static Criteria buildSelectCriteria( ActivitySet obj )
641     {
642         Criteria criteria = new Criteria(DATABASE_NAME);
643               if (!obj.isNew())
644                     criteria.add(TRANSACTION_ID, obj.getActivitySetId());
645                           criteria.add(TYPE_ID, obj.getTypeId());
646                           criteria.add(ATTACHMENT_ID, obj.getAttachmentId());
647                           criteria.add(CREATED_BY, obj.getCreatedBy());
648                           criteria.add(CREATED_DATE, obj.getCreatedDate());
649               return criteria;
650     }
651  
652     
653         /**
654      * Retrieve a single object by pk
655      *
656      * @param pk the primary key
657      * @throws TorqueException Any exceptions caught during processing will be
658      * rethrown wrapped into a TorqueException.
659      * @throws NoRowsException Primary key was not found in database.
660      * @throws TooManyRowsException Primary key was not found in database.
661      */

662     public static ActivitySet retrieveByPK(Long JavaDoc pk)
663         throws TorqueException, NoRowsException, TooManyRowsException
664     {
665         return retrieveByPK(SimpleKey.keyFor(pk));
666     }
667
668     /**
669      * Retrieve a single object by pk
670      *
671      * @param pk the primary key
672      * @param con the connection to use
673      * @throws TorqueException Any exceptions caught during processing will be
674      * rethrown wrapped into a TorqueException.
675      * @throws NoRowsException Primary key was not found in database.
676      * @throws TooManyRowsException Primary key was not found in database.
677      */

678     public static ActivitySet retrieveByPK(Long JavaDoc pk, Connection JavaDoc con)
679         throws TorqueException, NoRowsException, TooManyRowsException
680     {
681         return retrieveByPK(SimpleKey.keyFor(pk), con);
682     }
683   
684     /**
685      * Retrieve a single object by pk
686      *
687      * @param pk the primary key
688      * @throws TorqueException Any exceptions caught during processing will be
689      * rethrown wrapped into a TorqueException.
690      * @throws NoRowsException Primary key was not found in database.
691      * @throws TooManyRowsException Primary key was not found in database.
692      */

693     public static ActivitySet retrieveByPK(ObjectKey pk)
694         throws TorqueException, NoRowsException, TooManyRowsException
695     {
696         Connection JavaDoc db = null;
697         ActivitySet retVal = null;
698         try
699         {
700             db = Torque.getConnection(DATABASE_NAME);
701             retVal = retrieveByPK(pk, db);
702         }
703         finally
704         {
705             Torque.closeConnection(db);
706         }
707         return(retVal);
708     }
709
710     /**
711      * Retrieve a single object by pk
712      *
713      * @param pk the primary key
714      * @param con the connection to use
715      * @throws TorqueException Any exceptions caught during processing will be
716      * rethrown wrapped into a TorqueException.
717      * @throws NoRowsException Primary key was not found in database.
718      * @throws TooManyRowsException Primary key was not found in database.
719      */

720     public static ActivitySet retrieveByPK(ObjectKey pk, Connection JavaDoc con)
721         throws TorqueException, NoRowsException, TooManyRowsException
722     {
723         Criteria criteria = buildCriteria(pk);
724         List JavaDoc v = doSelect(criteria, con);
725         if (v.size() == 0)
726         {
727             throw new NoRowsException("Failed to select a row.");
728         }
729         else if (v.size() > 1)
730         {
731             throw new TooManyRowsException("Failed to select only one row.");
732         }
733         else
734         {
735             return (ActivitySet)v.get(0);
736         }
737     }
738
739     /**
740      * Retrieve a multiple objects by pk
741      *
742      * @param pks List of primary keys
743      * @throws TorqueException Any exceptions caught during processing will be
744      * rethrown wrapped into a TorqueException.
745      */

746     public static List JavaDoc retrieveByPKs(List JavaDoc pks)
747         throws TorqueException
748     {
749         Connection JavaDoc db = null;
750         List JavaDoc retVal = null;
751         try
752         {
753            db = Torque.getConnection(DATABASE_NAME);
754            retVal = retrieveByPKs(pks, db);
755         }
756         finally
757         {
758             Torque.closeConnection(db);
759         }
760         return(retVal);
761     }
762
763     /**
764      * Retrieve a multiple objects by pk
765      *
766      * @param pks List of primary keys
767      * @param dbcon the connection to use
768      * @throws TorqueException Any exceptions caught during processing will be
769      * rethrown wrapped into a TorqueException.
770      */

771     public static List JavaDoc retrieveByPKs( List JavaDoc pks, Connection JavaDoc dbcon )
772         throws TorqueException
773     {
774         List JavaDoc objs = null;
775         if (pks == null || pks.size() == 0)
776         {
777             objs = new LinkedList JavaDoc();
778         }
779         else
780         {
781             Criteria criteria = new Criteria();
782               criteria.addIn( TRANSACTION_ID, pks );
783           objs = doSelect(criteria, dbcon);
784         }
785         return objs;
786     }
787
788  
789
790
791
792               
793                                               
794                         
795                 
796
797     /**
798      * selects a collection of ActivitySet objects pre-filled with their
799      * ScarabUserImpl objects.
800      *
801      * This method is protected by default in order to keep the public
802      * api reasonable. You can provide public methods for those you
803      * actually need in ActivitySetPeer.
804      *
805      * @throws TorqueException Any exceptions caught during processing will be
806      * rethrown wrapped into a TorqueException.
807      */

808     protected static List JavaDoc doSelectJoinScarabUserImpl(Criteria criteria)
809         throws TorqueException
810     {
811         setDbName(criteria);
812
813         ActivitySetPeer.addSelectColumns(criteria);
814         int offset = numColumns + 1;
815         ScarabUserImplPeer.addSelectColumns(criteria);
816
817
818                         criteria.addJoin(ActivitySetPeer.CREATED_BY,
819             ScarabUserImplPeer.USER_ID);
820         
821
822                                                                                                   
823         List JavaDoc rows = BasePeer.doSelect(criteria);
824         List JavaDoc results = new ArrayList JavaDoc();
825
826         for (int i = 0; i < rows.size(); i++)
827         {
828             Record row = (Record) rows.get(i);
829
830                             Class JavaDoc omClass = ActivitySetPeer.getOMClass();
831                     ActivitySet obj1 = (ActivitySet) ActivitySetPeer
832                 .row2Object(row, 1, omClass);
833                      omClass = ScarabUserImplPeer.getOMClass();
834                     ScarabUserImpl obj2 = (ScarabUserImpl)ScarabUserImplPeer
835                 .row2Object(row, offset, omClass);
836
837             boolean newObject = true;
838             for (int j = 0; j < results.size(); j++)
839             {
840                 ActivitySet temp_obj1 = (ActivitySet)results.get(j);
841                 ScarabUserImpl temp_obj2 = (ScarabUserImpl)temp_obj1.getScarabUser();
842                 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
843                 {
844                     newObject = false;
845                               temp_obj2.addActivitySet(obj1);
846                               break;
847                 }
848             }
849                       if (newObject)
850             {
851                 obj2.initActivitySets();
852                 obj2.addActivitySet(obj1);
853             }
854                       results.add(obj1);
855         }
856         return results;
857     }
858                                                             
859                 
860                 
861
862     /**
863      * selects a collection of ActivitySet objects pre-filled with their
864      * ActivitySetType objects.
865      *
866      * This method is protected by default in order to keep the public
867      * api reasonable. You can provide public methods for those you
868      * actually need in ActivitySetPeer.
869      *
870      * @throws TorqueException Any exceptions caught during processing will be
871      * rethrown wrapped into a TorqueException.
872      */

873     protected static List JavaDoc doSelectJoinActivitySetType(Criteria criteria)
874         throws TorqueException
875     {
876         setDbName(criteria);
877
878         ActivitySetPeer.addSelectColumns(criteria);
879         int offset = numColumns + 1;
880         ActivitySetTypePeer.addSelectColumns(criteria);
881
882
883                         criteria.addJoin(ActivitySetPeer.TYPE_ID,
884             ActivitySetTypePeer.TYPE_ID);
885         
886
887                                                                                                   
888         List JavaDoc rows = BasePeer.doSelect(criteria);
889         List JavaDoc results = new ArrayList JavaDoc();
890
891         for (int i = 0; i < rows.size(); i++)
892         {
893             Record row = (Record) rows.get(i);
894
895                             Class JavaDoc omClass = ActivitySetPeer.getOMClass();
896                     ActivitySet obj1 = (ActivitySet) ActivitySetPeer
897                 .row2Object(row, 1, omClass);
898                      omClass = ActivitySetTypePeer.getOMClass();
899                     ActivitySetType obj2 = (ActivitySetType)ActivitySetTypePeer
900                 .row2Object(row, offset, omClass);
901
902             boolean newObject = true;
903             for (int j = 0; j < results.size(); j++)
904             {
905                 ActivitySet temp_obj1 = (ActivitySet)results.get(j);
906                 ActivitySetType temp_obj2 = (ActivitySetType)temp_obj1.getActivitySetType();
907                 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
908                 {
909                     newObject = false;
910                               temp_obj2.addActivitySet(obj1);
911                               break;
912                 }
913             }
914                       if (newObject)
915             {
916                 obj2.initActivitySets();
917                 obj2.addActivitySet(obj1);
918             }
919                       results.add(obj1);
920         }
921         return results;
922     }
923                                                             
924                 
925                 
926
927     /**
928      * selects a collection of ActivitySet objects pre-filled with their
929      * Attachment objects.
930      *
931      * This method is protected by default in order to keep the public
932      * api reasonable. You can provide public methods for those you
933      * actually need in ActivitySetPeer.
934      *
935      * @throws TorqueException Any exceptions caught during processing will be
936      * rethrown wrapped into a TorqueException.
937      */

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

1007    protected static List JavaDoc doSelectJoinAllExceptScarabUserImpl(Criteria criteria)
1008        throws TorqueException
1009    {
1010        setDbName(criteria);
1011
1012        addSelectColumns(criteria);
1013        int offset2 = numColumns + 1;
1014                                    
1015                                                  
1016                    ActivitySetTypePeer.addSelectColumns(criteria);
1017        int offset3 = offset2 + ActivitySetTypePeer.numColumns;
1018                                                                
1019                    AttachmentPeer.addSelectColumns(criteria);
1020        int offset4 = offset3 + AttachmentPeer.numColumns;
1021                                                                                                                                              
1022        List JavaDoc rows = BasePeer.doSelect(criteria);
1023        List JavaDoc results = new ArrayList JavaDoc();
1024
1025        for (int i = 0; i < rows.size(); i++)
1026        {
1027            Record row = (Record)rows.get(i);
1028
1029                            Class JavaDoc omClass = ActivitySetPeer.getOMClass();
1030                    ActivitySet obj1 = (ActivitySet)ActivitySetPeer
1031                .row2Object(row, 1, omClass);
1032                                                            
1033                                                                  
1034                                                        
1035                            
1036              
1037                           omClass = ActivitySetTypePeer.getOMClass();
1038                          ActivitySetType obj2 = (ActivitySetType)ActivitySetTypePeer
1039                .row2Object( row, offset2, omClass);
1040
1041               boolean newObject = true;
1042            for (int j = 0; j < results.size(); j++)
1043            {
1044                ActivitySet temp_obj1 = (ActivitySet)results.get(j);
1045                ActivitySetType temp_obj2 = (ActivitySetType)temp_obj1.getActivitySetType();
1046                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1047                {
1048                    newObject = false;
1049                                    temp_obj2.addActivitySet(obj1);
1050                                    break;
1051                }
1052            }
1053                            if (newObject)
1054            {
1055                obj2.initActivitySets();
1056                obj2.addActivitySet(obj1);
1057            }
1058                                                                                    
1059                                                        
1060                            
1061              
1062                           omClass = AttachmentPeer.getOMClass();
1063                          Attachment obj3 = (Attachment)AttachmentPeer
1064                .row2Object( row, offset3, omClass);
1065
1066               newObject = true;
1067            for (int j = 0; j < results.size(); j++)
1068            {
1069                ActivitySet temp_obj1 = (ActivitySet)results.get(j);
1070                Attachment temp_obj3 = (Attachment)temp_obj1.getAttachment();
1071                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1072                {
1073                    newObject = false;
1074                                    temp_obj3.addActivitySet(obj1);
1075                                    break;
1076                }
1077            }
1078                            if (newObject)
1079            {
1080                obj3.initActivitySets();
1081                obj3.addActivitySet(obj1);
1082            }
1083                                                                results.add(obj1);
1084        }
1085        return results;
1086    }
1087        
1088        
1089                                  
1090                
1091
1092    /**
1093     * selects a collection of ActivitySet objects pre-filled with
1094     * all related objects.
1095     *
1096     * This method is protected by default in order to keep the public
1097     * api reasonable. You can provide public methods for those you
1098     * actually need in ActivitySetPeer.
1099     *
1100     * @throws TorqueException Any exceptions caught during processing will be
1101     * rethrown wrapped into a TorqueException.
1102     */

1103    protected static List JavaDoc doSelectJoinAllExceptActivitySetType(Criteria criteria)
1104        throws TorqueException
1105    {
1106        setDbName(criteria);
1107
1108        addSelectColumns(criteria);
1109        int offset2 = numColumns + 1;
1110                                    
1111                    ScarabUserImplPeer.addSelectColumns(criteria);
1112        int offset3 = offset2 + ScarabUserImplPeer.numColumns;
1113                                                                
1114                                                  
1115                    AttachmentPeer.addSelectColumns(criteria);
1116        int offset4 = offset3 + AttachmentPeer.numColumns;
1117                                                                                                                                              
1118        List JavaDoc rows = BasePeer.doSelect(criteria);
1119        List JavaDoc results = new ArrayList JavaDoc();
1120
1121        for (int i = 0; i < rows.size(); i++)
1122        {
1123            Record row = (Record)rows.get(i);
1124
1125                            Class JavaDoc omClass = ActivitySetPeer.getOMClass();
1126                    ActivitySet obj1 = (ActivitySet)ActivitySetPeer
1127                .row2Object(row, 1, omClass);
1128                                                            
1129                                                        
1130                            
1131              
1132                           omClass = ScarabUserImplPeer.getOMClass();
1133                          ScarabUserImpl obj2 = (ScarabUserImpl)ScarabUserImplPeer
1134                .row2Object( row, offset2, omClass);
1135
1136               boolean newObject = true;
1137            for (int j = 0; j < results.size(); j++)
1138            {
1139                ActivitySet temp_obj1 = (ActivitySet)results.get(j);
1140                ScarabUserImpl temp_obj2 = (ScarabUserImpl)temp_obj1.getScarabUser();
1141                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1142                {
1143                    newObject = false;
1144                                    temp_obj2.addActivitySet(obj1);
1145                                    break;
1146                }
1147            }
1148                            if (newObject)
1149            {
1150                obj2.initActivitySets();
1151                obj2.addActivitySet(obj1);
1152            }
1153                                                                                    
1154                                                                  
1155                                                        
1156                            
1157              
1158                           omClass = AttachmentPeer.getOMClass();
1159                          Attachment obj3 = (Attachment)AttachmentPeer
1160                .row2Object( row, offset3, omClass);
1161
1162               newObject = true;
1163            for (int j = 0; j < results.size(); j++)
1164            {
1165                ActivitySet temp_obj1 = (ActivitySet)results.get(j);
1166                Attachment temp_obj3 = (Attachment)temp_obj1.getAttachment();
1167                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1168                {
1169                    newObject = false;
1170                                    temp_obj3.addActivitySet(obj1);
1171                                    break;
1172                }
1173            }
1174                            if (newObject)
1175            {
1176                obj3.initActivitySets();
1177                obj3.addActivitySet(obj1);
1178            }
1179                                                                results.add(obj1);
1180        }
1181        return results;
1182    }
1183        
1184        
1185                                  
1186                
1187
1188    /**
1189     * selects a collection of ActivitySet objects pre-filled with
1190     * all related objects.
1191     *
1192     * This method is protected by default in order to keep the public
1193     * api reasonable. You can provide public methods for those you
1194     * actually need in ActivitySetPeer.
1195     *
1196     * @throws TorqueException Any exceptions caught during processing will be
1197     * rethrown wrapped into a TorqueException.
1198     */

1199    protected static List JavaDoc doSelectJoinAllExceptAttachment(Criteria criteria)
1200        throws TorqueException
1201    {
1202        setDbName(criteria);
1203
1204        addSelectColumns(criteria);
1205        int offset2 = numColumns + 1;
1206                                    
1207                    ScarabUserImplPeer.addSelectColumns(criteria);
1208        int offset3 = offset2 + ScarabUserImplPeer.numColumns;
1209                                                                
1210                    ActivitySetTypePeer.addSelectColumns(criteria);
1211        int offset4 = offset3 + ActivitySetTypePeer.numColumns;
1212                                                                
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 = ActivitySetPeer.getOMClass();
1222                    ActivitySet obj1 = (ActivitySet)ActivitySetPeer
1223                .row2Object(row, 1, omClass);
1224                                                            
1225                                                        
1226                            
1227              
1228                           omClass = ScarabUserImplPeer.getOMClass();
1229                          ScarabUserImpl obj2 = (ScarabUserImpl)ScarabUserImplPeer
1230                .row2Object( row, offset2, omClass);
1231
1232               boolean newObject = true;
1233            for (int j = 0; j < results.size(); j++)
1234            {
1235                ActivitySet temp_obj1 = (ActivitySet)results.get(j);
1236                ScarabUserImpl temp_obj2 = (ScarabUserImpl)temp_obj1.getScarabUser();
1237                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1238                {
1239                    newObject = false;
1240                                    temp_obj2.addActivitySet(obj1);
1241                                    break;
1242                }
1243            }
1244                            if (newObject)
1245            {
1246                obj2.initActivitySets();
1247                obj2.addActivitySet(obj1);
1248            }
1249                                                                                    
1250                                                        
1251                            
1252              
1253                           omClass = ActivitySetTypePeer.getOMClass();
1254                          ActivitySetType obj3 = (ActivitySetType)ActivitySetTypePeer
1255                .row2Object( row, offset3, omClass);
1256
1257               newObject = true;
1258            for (int j = 0; j < results.size(); j++)
1259            {
1260                ActivitySet temp_obj1 = (ActivitySet)results.get(j);
1261                ActivitySetType temp_obj3 = (ActivitySetType)temp_obj1.getActivitySetType();
1262                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1263                {
1264                    newObject = false;
1265                                    temp_obj3.addActivitySet(obj1);
1266                                    break;
1267                }
1268            }
1269                            if (newObject)
1270            {
1271                obj3.initActivitySets();
1272                obj3.addActivitySet(obj1);
1273            }
1274                                                                                    
1275                                              results.add(obj1);
1276        }
1277        return results;
1278    }
1279                    
1280  
1281      /**
1282     * Returns the TableMap related to this peer. This method is not
1283     * needed for general use but a specific application could have a need.
1284     *
1285     * @throws TorqueException Any exceptions caught during processing will be
1286     * rethrown wrapped into a TorqueException.
1287     */

1288    protected static TableMap getTableMap()
1289        throws TorqueException
1290    {
1291        return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME);
1292    }
1293   
1294    private static void setDbName(Criteria crit)
1295    {
1296        // Set the correct dbName if it has not been overridden
1297
// crit.getDbName will return the same object if not set to
1298
// another value so == check is okay and faster
1299
if (crit.getDbName() == Torque.getDefaultDB())
1300        {
1301            crit.setDbName(DATABASE_NAME);
1302        }
1303    }
1304}
1305
Popular Tags