KickJava   Java API By Example, From Geeks To Geeks.

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


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 BaseIssuePeer
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_ISSUE";
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(IssueMapBuilder.CLASS_NAME);
58     }
59
60       /** the column name for the ISSUE_ID field */
61     public static final String JavaDoc ISSUE_ID;
62       /** the column name for the ID_PREFIX field */
63     public static final String JavaDoc ID_PREFIX;
64       /** the column name for the ID_COUNT field */
65     public static final String JavaDoc ID_COUNT;
66       /** the column name for the ID_DOMAIN field */
67     public static final String JavaDoc ID_DOMAIN;
68       /** the column name for the TYPE_ID field */
69     public static final String JavaDoc TYPE_ID;
70       /** the column name for the MODULE_ID field */
71     public static final String JavaDoc MODULE_ID;
72       /** the column name for the CREATED_TRANS_ID field */
73     public static final String JavaDoc CREATED_TRANS_ID;
74       /** the column name for the DELETED field */
75     public static final String JavaDoc DELETED;
76   
77     static
78     {
79           ISSUE_ID = "SCARAB_ISSUE.ISSUE_ID";
80           ID_PREFIX = "SCARAB_ISSUE.ID_PREFIX";
81           ID_COUNT = "SCARAB_ISSUE.ID_COUNT";
82           ID_DOMAIN = "SCARAB_ISSUE.ID_DOMAIN";
83           TYPE_ID = "SCARAB_ISSUE.TYPE_ID";
84           MODULE_ID = "SCARAB_ISSUE.MODULE_ID";
85           CREATED_TRANS_ID = "SCARAB_ISSUE.CREATED_TRANS_ID";
86           DELETED = "SCARAB_ISSUE.DELETED";
87           if (Torque.isInit())
88         {
89             try
90             {
91                 getMapBuilder(IssueMapBuilder.CLASS_NAME);
92             }
93             catch (Exception JavaDoc e)
94             {
95                 log.error("Could not initialize Peer", e);
96             }
97         }
98         else
99         {
100             Torque.registerMapBuilder(IssueMapBuilder.CLASS_NAME);
101         }
102     }
103  
104     /** number of columns for this peer */
105     public static final int numColumns = 8;
106
107     /** A class that can be returned by this peer. */
108     protected static final String JavaDoc CLASSNAME_DEFAULT =
109         "org.tigris.scarab.om.Issue";
110
111     /** A class that can be returned by this peer. */
112     protected static final Class JavaDoc CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT);
113
114     /**
115      * Class object initialization method.
116      *
117      * @param className name of the class to initialize
118      * @return the initialized class
119      */

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

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

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

212     public static ObjectKey doInsert(Criteria criteria, Connection JavaDoc con)
213         throws TorqueException
214     {
215                                                         // check for conversion from boolean to int
216
if (criteria.containsKey(DELETED))
217         {
218             Object JavaDoc possibleBoolean = criteria.get(DELETED);
219             if (possibleBoolean instanceof Boolean JavaDoc)
220             {
221                 criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
222             }
223          }
224       
225         setDbName(criteria);
226
227         if (con == null)
228         {
229             return BasePeer.doInsert(criteria);
230         }
231         else
232         {
233             return BasePeer.doInsert(criteria, con);
234         }
235     }
236
237     /**
238      * Add all the columns needed to create a new object.
239      *
240      * @param criteria object containing the columns to add.
241      * @throws TorqueException Any exceptions caught during processing will be
242      * rethrown wrapped into a TorqueException.
243      */

244     public static void addSelectColumns(Criteria criteria)
245             throws TorqueException
246     {
247           criteria.addSelectColumn(ISSUE_ID);
248           criteria.addSelectColumn(ID_PREFIX);
249           criteria.addSelectColumn(ID_COUNT);
250           criteria.addSelectColumn(ID_DOMAIN);
251           criteria.addSelectColumn(TYPE_ID);
252           criteria.addSelectColumn(MODULE_ID);
253           criteria.addSelectColumn(CREATED_TRANS_ID);
254           criteria.addSelectColumn(DELETED);
255       }
256
257     /**
258      * Create a new object of type cls from a resultset row starting
259      * from a specified offset. This is done so that you can select
260      * other rows than just those needed for this object. You may
261      * for example want to create two objects from the same row.
262      *
263      * @throws TorqueException Any exceptions caught during processing will be
264      * rethrown wrapped into a TorqueException.
265      */

