KickJava   Java API By Example, From Geeks To Geeks.

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


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

53     public static MapBuilder getMapBuilder()
54         throws TorqueException
55     {
56         return getMapBuilder(RModuleIssueTypeMapBuilder.CLASS_NAME);
57     }
58
59       /** the column name for the MODULE_ID field */
60     public static final String JavaDoc MODULE_ID;
61       /** the column name for the ISSUE_TYPE_ID field */
62     public static final String JavaDoc ISSUE_TYPE_ID;
63       /** the column name for the ACTIVE field */
64     public static final String JavaDoc ACTIVE;
65       /** the column name for the DISPLAY field */
66     public static final String JavaDoc DISPLAY;
67       /** the column name for the PREFERRED_ORDER field */
68     public static final String JavaDoc PREFERRED_ORDER;
69       /** the column name for the DEDUPE field */
70     public static final String JavaDoc DEDUPE;
71       /** the column name for the HISTORY field */
72     public static final String JavaDoc HISTORY;
73       /** the column name for the COMMENTS field */
74     public static final String JavaDoc COMMENTS;
75       /** the column name for the DISPLAY_NAME field */
76     public static final String JavaDoc DISPLAY_NAME;
77       /** the column name for the DISPLAY_DESCRIPTION field */
78     public static final String JavaDoc DISPLAY_DESCRIPTION;
79   
80     static
81     {
82           MODULE_ID = "SCARAB_R_MODULE_ISSUE_TYPE.MODULE_ID";
83           ISSUE_TYPE_ID = "SCARAB_R_MODULE_ISSUE_TYPE.ISSUE_TYPE_ID";
84           ACTIVE = "SCARAB_R_MODULE_ISSUE_TYPE.ACTIVE";
85           DISPLAY = "SCARAB_R_MODULE_ISSUE_TYPE.DISPLAY";
86           PREFERRED_ORDER = "SCARAB_R_MODULE_ISSUE_TYPE.PREFERRED_ORDER";
87           DEDUPE = "SCARAB_R_MODULE_ISSUE_TYPE.DEDUPE";
88           HISTORY = "SCARAB_R_MODULE_ISSUE_TYPE.HISTORY";
89           COMMENTS = "SCARAB_R_MODULE_ISSUE_TYPE.COMMENTS";
90           DISPLAY_NAME = "SCARAB_R_MODULE_ISSUE_TYPE.DISPLAY_NAME";
91           DISPLAY_DESCRIPTION = "SCARAB_R_MODULE_ISSUE_TYPE.DISPLAY_DESCRIPTION";
92           if (Torque.isInit())
93         {
94             try
95             {
96                 getMapBuilder(RModuleIssueTypeMapBuilder.CLASS_NAME);
97             }
98             catch (Exception JavaDoc e)
99             {
100                 log.error("Could not initialize Peer", e);
101             }
102         }
103         else
104         {
105             Torque.registerMapBuilder(RModuleIssueTypeMapBuilder.CLASS_NAME);
106         }
107     }
108  
109     /** number of columns for this peer */
110     public static final int numColumns = 10;
111
112     /** A class that can be returned by this peer. */
113     protected static final String JavaDoc CLASSNAME_DEFAULT =
114         "org.tigris.scarab.om.RModuleIssueType";
115
116     /** A class that can be returned by this peer. */
117     protected static final Class JavaDoc CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT);
118
119     /**
120      * Class object initialization method.
121      *
122      * @param className name of the class to initialize
123      * @return the initialized class
124      */

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

159     public static List JavaDoc resultSet2Objects(java.sql.ResultSet JavaDoc results)
160             throws TorqueException
161     {
162         try
163         {
164             QueryDataSet qds = null;
165             List JavaDoc rows = null;
166             try
167             {
168                 qds = new QueryDataSet(results);
169                 rows = getSelectResults(qds);
170             }
171             finally
172             {
173                 if (qds != null)
174                 {
175                     qds.close();
176                 }
177             }
178
179             return populateObjects(rows);
180         }
181         catch (SQLException JavaDoc e)
182         {
183             throw new TorqueException(e);
184         }
185         catch (DataSetException e)
186         {
187             throw new TorqueException(e);
188         }
189     }
190
191
192   
193     /**
194      * Method to do inserts.
195      *
196      * @param criteria object used to create the INSERT statement.
197      * @throws TorqueException Any exceptions caught during processing will be
198      * rethrown wrapped into a TorqueException.
199      */

