KickJava   Java API By Example, From Geeks To Geeks.

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


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 BaseMITListItemPeer
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_MIT_LISTITEM";
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(MITListItemMapBuilder.CLASS_NAME);
58     }
59
60       /** the column name for the ITEM_ID field */
61     public static final String JavaDoc ITEM_ID;
62       /** the column name for the MODULE_ID field */
63     public static final String JavaDoc MODULE_ID;
64       /** the column name for the ISSUE_TYPE_ID field */
65     public static final String JavaDoc ISSUE_TYPE_ID;
66       /** the column name for the LIST_ID field */
67     public static final String JavaDoc LIST_ID;
68   
69     static
70     {
71           ITEM_ID = "SCARAB_MIT_LISTITEM.ITEM_ID";
72           MODULE_ID = "SCARAB_MIT_LISTITEM.MODULE_ID";
73           ISSUE_TYPE_ID = "SCARAB_MIT_LISTITEM.ISSUE_TYPE_ID";
74           LIST_ID = "SCARAB_MIT_LISTITEM.LIST_ID";
75           if (Torque.isInit())
76         {
77             try
78             {
79                 getMapBuilder(MITListItemMapBuilder.CLASS_NAME);
80             }
81             catch (Exception JavaDoc e)
82             {
83                 log.error("Could not initialize Peer", e);
84             }
85         }
86         else
87         {
88             Torque.registerMapBuilder(MITListItemMapBuilder.CLASS_NAME);
89         }
90     }
91  
92     /** number of columns for this peer */
93     public static final int numColumns = 4;
94
95     /** A class that can be returned by this peer. */
96     protected static final String JavaDoc CLASSNAME_DEFAULT =
97         "org.tigris.scarab.om.MITListItem";
98
99     /** A class that can be returned by this peer. */
100     protected static final Class JavaDoc CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT);
101
102     /**
103      * Class object initialization method.
104      *
105      * @param className name of the class to initialize
106      * @return the initialized class
107      */

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

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

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

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

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

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

274     public static void populateObject(Record row,
275                                       int offset,
276                                       MITListItem obj)
277         throws TorqueException
278     {
279         try
280         {
281                 obj.setItemId(row.getValue(offset + 0).asLongObj());
282                   obj.setModuleId(row.getValue(offset + 1).asIntegerObj());
283                   obj.setIssueTypeId(row.getValue(offset + 2).asIntegerObj());
284                   obj.setListId(row.getValue(offset + 3).asLongObj());
285               }
286         catch (DataSetException e)
287         {
288             throw new TorqueException(e);
289         }
290     }
291
292     /**
293      * Method to do selects.
294      *
295      * @param criteria object used to create the SELECT statement.
296      * @return List of selected Objects
297      * @throws TorqueException Any exceptions caught during processing will be
298      * rethrown wrapped into a TorqueException.
299      */

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

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

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

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

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

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

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

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

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

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

494     public static List JavaDoc doSelect(MITListItem obj) throws TorqueException
495     {
496         return doSelect(buildSelectCriteria(obj));
497     }
498
499     /**
500      * Method to do inserts
501      *
502      * @throws TorqueException Any exceptions caught during processing will be
503      * rethrown wrapped into a TorqueException.
504      */

505     public static void doInsert(MITListItem obj) throws TorqueException
506     {
507           obj.setPrimaryKey(doInsert(buildCriteria(obj)));
508           obj.setNew(false);
509         obj.setModified(false);
510     }
511
512     /**
513      * @param obj the data object to update in the database.
514      * @throws TorqueException Any exceptions caught during processing will be
515      * rethrown wrapped into a TorqueException.
516      */

517     public static void doUpdate(MITListItem obj) throws TorqueException
518     {
519         doUpdate(buildCriteria(obj));
520         obj.setModified(false);
521     }
522
523     /**
524      * @param obj the data object to delete in the database.
525      * @throws TorqueException Any exceptions caught during processing will be
526      * rethrown wrapped into a TorqueException.
527      */

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

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

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

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

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

607     public static void doDelete(ObjectKey pk, Connection JavaDoc con)
608         throws TorqueException
609     {
610         doDelete(buildCriteria(pk), con);
611     }
612
613     /** Build a Criteria object from an ObjectKey */
614     public static Criteria buildCriteria( ObjectKey pk )
615     {
616         Criteria criteria = new Criteria();
617               criteria.add(ITEM_ID, pk);
618           return criteria;
619      }
620
621     /** Build a Criteria object from the data object for this peer */
622     public static Criteria buildCriteria( MITListItem obj )
623     {
624         Criteria criteria = new Criteria(DATABASE_NAME);
625               if (!obj.isNew())
626             criteria.add(ITEM_ID, obj.getItemId());
627               criteria.add(MODULE_ID, obj.getModuleId());
628               criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId());
629               criteria.add(LIST_ID, obj.getListId());
630           return criteria;
631     }
632
633     /** Build a Criteria object from the data object for this peer, skipping all binary columns */
634     public static Criteria buildSelectCriteria( MITListItem obj )
635     {
636         Criteria criteria = new Criteria(DATABASE_NAME);
637               if (!obj.isNew())
638                     criteria.add(ITEM_ID, obj.getItemId());
639                           criteria.add(MODULE_ID, obj.getModuleId());
640                           criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId());
641                           criteria.add(LIST_ID, obj.getListId());
642               return criteria;
643     }
644  
645     
646         /**
647      * Retrieve a single object by pk
648      *
649      * @param pk the primary key
650      * @throws TorqueException Any exceptions caught during processing will be
651      * rethrown wrapped into a TorqueException.
652      * @throws NoRowsException Primary key was not found in database.
653      * @throws TooManyRowsException Primary key was not found in database.
654      */