266     public static Issue row2Object(Record row,
267                                              int offset,
268                                              Class JavaDoc cls)
269         throws TorqueException
270     {
271         try
272         {
273             Issue obj = (Issue) cls.newInstance();
274             IssuePeer.populateObject(row, offset, obj);
275                   obj.setModified(false);
276               obj.setNew(false);
277
278             return obj;
279         }
280         catch (InstantiationException JavaDoc e)
281         {
282             throw new TorqueException(e);
283         }
284         catch (IllegalAccessException JavaDoc e)
285         {
286             throw new TorqueException(e);
287         }
288     }
289
290     /**
291      * Populates an object from a resultset row starting
292      * from a specified offset. This is done so that you can select
293      * other rows than just those needed for this object. You may
294      * for example want to create two objects from the same row.
295      *
296      * @throws TorqueException Any exceptions caught during processing will be
297      * rethrown wrapped into a TorqueException.
298      */

299     public static void populateObject(Record row,
300                                       int offset,
301                                       Issue obj)
302         throws TorqueException
303     {
304         try
305         {
306                 obj.setIssueId(row.getValue(offset + 0).asLongObj());
307                   obj.setIdPrefix(row.getValue(offset + 1).asString());
308                   obj.setIdCount(row.getValue(offset + 2).asInt());
309                   obj.setIdDomain(row.getValue(offset + 3).asString());
310                   obj.setTypeId(row.getValue(offset + 4).asIntegerObj());
311                   obj.setModuleId(row.getValue(offset + 5).asIntegerObj());
312                   obj.setCreatedTransId(row.getValue(offset + 6).asLongObj());
313                   obj.setDeleted(row.getValue(offset + 7).asBoolean());
314               }
315         catch (DataSetException e)
316         {
317             throw new TorqueException(e);
318         }
319     }
320
321     /**
322      * Method to do selects.
323      *
324      * @param criteria object used to create the SELECT statement.
325      * @return List of selected Objects
326      * @throws TorqueException Any exceptions caught during processing will be
327      * rethrown wrapped into a TorqueException.
328      */

329     public static List JavaDoc doSelect(Criteria criteria) throws TorqueException
330     {
331         return populateObjects(doSelectVillageRecords(criteria));
332     }
333
334     /**
335      * Method to do selects within a transaction.
336      *
337      * @param criteria object used to create the SELECT statement.
338      * @param con the connection to use
339      * @return List of selected Objects
340      * @throws TorqueException Any exceptions caught during processing will be
341      * rethrown wrapped into a TorqueException.
342      */

343     public static List JavaDoc doSelect(Criteria criteria, Connection JavaDoc con)
344         throws TorqueException
345     {
346         return populateObjects(doSelectVillageRecords(criteria, con));
347     }
348
349     /**
350      * Grabs the raw Village records to be formed into objects.
351      * This method handles connections internally. The Record objects
352      * returned by this method should be considered readonly. Do not
353      * alter the data and call save(), your results may vary, but are
354      * certainly likely to result in hard to track MT bugs.
355      *
356      * @throws TorqueException Any exceptions caught during processing will be
357      * rethrown wrapped into a TorqueException.
358      */

359     public static List JavaDoc doSelectVillageRecords(Criteria criteria)
360         throws TorqueException
361     {
362         return BaseIssuePeer
363             .doSelectVillageRecords(criteria, (Connection JavaDoc) null);
364     }
365
366     /**
367      * Grabs the raw Village records to be formed into objects.
368      * This method should be used for transactions
369      *
370      * @param criteria object used to create the SELECT statement.
371      * @param con the connection to use
372      * @throws TorqueException Any exceptions caught during processing will be
373      * rethrown wrapped into a TorqueException.
374      */