200     public static ObjectKey doInsert(Criteria criteria)
201         throws TorqueException
202     {
203         return BaseRModuleIssueTypePeer
204             .doInsert(criteria, (Connection JavaDoc) null);
205     }
206
207     /**
208      * Method to do inserts. This method is to be used during a transaction,
209      * otherwise use the doInsert(Criteria) method. It will take care of
210      * the connection details internally.
211      *
212      * @param criteria object used to create the INSERT statement.
213      * @param con the connection to use
214      * @throws TorqueException Any exceptions caught during processing will be
215      * rethrown wrapped into a TorqueException.
216      */

217     public static ObjectKey doInsert(Criteria criteria, Connection JavaDoc con)
218         throws TorqueException
219     {
220                           // check for conversion from boolean to int
221
if (criteria.containsKey(ACTIVE))
222         {
223             Object JavaDoc possibleBoolean = criteria.get(ACTIVE);
224             if (possibleBoolean instanceof Boolean JavaDoc)
225             {
226                 criteria.add(ACTIVE, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
227             }
228          }
229                   // check for conversion from boolean to int
230
if (criteria.containsKey(DISPLAY))
231         {
232             Object JavaDoc possibleBoolean = criteria.get(DISPLAY);
233             if (possibleBoolean instanceof Boolean JavaDoc)
234             {
235                 criteria.add(DISPLAY, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
236             }
237          }
238                         // check for conversion from boolean to int
239
if (criteria.containsKey(DEDUPE))
240         {
241             Object JavaDoc possibleBoolean = criteria.get(DEDUPE);
242             if (possibleBoolean instanceof Boolean JavaDoc)
243             {
244                 criteria.add(DEDUPE, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
245             }
246          }
247                               
248         setDbName(criteria);
249
250         if (con == null)
251         {
252             return BasePeer.doInsert(criteria);
253         }
254         else
255         {
256             return BasePeer.doInsert(criteria, con);
257         }
258     }
259
260     /**
261      * Add all the columns needed to create a new object.
262      *
263      * @param criteria object containing the columns to add.
264      * @throws TorqueException Any exceptions caught during processing will be
265      * rethrown wrapped into a TorqueException.
266      */

267     public static void addSelectColumns(Criteria criteria)
268             throws TorqueException
269     {
270           criteria.addSelectColumn(MODULE_ID);
271           criteria.addSelectColumn(ISSUE_TYPE_ID);
272           criteria.addSelectColumn(ACTIVE);
273           criteria.addSelectColumn(DISPLAY);
274           criteria.addSelectColumn(PREFERRED_ORDER);
275           criteria.addSelectColumn(DEDUPE);
276           criteria.addSelectColumn(HISTORY);
277           criteria.addSelectColumn(COMMENTS);
278           criteria.addSelectColumn(DISPLAY_NAME);
279           criteria.addSelectColumn(DISPLAY_DESCRIPTION);
280       }
281
282     /**
283      * Create a new object of type cls from a resultset row starting
284      * from a specified offset. This is done so that you can select
285      * other rows than just those needed for this object. You may
286      * for example want to create two objects from the same row.
287      *
288      * @throws TorqueException Any exceptions caught during processing will be
289      * rethrown wrapped into a TorqueException.
290      */

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

324     public static void populateObject(Record row,
325                                       int offset,
326                                       RModuleIssueType obj)
327         throws TorqueException
328     {
329         try
330         {
331                 obj.setModuleId(row.getValue(offset + 0).asIntegerObj());
332                   obj.setIssueTypeId(row.getValue(offset + 1).asIntegerObj());
333                   obj.setActive(row.getValue(offset + 2).asBoolean());
334                   obj.setDisplay(row.getValue(offset + 3).asBoolean());
335                   obj.setOrder(row.getValue(offset + 4).asInt());
336                   obj.setDedupe(row.getValue(offset + 5).asBoolean());
337                   obj.setHistory(row.getValue(offset + 6).asInt());
338                   obj.setComments(row.getValue(offset + 7).asInt());
339                   obj.setDisplayName(row.getValue(offset + 8).asString());
340                   obj.setDisplayDescription(row.getValue(offset + 9).asString());
341               }
342         catch (DataSetException e)
343         {
344             throw new TorqueException(e);
345         }
346     }
347
348     /**
349      * Method to do selects.
350      *
351      * @param criteria object used to create the SELECT statement.
352      * @return List of selected Objects
353      * @throws TorqueException Any exceptions caught during processing will be
354      * rethrown wrapped into a TorqueException.
355      */

356     public static List JavaDoc doSelect(Criteria criteria) throws TorqueException
357     {
358         return populateObjects(doSelectVillageRecords(criteria));
359     }
360
361     /**
362      * Method to do selects within a transaction.
363      *
364      * @param criteria object used to create the SELECT statement.
365      * @param con the connection to use
366      * @return List of selected Objects
367      * @throws TorqueException Any exceptions caught during processing will be
368      * rethrown wrapped into a TorqueException.
369      */

370     public static List JavaDoc doSelect(Criteria criteria, Connection JavaDoc con)
371         throws TorqueException
372     {
373         return populateObjects(doSelectVillageRecords(criteria, con));
374     }
375
376     /**
377      * Grabs the raw Village records to be formed into objects.
378      * This method handles connections internally. The Record objects
379      * returned by this method should be considered readonly. Do not
380      * alter the data and call save(), your results may vary, but are
381      * certainly likely to result in hard to track MT bugs.
382      *
383      * @throws TorqueException Any exceptions caught during processing will be
384      * rethrown wrapped into a TorqueException.
385      */

386     public static List JavaDoc doSelectVillageRecords(Criteria criteria)
387         throws TorqueException
388     {
389         return BaseRModuleIssueTypePeer
390             .doSelectVillageRecords(criteria, (Connection JavaDoc) null);
391     }
392
393     /**
394      * Grabs the raw Village records to be formed into objects.
395      * This method should be used for transactions
396      *
397      * @param criteria object used to create the SELECT statement.
398      * @param con the connection to use
399      * @throws TorqueException Any exceptions caught during processing will be
400      * rethrown wrapped into a TorqueException.
401      */

402     public static List JavaDoc doSelectVillageRecords(Criteria criteria, Connection JavaDoc con)
403         throws TorqueException
404     {
405         if (criteria.getSelectColumns().size() == 0)
406         {
407             addSelectColumns(criteria);
408         }
409
410                           // check for conversion from boolean to int
411
if (criteria.containsKey(ACTIVE))
412         {
413             Object JavaDoc possibleBoolean = criteria.get(ACTIVE);
414             if (possibleBoolean instanceof Boolean JavaDoc)
415             {
416                 criteria.add(ACTIVE, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
417             }
418          }
419                   // check for conversion from boolean to int
420
if (criteria.containsKey(DISPLAY))
421         {
422             Object JavaDoc possibleBoolean = criteria.get(DISPLAY);
423             if (possibleBoolean instanceof Boolean JavaDoc)
424             {
425                 criteria.add(DISPLAY, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
426             }
427          }
428                         // check for conversion from boolean to int
429
if (criteria.containsKey(DEDUPE))
430         {
431             Object JavaDoc possibleBoolean = criteria.get(DEDUPE);
432             if (possibleBoolean instanceof Boolean JavaDoc)
433             {
434                 criteria.add(DEDUPE, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
435             }
436          }
437                               
438         setDbName(criteria);
439
440         // BasePeer returns a List of Value (Village) arrays. The array
441
// order follows the order columns were placed in the Select clause.
442
if (con == null)
443         {
444             return BasePeer.doSelect(criteria);
445         }
446         else
447         {
448             return BasePeer.doSelect(criteria, con);
449         }
450     }
451
452     /**
453      * The returned List will contain objects of the default type or
454      * objects that inherit from the default.
455      *
456      * @throws TorqueException Any exceptions caught during processing will be
457      * rethrown wrapped into a TorqueException.
458      */

459     public static List JavaDoc populateObjects(List JavaDoc records)
460         throws TorqueException
461     {
462         List JavaDoc results = new ArrayList JavaDoc(records.size());
463
464         // populate the object(s)
465
for (int i = 0; i < records.size(); i++)
466         {
467             Record row = (Record) records.get(i);
468               results.add(RModuleIssueTypePeer.row2Object(row, 1,
469                 RModuleIssueTypePeer.getOMClass()));
470           }
471         return results;
472     }
473  
474
475     /**
476      * The class that the Peer will make instances of.
477      * If the BO is abstract then you must implement this method
478      * in the BO.
479      *
480      * @throws TorqueException Any exceptions caught during processing will be
481      * rethrown wrapped into a TorqueException.
482      */

483     public static Class JavaDoc getOMClass()
484         throws TorqueException
485     {
486         return CLASS_DEFAULT;
487     }
488
489     /**
490      * Method to do updates.
491      *
492      * @param criteria object containing data that is used to create the UPDATE
493      * statement.
494      * @throws TorqueException Any exceptions caught during processing will be
495      * rethrown wrapped into a TorqueException.
496      */

497     public static void doUpdate(Criteria criteria) throws TorqueException
498     {
499          BaseRModuleIssueTypePeer
500             .doUpdate(criteria, (Connection JavaDoc) null);
501     }
502
503     /**
504      * Method to do updates. This method is to be used during a transaction,
505      * otherwise use the doUpdate(Criteria) method. It will take care of
506      * the connection details internally.
507      *
508      * @param criteria object containing data that is used to create the UPDATE
509      * statement.
510      * @param con the connection to use
511      * @throws TorqueException Any exceptions caught during processing will be
512      * rethrown wrapped into a TorqueException.
513      */

514     public static void doUpdate(Criteria criteria, Connection JavaDoc con)
515         throws TorqueException
516     {
517         Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
518                    selectCriteria.put(MODULE_ID, criteria.remove(MODULE_ID));
519                        selectCriteria.put(ISSUE_TYPE_ID, criteria.remove(ISSUE_TYPE_ID));
520                   // check for conversion from boolean to int
521
if (criteria.containsKey(ACTIVE))
522         {
523             Object JavaDoc possibleBoolean = criteria.get(ACTIVE);
524             if (possibleBoolean instanceof Boolean JavaDoc)
525             {
526                 criteria.add(ACTIVE, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
527             }
528          }
529                       // check for conversion from boolean to int
530
if (criteria.containsKey(DISPLAY))
531         {
532             Object JavaDoc possibleBoolean = criteria.get(DISPLAY);
533             if (possibleBoolean instanceof Boolean JavaDoc)
534             {
535                 criteria.add(DISPLAY, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
536             }
537          }
538                                 // check for conversion from boolean to int
539
if (criteria.containsKey(DEDUPE))
540         {
541             Object JavaDoc possibleBoolean = criteria.get(DEDUPE);
542             if (possibleBoolean instanceof Boolean JavaDoc)
543             {
544                 criteria.add(DEDUPE, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
545             }
546          }
547                                                   
548         setDbName(criteria);
549
550         if (con == null)
551         {
552             BasePeer.doUpdate(selectCriteria, criteria);
553         }
554         else
555         {
556             BasePeer.doUpdate(selectCriteria, criteria, con);
557         }
558     }
559
560     /**
561      * Method to do deletes.
562      *
563      * @param criteria object containing data that is used DELETE from database.
564      * @throws TorqueException Any exceptions caught during processing will be
565      * rethrown wrapped into a TorqueException.
566      */

567      public static void doDelete(Criteria criteria) throws TorqueException
568      {
569          RModuleIssueTypePeer
570             .doDelete(criteria, (Connection JavaDoc) null);
571      }
572
573     /**
574      * Method to do deletes. This method is to be used during a transaction,
575      * otherwise use the doDelete(Criteria) method. It will take care of
576      * the connection details internally.
577      *
578      * @param criteria object containing data that is used DELETE from 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(Criteria criteria, Connection JavaDoc con)
584         throws TorqueException
585      {
586                           // check for conversion from boolean to int
587
if (criteria.containsKey(ACTIVE))
588         {
589             Object JavaDoc possibleBoolean = criteria.get(ACTIVE);
590             if (possibleBoolean instanceof Boolean JavaDoc)
591             {
592                 criteria.add(ACTIVE, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
593             }
594          }
595                   // check for conversion from boolean to int
596
if (criteria.containsKey(DISPLAY))
597         {
598             Object JavaDoc possibleBoolean = criteria.get(DISPLAY);
599             if (possibleBoolean instanceof Boolean JavaDoc)
600             {
601                 criteria.add(DISPLAY, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
602             }
603          }
604                         // check for conversion from boolean to int
605
if (criteria.containsKey(DEDUPE))
606         {
607             Object JavaDoc possibleBoolean = criteria.get(DEDUPE);
608             if (possibleBoolean instanceof Boolean JavaDoc)
609             {
610                 criteria.add(DEDUPE, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
611             }
612          }
613                               
614         setDbName(criteria);
615
616         if (con == null)
617         {
618             BasePeer.doDelete(criteria);
619         }
620         else
621         {
622             BasePeer.doDelete(criteria, con);
623         }
624      }
625
626     /**
627      * Method to do selects
628      *
629      * @throws TorqueException Any exceptions caught during processing will be
630      * rethrown wrapped into a TorqueException.
631      */

632     public static List JavaDoc doSelect(RModuleIssueType obj) throws TorqueException
633     {
634         return doSelect(buildSelectCriteria(obj));
635     }
636
637     /**
638      * Method to do inserts
639      *
640      * @throws TorqueException Any exceptions caught during processing will be
641      * rethrown wrapped into a TorqueException.
642      */

643     public static void doInsert(RModuleIssueType obj) throws TorqueException
644     {
645           doInsert(buildCriteria(obj));
646           obj.setNew(false);
647         obj.setModified(false);
648     }
649
650     /**
651      * @param obj the data object to update in the database.
652      * @throws TorqueException Any exceptions caught during processing will be
653      * rethrown wrapped into a TorqueException.
654      */

655     public static void doUpdate(RModuleIssueType obj) throws TorqueException
656     {
657         doUpdate(buildCriteria(obj));
658         obj.setModified(false);
659     }
660
661     /**
662      * @param obj the data object to delete in the database.
663      * @throws TorqueException Any exceptions caught during processing will be
664      * rethrown wrapped into a TorqueException.
665      */

666     public static void doDelete(RModuleIssueType obj) throws TorqueException
667     {
668         doDelete(buildSelectCriteria(obj));
669     }
670
671     /**
672      * Method to do inserts. This method is to be used during a transaction,
673      * otherwise use the doInsert(RModuleIssueType) method. It will take
674      * care of the connection details internally.
675      *
676      * @param obj the data object to insert into the database.
677      * @param con the connection to use
678      * @throws TorqueException Any exceptions caught during processing will be
679      * rethrown wrapped into a TorqueException.
680      */

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

699     public static void doUpdate(RModuleIssueType obj, Connection JavaDoc con)
700         throws TorqueException
701     {
702         doUpdate(buildCriteria(obj), con);
703         obj.setModified(false);
704     }
705
706     /**
707      * Method to delete. This method is to be used during a transaction,
708      * otherwise use the doDelete(RModuleIssueType) method. It will take
709      * care of the connection details internally.
710      *
711      * @param obj the data object to delete in the database.
712      * @param con the connection to use
713      * @throws TorqueException Any exceptions caught during processing will be
714      * rethrown wrapped into a TorqueException.
715      */

716     public static void doDelete(RModuleIssueType obj, Connection JavaDoc con)
717         throws TorqueException
718     {
719         doDelete(buildSelectCriteria(obj), con);
720     }
721
722     /**
723      * Method to do deletes.
724      *
725      * @param pk ObjectKey that is used DELETE from database.
726      * @throws TorqueException Any exceptions caught during processing will be
727      * rethrown wrapped into a TorqueException.
728      */

729     public static void doDelete(ObjectKey pk) throws TorqueException
730     {
731         BaseRModuleIssueTypePeer
732            .doDelete(pk, (Connection JavaDoc) null);
733     }
734
735     /**
736      * Method to delete. This method is to be used during a transaction,
737      * otherwise use the doDelete(ObjectKey) method. It will take
738      * care of the connection details internally.
739      *
740      * @param pk the primary key for the object to delete in the database.
741      * @param con the connection to use
742      * @throws TorqueException Any exceptions caught during processing will be
743      * rethrown wrapped into a TorqueException.
744      */

745     public static void doDelete(ObjectKey pk, Connection JavaDoc con)
746         throws TorqueException
747     {
748         doDelete(buildCriteria(pk), con);
749     }
750
751     /** Build a Criteria object from an ObjectKey */
752     public static Criteria buildCriteria( ObjectKey pk )
753     {
754         Criteria criteria = new Criteria();
755           SimpleKey[] keys = (SimpleKey[])pk.getValue();
756                     criteria.add(MODULE_ID, keys[0]);
757                       criteria.add(ISSUE_TYPE_ID, keys[1]);
758                     return criteria;
759      }
760
761     /** Build a Criteria object from the data object for this peer */
762     public static Criteria buildCriteria( RModuleIssueType obj )
763     {
764         Criteria criteria = new Criteria(DATABASE_NAME);
765               criteria.add(MODULE_ID, obj.getModuleId());
766               criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId());
767               criteria.add(ACTIVE, obj.getActive());
768               criteria.add(DISPLAY, obj.getDisplay());
769               criteria.add(PREFERRED_ORDER, obj.getOrder());
770               criteria.add(DEDUPE, obj.getDedupe());
771               criteria.add(HISTORY, obj.getHistory());
772               criteria.add(COMMENTS, obj.getComments());
773               criteria.add(DISPLAY_NAME, obj.getDisplayName());
774               criteria.add(DISPLAY_DESCRIPTION, obj.getDisplayDescription());
775           return criteria;
776     }
777
778     /** Build a Criteria object from the data object for this peer, skipping all binary columns */
779     public static Criteria buildSelectCriteria( RModuleIssueType obj )
780     {
781         Criteria criteria = new Criteria(DATABASE_NAME);
782                       criteria.add(MODULE_ID, obj.getModuleId());
783                           criteria.add(ISSUE_TYPE_ID, obj.getIssueTypeId());
784                           criteria.add(ACTIVE, obj.getActive());
785                           criteria.add(DISPLAY, obj.getDisplay());
786                           criteria.add(PREFERRED_ORDER, obj.getOrder());
787                           criteria.add(DEDUPE, obj.getDedupe());
788                           criteria.add(HISTORY, obj.getHistory());
789                           criteria.add(COMMENTS, obj.getComments());
790                           criteria.add(DISPLAY_NAME, obj.getDisplayName());
791                           criteria.add(DISPLAY_DESCRIPTION, obj.getDisplayDescription());
792               return criteria;
793     }
794  
795     
796     
797     /**
798      * Retrieve a single object by pk
799      *
800      * @param pk the primary key
801      * @throws TorqueException Any exceptions caught during processing will be
802      * rethrown wrapped into a TorqueException.
803      * @throws NoRowsException Primary key was not found in database.
804      * @throws TooManyRowsException Primary key was not found in database.
805      */

806     public static RModuleIssueType retrieveByPK(ObjectKey pk)
807         throws TorqueException, NoRowsException, TooManyRowsException
808     {
809         Connection JavaDoc db = null;
810         RModuleIssueType retVal = null;
811         try
812         {
813             db = Torque.getConnection(DATABASE_NAME);
814             retVal = retrieveByPK(pk, db);
815         }
816         finally
817         {
818             Torque.closeConnection(db);
819         }
820         return(retVal);
821     }
822
823     /**
824      * Retrieve a single object by pk
825      *
826      * @param pk the primary key
827      * @param con the connection to use
828      * @throws TorqueException Any exceptions caught during processing will be
829      * rethrown wrapped into a TorqueException.
830      * @throws NoRowsException Primary key was not found in database.
831      * @throws TooManyRowsException Primary key was not found in database.
832      */

833     public static RModuleIssueType retrieveByPK(ObjectKey pk, Connection JavaDoc con)
834         throws TorqueException, NoRowsException, TooManyRowsException
835     {
836         Criteria criteria = buildCriteria(pk);
837         List JavaDoc v = doSelect(criteria, con);
838         if (v.size() == 0)
839         {
840             throw new NoRowsException("Failed to select a row.");
841         }
842         else if (v.size() > 1)
843         {
844             throw new TooManyRowsException("Failed to select only one row.");
845         }
846         else
847         {
848             return (RModuleIssueType)v.get(0);
849         }
850     }
851
852     /**
853      * Retrieve a multiple objects by pk
854      *
855      * @param pks List of primary keys
856      * @throws TorqueException Any exceptions caught during processing will be
857      * rethrown wrapped into a TorqueException.
858      */

859     public static List JavaDoc retrieveByPKs(List JavaDoc pks)
860         throws TorqueException
861     {
862         Connection JavaDoc db = null;
863         List JavaDoc retVal = null;
864         try
865         {
866            db = Torque.getConnection(DATABASE_NAME);
867            retVal = retrieveByPKs(pks, db);
868         }
869         finally
870         {
871             Torque.closeConnection(db);
872         }
873         return(retVal);
874     }
875
876     /**
877      * Retrieve a multiple objects by pk
878      *
879      * @param pks List of primary keys
880      * @param dbcon the connection to use
881      * @throws TorqueException Any exceptions caught during processing will be
882      * rethrown wrapped into a TorqueException.
883      */

884     public static List JavaDoc retrieveByPKs( List JavaDoc pks, Connection JavaDoc dbcon )
885         throws TorqueException
886     {
887         List JavaDoc objs = null;
888         if (pks == null || pks.size() == 0)
889         {
890             objs = new LinkedList JavaDoc();
891         }
892         else
893         {
894             Criteria criteria = new Criteria();
895               Iterator JavaDoc iter = pks.iterator();
896             while (iter.hasNext())
897             {
898                 ObjectKey pk = (ObjectKey)iter.next();
899                 SimpleKey[] keys = (SimpleKey[])pk.getValue();
900                             Criteria.Criterion c0 = criteria.getNewCriterion(
901                         MODULE_ID, keys[0], Criteria.EQUAL);
902                                     Criteria.Criterion c1 = criteria.getNewCriterion(
903                         ISSUE_TYPE_ID, keys[1], Criteria.EQUAL);
904                                     c0.and(c1);
905                           criteria.or(c0);
906             }
907           objs = doSelect(criteria, dbcon);
908         }
909         return objs;
910     }
911
912  
913     /**
914      * retrieve object using using pk values.
915      *
916        * @param module_id Integer
917        * @param issue_type_id Integer
918        */

919     public static RModuleIssueType retrieveByPK(
920        Integer JavaDoc module_id
921           , Integer JavaDoc issue_type_id
922               ) throws TorqueException
923     {
924         Connection JavaDoc db = null;
925         RModuleIssueType retVal = null;
926         try
927         {
928            db = Torque.getConnection(DATABASE_NAME);
929            retVal = retrieveByPK(
930          module_id
931           , issue_type_id
932                      , db);
933         }
934         finally
935         {
936             Torque.closeConnection(db);
937         }
938         return(retVal);
939     }
940
941       /**
942      * retrieve object using using pk values.
943      *
944        * @param module_id Integer
945        * @param issue_type_id Integer
946        * @param con Connection
947      */

948     public static RModuleIssueType retrieveByPK(
949        Integer JavaDoc module_id
950           , Integer JavaDoc issue_type_id
951              ,Connection JavaDoc con) throws TorqueException
952     {
953
954         Criteria criteria = new Criteria(5);
955           criteria.add(MODULE_ID, module_id);
956           criteria.add(ISSUE_TYPE_ID, issue_type_id);
957           List JavaDoc v = doSelect(criteria, con);
958         if (v.size() != 1)
959         {
960             throw new TorqueException("Failed to select one and only one row.");
961         }
962         else
963         {
964             return (RModuleIssueType) v.get(0);
965         }
966     }
967
968
969
970             
971                                               
972                         
973                 
974
975     /**
976      * selects a collection of RModuleIssueType objects pre-filled with their
977      * ScarabModule objects.
978      *
979      * This method is protected by default in order to keep the public
980      * api reasonable. You can provide public methods for those you
981      * actually need in RModuleIssueTypePeer.
982      *
983      * @throws TorqueException Any exceptions caught during processing will be
984      * rethrown wrapped into a TorqueException.
985      */

986     protected static List JavaDoc doSelectJoinScarabModule(Criteria criteria)
987         throws TorqueException
988     {
989         setDbName(criteria);
990
991         RModuleIssueTypePeer.addSelectColumns(criteria);
992         int offset = numColumns + 1;
993         ScarabModulePeer.addSelectColumns(criteria);
994
995
996                         criteria.addJoin(RModuleIssueTypePeer.MODULE_ID,
997             ScarabModulePeer.MODULE_ID);
998         
999
1000                                                              // check for conversion from boolean to int
1001
if (criteria.containsKey(ACTIVE))
1002        {
1003            Object JavaDoc possibleBoolean = criteria.get(ACTIVE);
1004            if (possibleBoolean instanceof Boolean JavaDoc)
1005            {
1006                criteria.add(ACTIVE, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1007            }
1008         }
1009                                    // check for conversion from boolean to int
1010
if (criteria.containsKey(DISPLAY))
1011        {
1012            Object JavaDoc possibleBoolean = criteria.get(DISPLAY);
1013            if (possibleBoolean instanceof Boolean JavaDoc)
1014            {
1015                criteria.add(DISPLAY, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1016            }
1017         }
1018                                                      // check for conversion from boolean to int
1019
if (criteria.containsKey(DEDUPE))
1020        {
1021            Object JavaDoc possibleBoolean = criteria.get(DEDUPE);
1022            if (possibleBoolean instanceof Boolean JavaDoc)
1023            {
1024                criteria.add(DEDUPE, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1025            }
1026         }
1027                                                                                          
1028        List JavaDoc rows = BasePeer.doSelect(criteria);
1029        List JavaDoc results = new ArrayList JavaDoc();
1030
1031        for (int i = 0; i < rows.size(); i++)
1032        {
1033            Record row = (Record) rows.get(i);
1034
1035                            Class JavaDoc omClass = RModuleIssueTypePeer.getOMClass();
1036                    RModuleIssueType obj1 = (RModuleIssueType) RModuleIssueTypePeer
1037                .row2Object(row, 1, omClass);
1038                     omClass = ScarabModulePeer.getOMClass(row, offset);
1039                    ScarabModule obj2 = (ScarabModule)ScarabModulePeer
1040                .row2Object(row, offset, omClass);
1041
1042            boolean newObject = true;
1043            for (int j = 0; j < results.size(); j++)
1044            {
1045                RModuleIssueType temp_obj1 = (RModuleIssueType)results.get(j);
1046                ScarabModule temp_obj2 = (ScarabModule)temp_obj1.getModule();
1047                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1048                {
1049                    newObject = false;
1050                              temp_obj2.addRModuleIssueType(obj1);
1051                              break;
1052                }
1053            }
1054                      if (newObject)
1055            {
1056                obj2.initRModuleIssueTypes();
1057                obj2.addRModuleIssueType(obj1);
1058            }
1059                      results.add(obj1);
1060        }
1061        return results;
1062    }
1063                                                            
1064                
1065                
1066
1067    /**
1068     * selects a collection of RModuleIssueType objects pre-filled with their
1069     * IssueType objects.
1070     *
1071     * This method is protected by default in order to keep the public
1072     * api reasonable. You can provide public methods for those you
1073     * actually need in RModuleIssueTypePeer.
1074     *
1075     * @throws TorqueException Any exceptions caught during processing will be
1076     * rethrown wrapped into a TorqueException.
1077     */

1078    protected static List JavaDoc doSelectJoinIssueType(Criteria criteria)
1079        throws TorqueException
1080    {
1081        setDbName(criteria);
1082
1083        RModuleIssueTypePeer.addSelectColumns(criteria);
1084        int offset = numColumns + 1;
1085        IssueTypePeer.addSelectColumns(criteria);
1086
1087
1088                        criteria.addJoin(RModuleIssueTypePeer.ISSUE_TYPE_ID,
1089            IssueTypePeer.ISSUE_TYPE_ID);
1090        
1091
1092                                                              // check for conversion from boolean to int
1093
if (criteria.containsKey(ACTIVE))
1094        {
1095            Object JavaDoc possibleBoolean = criteria.get(ACTIVE);
1096            if (possibleBoolean instanceof Boolean JavaDoc)
1097            {
1098                criteria.add(ACTIVE, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1099            }
1100         }
1101                                    // check for conversion from boolean to int
1102
if (criteria.containsKey(DISPLAY))
1103        {
1104            Object JavaDoc possibleBoolean = criteria.get(DISPLAY);
1105            if (possibleBoolean instanceof Boolean JavaDoc)
1106            {
1107                criteria.add(DISPLAY, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1108            }
1109         }
1110                                                      // check for conversion from boolean to int
1111
if (criteria.containsKey(DEDUPE))
1112        {
1113            Object JavaDoc possibleBoolean = criteria.get(DEDUPE);
1114            if (possibleBoolean instanceof Boolean JavaDoc)
1115            {
1116                criteria.add(DEDUPE, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1117            }
1118         }
1119                                                                                          
1120        List JavaDoc rows = BasePeer.doSelect(criteria);
1121        List JavaDoc results = new ArrayList JavaDoc();
1122
1123        for (int i = 0; i < rows.size(); i++)
1124        {
1125            Record row = (Record) rows.get(i);
1126
1127                            Class JavaDoc omClass = RModuleIssueTypePeer.getOMClass();
1128                    RModuleIssueType obj1 = (RModuleIssueType) RModuleIssueTypePeer
1129                .row2Object(row, 1, omClass);
1130                     omClass = IssueTypePeer.getOMClass();
1131                    IssueType obj2 = (IssueType)IssueTypePeer
1132                .row2Object(row, offset, omClass);
1133
1134            boolean newObject = true;
1135            for (int j = 0; j < results.size(); j++)
1136            {
1137                RModuleIssueType temp_obj1 = (RModuleIssueType)results.get(j);
1138                IssueType temp_obj2 = (IssueType)temp_obj1.getIssueType();
1139                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1140                {
1141                    newObject = false;
1142                              temp_obj2.addRModuleIssueType(obj1);
1143                              break;
1144                }
1145            }
1146                      if (newObject)
1147            {
1148                obj2.initRModuleIssueTypes();
1149                obj2.addRModuleIssueType(obj1);
1150            }
1151                      results.add(obj1);
1152        }
1153        return results;
1154    }
1155                    
1156  
1157    
1158  
1159      /**
1160     * Returns the TableMap related to this peer. This method is not
1161     * needed for general use but a specific application could have a need.
1162     *
1163     * @throws TorqueException Any exceptions caught during processing will be
1164     * rethrown wrapped into a TorqueException.
1165     */

1166    protected static TableMap getTableMap()
1167        throws TorqueException
1168    {
1169        return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME);
1170    }
1171   
1172    private static void setDbName(Criteria crit)
1173    {
1174        // Set the correct dbName if it has not been overridden
1175
// crit.getDbName will return the same object if not set to
1176
// another value so == check is okay and faster
1177
if (crit.getDbName() == Torque.getDefaultDB())
1178        {
1179            crit.setDbName(DATABASE_NAME);
1180        }
1181    }
1182}
1183
Popular Tags