655     public static MITListItem retrieveByPK(Long JavaDoc pk)
656         throws TorqueException, NoRowsException, TooManyRowsException
657     {
658         return retrieveByPK(SimpleKey.keyFor(pk));
659     }
660
661     /**
662      * Retrieve a single object by pk
663      *
664      * @param pk the primary key
665      * @param con the connection to use
666      * @throws TorqueException Any exceptions caught during processing will be
667      * rethrown wrapped into a TorqueException.
668      * @throws NoRowsException Primary key was not found in database.
669      * @throws TooManyRowsException Primary key was not found in database.
670      */

671     public static MITListItem retrieveByPK(Long JavaDoc pk, Connection JavaDoc con)
672         throws TorqueException, NoRowsException, TooManyRowsException
673     {
674         return retrieveByPK(SimpleKey.keyFor(pk), con);
675     }
676   
677     /**
678      * Retrieve a single object by pk
679      *
680      * @param pk the primary key
681      * @throws TorqueException Any exceptions caught during processing will be
682      * rethrown wrapped into a TorqueException.
683      * @throws NoRowsException Primary key was not found in database.
684      * @throws TooManyRowsException Primary key was not found in database.
685      */

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

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

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

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

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

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

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

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

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

1192    protected static List JavaDoc doSelectJoinAllExceptIssueType(Criteria criteria)
1193        throws TorqueException
1194    {
1195        setDbName(criteria);
1196
1197        addSelectColumns(criteria);
1198        int offset2 = numColumns + 1;
1199                                    
1200                    MITListPeer.addSelectColumns(criteria);
1201        int offset3 = offset2 + MITListPeer.numColumns;
1202                                                                
1203                    ScarabModulePeer.addSelectColumns(criteria);
1204        int offset4 = offset3 + ScarabModulePeer.numColumns;
1205                                                                
1206                                                                                                              
1207        List JavaDoc rows = BasePeer.doSelect(criteria);
1208        List JavaDoc results = new ArrayList JavaDoc();
1209
1210        for (int i = 0; i < rows.size(); i++)
1211        {
1212            Record row = (Record)rows.get(i);
1213
1214                            Class JavaDoc omClass = MITListItemPeer.getOMClass();
1215                    MITListItem obj1 = (MITListItem)MITListItemPeer
1216                .row2Object(row, 1, omClass);
1217                                                
1218                                                        
1219                            
1220              
1221                           omClass = MITListPeer.getOMClass();
1222                          MITList obj2 = (MITList)MITListPeer
1223                .row2Object( row, offset2, omClass);
1224
1225               boolean newObject = true;
1226            for (int j = 0; j < results.size(); j++)
1227            {
1228                MITListItem temp_obj1 = (MITListItem)results.get(j);
1229                MITList temp_obj2 = (MITList)temp_obj1.getMITList();
1230                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1231                {
1232                    newObject = false;
1233                                    temp_obj2.addMITListItem(obj1);
1234                                    break;
1235                }
1236            }
1237                            if (newObject)
1238            {
1239                obj2.initMITListItems();
1240                obj2.addMITListItem(obj1);
1241            }
1242                                                                                                
1243                                                        
1244                            
1245              
1246                           omClass = ScarabModulePeer.getOMClass(row, offset3);
1247                          ScarabModule obj3 = (ScarabModule)ScarabModulePeer
1248                .row2Object( row, offset3, omClass);
1249
1250               newObject = true;
1251            for (int j = 0; j < results.size(); j++)
1252            {
1253                MITListItem temp_obj1 = (MITListItem)results.get(j);
1254                ScarabModule temp_obj3 = (ScarabModule)temp_obj1.getModule();
1255                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1256                {
1257                    newObject = false;
1258                                    temp_obj3.addMITListItem(obj1);
1259                                    break;
1260                }
1261            }
1262                            if (newObject)
1263            {
1264                obj3.initMITListItems();
1265                obj3.addMITListItem(obj1);
1266            }
1267                                                                                    
1268                                              results.add(obj1);
1269        }
1270        return results;
1271    }
1272                    
1273  
1274      /**
1275     * Returns the TableMap related to this peer. This method is not
1276     * needed for general use but a specific application could have a need.
1277     *
1278     * @throws TorqueException Any exceptions caught during processing will be
1279     * rethrown wrapped into a TorqueException.
1280     */

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