375     public static List JavaDoc doSelectVillageRecords(Criteria criteria, Connection JavaDoc con)
376         throws TorqueException
377     {
378         if (criteria.getSelectColumns().size() == 0)
379         {
380             addSelectColumns(criteria);
381         }
382
383                                                         // check for conversion from boolean to int
384
if (criteria.containsKey(DELETED))
385         {
386             Object JavaDoc possibleBoolean = criteria.get(DELETED);
387             if (possibleBoolean instanceof Boolean JavaDoc)
388             {
389                 criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
390             }
391          }
392       
393         setDbName(criteria);
394
395         // BasePeer returns a List of Value (Village) arrays. The array
396
// order follows the order columns were placed in the Select clause.
397
if (con == null)
398         {
399             return BasePeer.doSelect(criteria);
400         }
401         else
402         {
403             return BasePeer.doSelect(criteria, con);
404         }
405     }
406
407     /**
408      * The returned List will contain objects of the default type or
409      * objects that inherit from the default.
410      *
411      * @throws TorqueException Any exceptions caught during processing will be
412      * rethrown wrapped into a TorqueException.
413      */

414     public static List JavaDoc populateObjects(List JavaDoc records)
415         throws TorqueException
416     {
417         List JavaDoc results = new ArrayList JavaDoc(records.size());
418
419         // populate the object(s)
420
for (int i = 0; i < records.size(); i++)
421         {
422             Record row = (Record) records.get(i);
423               results.add(IssuePeer.row2Object(row, 1,
424                 IssuePeer.getOMClass()));
425           }
426         return results;
427     }
428  
429
430     /**
431      * The class that the Peer will make instances of.
432      * If the BO is abstract then you must implement this method
433      * in the BO.
434      *
435      * @throws TorqueException Any exceptions caught during processing will be
436      * rethrown wrapped into a TorqueException.
437      */

438     public static Class JavaDoc getOMClass()
439         throws TorqueException
440     {
441         return CLASS_DEFAULT;
442     }
443
444     /**
445      * Method to do updates.
446      *
447      * @param criteria object containing data that is used to create the UPDATE
448      * statement.
449      * @throws TorqueException Any exceptions caught during processing will be
450      * rethrown wrapped into a TorqueException.
451      */

452     public static void doUpdate(Criteria criteria) throws TorqueException
453     {
454          BaseIssuePeer
455             .doUpdate(criteria, (Connection JavaDoc) null);
456     }
457
458     /**
459      * Method to do updates. This method is to be used during a transaction,
460      * otherwise use the doUpdate(Criteria) method. It will take care of
461      * the connection details internally.
462      *
463      * @param criteria object containing data that is used to create the UPDATE
464      * statement.
465      * @param con the connection to use
466      * @throws TorqueException Any exceptions caught during processing will be
467      * rethrown wrapped into a TorqueException.
468      */

469     public static void doUpdate(Criteria criteria, Connection JavaDoc con)
470         throws TorqueException
471     {
472         Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
473                    selectCriteria.put(ISSUE_ID, criteria.remove(ISSUE_ID));
474                                                                               // check for conversion from boolean to int
475
if (criteria.containsKey(DELETED))
476         {
477             Object JavaDoc possibleBoolean = criteria.get(DELETED);
478             if (possibleBoolean instanceof Boolean JavaDoc)
479             {
480                 criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
481             }
482          }
483           
484         setDbName(criteria);
485
486         if (con == null)
487         {
488             BasePeer.doUpdate(selectCriteria, criteria);
489         }
490         else
491         {
492             BasePeer.doUpdate(selectCriteria, criteria, con);
493         }
494     }
495
496     /**
497      * Method to do deletes.
498      *
499      * @param criteria object containing data that is used DELETE from database.
500      * @throws TorqueException Any exceptions caught during processing will be
501      * rethrown wrapped into a TorqueException.
502      */

503      public static void doDelete(Criteria criteria) throws TorqueException
504      {
505          IssuePeer
506             .doDelete(criteria, (Connection JavaDoc) null);
507      }
508
509     /**
510      * Method to do deletes. This method is to be used during a transaction,
511      * otherwise use the doDelete(Criteria) method. It will take care of
512      * the connection details internally.
513      *
514      * @param criteria object containing data that is used DELETE from database.
515      * @param con the connection to use
516      * @throws TorqueException Any exceptions caught during processing will be
517      * rethrown wrapped into a TorqueException.
518      */

519      public static void doDelete(Criteria criteria, Connection JavaDoc con)
520         throws TorqueException
521      {
522                                                         // check for conversion from boolean to int
523
if (criteria.containsKey(DELETED))
524         {
525             Object JavaDoc possibleBoolean = criteria.get(DELETED);
526             if (possibleBoolean instanceof Boolean JavaDoc)
527             {
528                 criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
529             }
530          }
531       
532         setDbName(criteria);
533
534         if (con == null)
535         {
536             BasePeer.doDelete(criteria);
537         }
538         else
539         {
540             BasePeer.doDelete(criteria, con);
541         }
542      }
543
544     /**
545      * Method to do selects
546      *
547      * @throws TorqueException Any exceptions caught during processing will be
548      * rethrown wrapped into a TorqueException.
549      */

550     public static List JavaDoc doSelect(Issue obj) throws TorqueException
551     {
552         return doSelect(buildSelectCriteria(obj));
553     }
554
555     /**
556      * Method to do inserts
557      *
558      * @throws TorqueException Any exceptions caught during processing will be
559      * rethrown wrapped into a TorqueException.
560      */

561     public static void doInsert(Issue obj) throws TorqueException
562     {
563           obj.setPrimaryKey(doInsert(buildCriteria(obj)));
564           obj.setNew(false);
565         obj.setModified(false);
566     }
567
568     /**
569      * @param obj the data object to update in the database.
570      * @throws TorqueException Any exceptions caught during processing will be
571      * rethrown wrapped into a TorqueException.
572      */

573     public static void doUpdate(Issue obj) throws TorqueException
574     {
575         doUpdate(buildCriteria(obj));
576         obj.setModified(false);
577     }
578
579     /**
580      * @param obj the data object to delete in the database.
581      * @throws TorqueException Any exceptions caught during processing will be
582      * rethrown wrapped into a TorqueException.
583      */

584     public static void doDelete(Issue obj) throws TorqueException
585     {
586         doDelete(buildSelectCriteria(obj));
587     }
588
589     /**
590      * Method to do inserts. This method is to be used during a transaction,
591      * otherwise use the doInsert(Issue) method. It will take
592      * care of the connection details internally.
593      *
594      * @param obj the data object to insert into the database.
595      * @param con the connection to use
596      * @throws TorqueException Any exceptions caught during processing will be
597      * rethrown wrapped into a TorqueException.
598      */

599     public static void doInsert(Issue obj, Connection JavaDoc con)
600         throws TorqueException
601     {
602           obj.setPrimaryKey(doInsert(buildCriteria(obj), con));
603           obj.setNew(false);
604         obj.setModified(false);
605     }
606
607     /**
608      * Method to do update. This method is to be used during a transaction,
609      * otherwise use the doUpdate(Issue) method. It will take
610      * care of the connection details internally.
611      *
612      * @param obj the data object to update in the database.
613      * @param con the connection to use
614      * @throws TorqueException Any exceptions caught during processing will be
615      * rethrown wrapped into a TorqueException.
616      */

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

634     public static void doDelete(Issue obj, Connection JavaDoc con)
635         throws TorqueException
636     {
637         doDelete(buildSelectCriteria(obj), con);
638     }
639
640     /**
641      * Method to do deletes.
642      *
643      * @param pk ObjectKey that is used DELETE from database.
644      * @throws TorqueException Any exceptions caught during processing will be
645      * rethrown wrapped into a TorqueException.
646      */

647     public static void doDelete(ObjectKey pk) throws TorqueException
648     {
649         BaseIssuePeer
650            .doDelete(pk, (Connection JavaDoc) null);
651     }
652
653     /**
654      * Method to delete. This method is to be used during a transaction,
655      * otherwise use the doDelete(ObjectKey) method. It will take
656      * care of the connection details internally.
657      *
658      * @param pk the primary key for the object to delete in the database.
659      * @param con the connection to use
660      * @throws TorqueException Any exceptions caught during processing will be
661      * rethrown wrapped into a TorqueException.
662      */

663     public static void doDelete(ObjectKey pk, Connection JavaDoc con)
664         throws TorqueException
665     {
666         doDelete(buildCriteria(pk), con);
667     }
668
669     /** Build a Criteria object from an ObjectKey */
670     public static Criteria buildCriteria( ObjectKey pk )
671     {
672         Criteria criteria = new Criteria();
673               criteria.add(ISSUE_ID, pk);
674           return criteria;
675      }
676
677     /** Build a Criteria object from the data object for this peer */
678     public static Criteria buildCriteria( Issue obj )
679     {
680         Criteria criteria = new Criteria(DATABASE_NAME);
681               if (!obj.isNew())
682             criteria.add(ISSUE_ID, obj.getIssueId());
683               criteria.add(ID_PREFIX, obj.getIdPrefix());
684               criteria.add(ID_COUNT, obj.getIdCount());
685               criteria.add(ID_DOMAIN, obj.getIdDomain());
686               criteria.add(TYPE_ID, obj.getTypeId());
687               criteria.add(MODULE_ID, obj.getModuleId());
688               criteria.add(CREATED_TRANS_ID, obj.getCreatedTransId());
689               criteria.add(DELETED, obj.getDeleted());
690           return criteria;
691     }
692
693     /** Build a Criteria object from the data object for this peer, skipping all binary columns */
694     public static Criteria buildSelectCriteria( Issue obj )
695     {
696         Criteria criteria = new Criteria(DATABASE_NAME);
697               if (!obj.isNew())
698                     criteria.add(ISSUE_ID, obj.getIssueId());
699                           criteria.add(ID_PREFIX, obj.getIdPrefix());
700                           criteria.add(ID_COUNT, obj.getIdCount());
701                           criteria.add(ID_DOMAIN, obj.getIdDomain());
702                           criteria.add(TYPE_ID, obj.getTypeId());
703                           criteria.add(MODULE_ID, obj.getModuleId());
704                           criteria.add(CREATED_TRANS_ID, obj.getCreatedTransId());
705                           criteria.add(DELETED, obj.getDeleted());
706               return criteria;
707     }
708  
709     
710         /**
711      * Retrieve a single object by pk
712      *
713      * @param pk the primary key
714      * @throws TorqueException Any exceptions caught during processing will be
715      * rethrown wrapped into a TorqueException.
716      * @throws NoRowsException Primary key was not found in database.
717      * @throws TooManyRowsException Primary key was not found in database.
718      */

719     public static Issue retrieveByPK(Long JavaDoc pk)
720         throws TorqueException, NoRowsException, TooManyRowsException
721     {
722         return retrieveByPK(SimpleKey.keyFor(pk));
723     }
724
725     /**
726      * Retrieve a single object by pk
727      *
728      * @param pk the primary key
729      * @param con the connection to use
730      * @throws TorqueException Any exceptions caught during processing will be
731      * rethrown wrapped into a TorqueException.
732      * @throws NoRowsException Primary key was not found in database.
733      * @throws TooManyRowsException Primary key was not found in database.
734      */

735     public static Issue retrieveByPK(Long JavaDoc pk, Connection JavaDoc con)
736         throws TorqueException, NoRowsException, TooManyRowsException
737     {
738         return retrieveByPK(SimpleKey.keyFor(pk), con);
739     }
740   
741     /**
742      * Retrieve a single object by pk
743      *
744      * @param pk the primary key
745      * @throws TorqueException Any exceptions caught during processing will be
746      * rethrown wrapped into a TorqueException.
747      * @throws NoRowsException Primary key was not found in database.
748      * @throws TooManyRowsException Primary key was not found in database.
749      */

750     public static Issue retrieveByPK(ObjectKey pk)
751         throws TorqueException, NoRowsException, TooManyRowsException
752     {
753         Connection JavaDoc db = null;
754         Issue retVal = null;
755         try
756         {
757             db = Torque.getConnection(DATABASE_NAME);
758             retVal = retrieveByPK(pk, db);
759         }
760         finally
761         {
762             Torque.closeConnection(db);
763         }
764         return(retVal);
765     }
766
767     /**
768      * Retrieve a single object by pk
769      *
770      * @param pk the primary key
771      * @param con the connection to use
772      * @throws TorqueException Any exceptions caught during processing will be
773      * rethrown wrapped into a TorqueException.
774      * @throws NoRowsException Primary key was not found in database.
775      * @throws TooManyRowsException Primary key was not found in database.
776      */

777     public static Issue retrieveByPK(ObjectKey pk, Connection JavaDoc con)
778         throws TorqueException, NoRowsException, TooManyRowsException
779     {
780         Criteria criteria = buildCriteria(pk);
781         List JavaDoc v = doSelect(criteria, con);
782         if (v.size() == 0)
783         {
784             throw new NoRowsException("Failed to select a row.");
785         }
786         else if (v.size() > 1)
787         {
788             throw new TooManyRowsException("Failed to select only one row.");
789         }
790         else
791         {
792             return (Issue)v.get(0);
793         }
794     }
795
796     /**
797      * Retrieve a multiple objects by pk
798      *
799      * @param pks List of primary keys
800      * @throws TorqueException Any exceptions caught during processing will be
801      * rethrown wrapped into a TorqueException.
802      */

803     public static List JavaDoc retrieveByPKs(List JavaDoc pks)
804         throws TorqueException
805     {
806         Connection JavaDoc db = null;
807         List JavaDoc retVal = null;
808         try
809         {
810            db = Torque.getConnection(DATABASE_NAME);
811            retVal = retrieveByPKs(pks, db);
812         }
813         finally
814         {
815             Torque.closeConnection(db);
816         }
817         return(retVal);
818     }
819
820     /**
821      * Retrieve a multiple objects by pk
822      *
823      * @param pks List of primary keys
824      * @param dbcon the connection to use
825      * @throws TorqueException Any exceptions caught during processing will be
826      * rethrown wrapped into a TorqueException.
827      */

828     public static List JavaDoc retrieveByPKs( List JavaDoc pks, Connection JavaDoc dbcon )
829         throws TorqueException
830     {
831         List JavaDoc objs = null;
832         if (pks == null || pks.size() == 0)
833         {
834             objs = new LinkedList JavaDoc();
835         }
836         else
837         {
838             Criteria criteria = new Criteria();
839               criteria.addIn( ISSUE_ID, pks );
840           objs = doSelect(criteria, dbcon);
841         }
842         return objs;
843     }
844
845  
846
847
848
849               
850                                               
851                         
852                 
853
854     /**
855      * selects a collection of Issue objects pre-filled with their
856      * ScarabModule objects.
857      *
858      * This method is protected by default in order to keep the public
859      * api reasonable. You can provide public methods for those you
860      * actually need in IssuePeer.
861      *
862      * @throws TorqueException Any exceptions caught during processing will be
863      * rethrown wrapped into a TorqueException.
864      */

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

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

1013    protected static List JavaDoc doSelectJoinActivitySet(Criteria criteria)
1014        throws TorqueException
1015    {
1016        setDbName(criteria);
1017
1018        IssuePeer.addSelectColumns(criteria);
1019        int offset = numColumns + 1;
1020        ActivitySetPeer.addSelectColumns(criteria);
1021
1022
1023                        criteria.addJoin(IssuePeer.CREATED_TRANS_ID,
1024            ActivitySetPeer.TRANSACTION_ID);
1025        
1026
1027                                                                                                                                                        // check for conversion from boolean to int
1028
if (criteria.containsKey(DELETED))
1029        {
1030            Object JavaDoc possibleBoolean = criteria.get(DELETED);
1031            if (possibleBoolean instanceof Boolean JavaDoc)
1032            {
1033                criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1034            }
1035         }
1036                  
1037        List JavaDoc rows = BasePeer.doSelect(criteria);
1038        List JavaDoc results = new ArrayList JavaDoc();
1039
1040        for (int i = 0; i < rows.size(); i++)
1041        {
1042            Record row = (Record) rows.get(i);
1043
1044                            Class JavaDoc omClass = IssuePeer.getOMClass();
1045                    Issue obj1 = (Issue) IssuePeer
1046                .row2Object(row, 1, omClass);
1047                     omClass = ActivitySetPeer.getOMClass();
1048                    ActivitySet obj2 = (ActivitySet)ActivitySetPeer
1049                .row2Object(row, offset, omClass);
1050
1051            boolean newObject = true;
1052            for (int j = 0; j < results.size(); j++)
1053            {
1054                Issue temp_obj1 = (Issue)results.get(j);
1055                ActivitySet temp_obj2 = (ActivitySet)temp_obj1.getActivitySet();
1056                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1057                {
1058                    newObject = false;
1059                              temp_obj2.addIssue(obj1);
1060                              break;
1061                }
1062            }
1063                      if (newObject)
1064            {
1065                obj2.initIssues();
1066                obj2.addIssue(obj1);
1067            }
1068                      results.add(obj1);
1069        }
1070        return results;
1071    }
1072                    
1073  
1074                                    
1075          
1076        
1077                                  
1078                
1079
1080    /**
1081     * selects a collection of Issue objects pre-filled with
1082     * all related objects.
1083     *
1084     * This method is protected by default in order to keep the public
1085     * api reasonable. You can provide public methods for those you
1086     * actually need in IssuePeer.
1087     *
1088     * @throws TorqueException Any exceptions caught during processing will be
1089     * rethrown wrapped into a TorqueException.
1090     */

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

1196    protected static List JavaDoc doSelectJoinAllExceptIssueType(Criteria criteria)
1197        throws TorqueException
1198    {
1199        setDbName(criteria);
1200
1201        addSelectColumns(criteria);
1202        int offset2 = numColumns + 1;
1203                                    
1204                    ScarabModulePeer.addSelectColumns(criteria);
1205        int offset3 = offset2 + ScarabModulePeer.numColumns;
1206                                                                
1207                                                  
1208                    ActivitySetPeer.addSelectColumns(criteria);
1209        int offset4 = offset3 + ActivitySetPeer.numColumns;
1210                                                                                                                                                                                                    // check for conversion from boolean to int
1211
if (criteria.containsKey(DELETED))
1212        {
1213            Object JavaDoc possibleBoolean = criteria.get(DELETED);
1214            if (possibleBoolean instanceof Boolean JavaDoc)
1215            {
1216                criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1217            }
1218         }
1219                  
1220        List JavaDoc rows = BasePeer.doSelect(criteria);
1221        List JavaDoc results = new ArrayList JavaDoc();
1222
1223        for (int i = 0; i < rows.size(); i++)
1224        {
1225            Record row = (Record)rows.get(i);
1226
1227                            Class JavaDoc omClass = IssuePeer.getOMClass();
1228                    Issue obj1 = (Issue)IssuePeer
1229                .row2Object(row, 1, omClass);
1230                                                            
1231                                                        
1232                            
1233              
1234                           omClass = ScarabModulePeer.getOMClass(row, offset2);
1235                          ScarabModule obj2 = (ScarabModule)ScarabModulePeer
1236                .row2Object( row, offset2, omClass);
1237
1238               boolean newObject = true;
1239            for (int j = 0; j < results.size(); j++)
1240            {
1241                Issue temp_obj1 = (Issue)results.get(j);
1242                ScarabModule temp_obj2 = (ScarabModule)temp_obj1.getModule();
1243                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1244                {
1245                    newObject = false;
1246                                    temp_obj2.addIssue(obj1);
1247                                    break;
1248                }
1249            }
1250                            if (newObject)
1251            {
1252                obj2.initIssues();
1253                obj2.addIssue(obj1);
1254            }
1255                                                                                    
1256                                                                  
1257                                                        
1258                            
1259              
1260                           omClass = ActivitySetPeer.getOMClass();
1261                          ActivitySet obj3 = (ActivitySet)ActivitySetPeer
1262                .row2Object( row, offset3, omClass);
1263
1264               newObject = true;
1265            for (int j = 0; j < results.size(); j++)
1266            {
1267                Issue temp_obj1 = (Issue)results.get(j);
1268                ActivitySet temp_obj3 = (ActivitySet)temp_obj1.getActivitySet();
1269                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1270                {
1271                    newObject = false;
1272                                    temp_obj3.addIssue(obj1);
1273                                    break;
1274                }
1275            }
1276                            if (newObject)
1277            {
1278                obj3.initIssues();
1279                obj3.addIssue(obj1);
1280            }
1281                                                                results.add(obj1);
1282        }
1283        return results;
1284    }
1285        
1286        
1287                                  
1288                
1289
1290    /**
1291     * selects a collection of Issue objects pre-filled with
1292     * all related objects.
1293     *
1294     * This method is protected by default in order to keep the public
1295     * api reasonable. You can provide public methods for those you
1296     * actually need in IssuePeer.
1297     *
1298     * @throws TorqueException Any exceptions caught during processing will be
1299     * rethrown wrapped into a TorqueException.
1300     */

1301    protected static List JavaDoc doSelectJoinAllExceptActivitySet(Criteria criteria)
1302        throws TorqueException
1303    {
1304        setDbName(criteria);
1305
1306        addSelectColumns(criteria);
1307        int offset2 = numColumns + 1;
1308                                    
1309                    ScarabModulePeer.addSelectColumns(criteria);
1310        int offset3 = offset2 + ScarabModulePeer.numColumns;
1311                                                                
1312                    IssueTypePeer.addSelectColumns(criteria);
1313        int offset4 = offset3 + IssueTypePeer.numColumns;
1314                                                                
1315                                                                                                                                                                                      // check for conversion from boolean to int
1316
if (criteria.containsKey(DELETED))
1317        {
1318            Object JavaDoc possibleBoolean = criteria.get(DELETED);
1319            if (possibleBoolean instanceof Boolean JavaDoc)
1320            {
1321                criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1322            }
1323         }
1324                  
1325        List JavaDoc rows = BasePeer.doSelect(criteria);
1326        List JavaDoc results = new ArrayList JavaDoc();
1327
1328        for (int i = 0; i < rows.size(); i++)
1329        {
1330            Record row = (Record)rows.get(i);
1331
1332                            Class JavaDoc omClass = IssuePeer.getOMClass();
1333                    Issue obj1 = (Issue)IssuePeer
1334                .row2Object(row, 1, omClass);
1335                                                            
1336                                                        
1337                            
1338              
1339                           omClass = ScarabModulePeer.getOMClass(row, offset2);
1340                          ScarabModule obj2 = (ScarabModule)ScarabModulePeer
1341                .row2Object( row, offset2, omClass);
1342
1343               boolean newObject = true;
1344            for (int j = 0; j < results.size(); j++)
1345            {
1346                Issue temp_obj1 = (Issue)results.get(j);
1347                ScarabModule temp_obj2 = (ScarabModule)temp_obj1.getModule();
1348                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1349                {
1350                    newObject = false;
1351                                    temp_obj2.addIssue(obj1);
1352                                    break;
1353                }
1354            }
1355                            if (newObject)
1356            {
1357                obj2.initIssues();
1358                obj2.addIssue(obj1);
1359            }
1360                                                                                    
1361                                                        
1362                            
1363              
1364                           omClass = IssueTypePeer.getOMClass();
1365                          IssueType obj3 = (IssueType)IssueTypePeer
1366                .row2Object( row, offset3, omClass);
1367
1368               newObject = true;
1369            for (int j = 0; j < results.size(); j++)
1370            {
1371                Issue temp_obj1 = (Issue)results.get(j);
1372                IssueType temp_obj3 = (IssueType)temp_obj1.getIssueType();
1373                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1374                {
1375                    newObject = false;
1376                                    temp_obj3.addIssue(obj1);
1377                                    break;
1378                }
1379            }
1380                            if (newObject)
1381            {
1382                obj3.initIssues();
1383                obj3.addIssue(obj1);
1384            }
1385                                                                                    
1386                                              results.add(obj1);
1387        }
1388        return results;
1389    }
1390                    
1391  
1392      /**
1393     * Returns the TableMap related to this peer. This method is not
1394     * needed for general use but a specific application could have a need.
1395     *
1396     * @throws TorqueException Any exceptions caught during processing will be
1397     * rethrown wrapped into a TorqueException.
1398     */

1399    protected static TableMap getTableMap()
1400        throws TorqueException
1401    {
1402        return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME);
1403    }
1404   
1405    private static void setDbName(Criteria crit)
1406    {
1407        // Set the correct dbName if it has not been overridden
1408
// crit.getDbName will return the same object if not set to
1409
// another value so == check is okay and faster
1410
if (crit.getDbName() == Torque.getDefaultDB())
1411        {
1412            crit.setDbName(DATABASE_NAME);
1413        }
1414    }
1415}
1416
Popular Tags