View Javadoc

1   package org.apache.turbine.services.schedule;
2   
3   import java.math.BigDecimal;
4   import java.sql.Connection;
5   import java.sql.SQLException;
6   import java.util.ArrayList;
7   import java.util.Date;
8   import java.util.Iterator;
9   import java.util.LinkedList;
10  import java.util.List;
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.TorqueRuntimeException;
17  import org.apache.torque.map.MapBuilder;
18  import org.apache.torque.map.TableMap;
19  import org.apache.torque.om.DateKey;
20  import org.apache.torque.om.NumberKey;
21  import org.apache.torque.om.StringKey;
22  import org.apache.torque.om.ObjectKey;
23  import org.apache.torque.om.SimpleKey;
24  import org.apache.torque.util.BasePeer;
25  import org.apache.torque.util.Criteria;
26  
27  import com.workingdogs.village.DataSetException;
28  import com.workingdogs.village.QueryDataSet;
29  import com.workingdogs.village.Record;
30  
31  // Local classes
32  import org.apache.turbine.services.schedule.map.*;
33  
34  
35  
36  
37  /***
38   * This class was autogenerated by Torque on:
39   *
40   * [Tue Nov 04 15:53:50 CET 2008]
41   *
42   */
43  public abstract class BaseJobEntryPeer
44      extends BasePeer
45  {
46      /*** Serial version */
47      private static final long serialVersionUID = 1225810430285L;
48  
49  
50      /*** the default database name for this class */
51      public static final String DATABASE_NAME;
52  
53       /*** the table name for this class */
54      public static final String TABLE_NAME;
55  
56      /***
57       * @return the map builder for this peer
58       * @throws TorqueException Any exceptions caught during processing will be
59       *         rethrown wrapped into a TorqueException.
60       * @deprecated Torque.getMapBuilder(JobEntryMapBuilder.CLASS_NAME) instead
61       */
62      public static MapBuilder getMapBuilder()
63          throws TorqueException
64      {
65          return Torque.getMapBuilder(JobEntryMapBuilder.CLASS_NAME);
66      }
67  
68      /*** the column name for the JOB_ID field */
69      public static final String JOB_ID;
70      /*** the column name for the SECOND field */
71      public static final String SECOND;
72      /*** the column name for the MINUTE field */
73      public static final String MINUTE;
74      /*** the column name for the HOUR field */
75      public static final String HOUR;
76      /*** the column name for the WEEK_DAY field */
77      public static final String WEEK_DAY;
78      /*** the column name for the DAY_OF_MONTH field */
79      public static final String DAY_OF_MONTH;
80      /*** the column name for the TASK field */
81      public static final String TASK;
82      /*** the column name for the EMAIL field */
83      public static final String EMAIL;
84      /*** the column name for the PROPERTY field */
85      public static final String PROPERTY;
86  
87      static
88      {
89          DATABASE_NAME = "default";
90          TABLE_NAME = "TURBINE_SCHEDULED_JOB";
91  
92          JOB_ID = "TURBINE_SCHEDULED_JOB.JOB_ID";
93          SECOND = "TURBINE_SCHEDULED_JOB.SECOND";
94          MINUTE = "TURBINE_SCHEDULED_JOB.MINUTE";
95          HOUR = "TURBINE_SCHEDULED_JOB.HOUR";
96          WEEK_DAY = "TURBINE_SCHEDULED_JOB.WEEK_DAY";
97          DAY_OF_MONTH = "TURBINE_SCHEDULED_JOB.DAY_OF_MONTH";
98          TASK = "TURBINE_SCHEDULED_JOB.TASK";
99          EMAIL = "TURBINE_SCHEDULED_JOB.EMAIL";
100         PROPERTY = "TURBINE_SCHEDULED_JOB.PROPERTY";
101         if (Torque.isInit())
102         {
103             try
104             {
105                 Torque.getMapBuilder(JobEntryMapBuilder.CLASS_NAME);
106             }
107             catch (TorqueException e)
108             {
109                 log.error("Could not initialize Peer", e);
110                 throw new TorqueRuntimeException(e);
111             }
112         }
113         else
114         {
115             Torque.registerMapBuilder(JobEntryMapBuilder.CLASS_NAME);
116         }
117     }
118  
119     /*** number of columns for this peer */
120     public static final int numColumns =  9;
121 
122     /*** A class that can be returned by this peer. */
123     protected static final String CLASSNAME_DEFAULT =
124         "org.apache.turbine.services.schedule.JobEntry";
125 
126     /*** A class that can be returned by this peer. */
127     protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT);
128 
129     /***
130      * Class object initialization method.
131      *
132      * @param className name of the class to initialize
133      * @return the initialized class
134      */
135     private static Class initClass(String className)
136     {
137         Class c = null;
138         try
139         {
140             c = Class.forName(className);
141         }
142         catch (Throwable t)
143         {
144             log.error("A FATAL ERROR has occurred which should not "
145                 + "have happened under any circumstance.  Please notify "
146                 + "the Torque developers <torque-dev@db.apache.org> "
147                 + "and give as many details as possible (including the error "
148                 + "stack trace).", t);
149 
150             // Error objects should always be propagated.
151             if (t instanceof Error)
152             {
153                 throw (Error) t.fillInStackTrace();
154             }
155         }
156         return c;
157     }
158 
159     /***
160      * Get the list of objects for a ResultSet.  Please not that your
161      * resultset MUST return columns in the right order.  You can use
162      * getFieldNames() in BaseObject to get the correct sequence.
163      *
164      * @param results the ResultSet
165      * @return the list of objects
166      * @throws TorqueException Any exceptions caught during processing will be
167      *         rethrown wrapped into a TorqueException.
168      */
169     public static List resultSet2Objects(java.sql.ResultSet results)
170             throws TorqueException
171     {
172         try
173         {
174             QueryDataSet qds = null;
175             List rows = null;
176             try
177             {
178                 qds = new QueryDataSet(results);
179                 rows = getSelectResults(qds);
180             }
181             finally
182             {
183                 if (qds != null)
184                 {
185                     qds.close();
186                 }
187             }
188 
189             return populateObjects(rows);
190         }
191         catch (SQLException e)
192         {
193             throw new TorqueException(e);
194         }
195         catch (DataSetException e)
196         {
197             throw new TorqueException(e);
198         }
199     }
200 
201 
202 
203     /***
204      * Method to do inserts.
205      *
206      * @param criteria object used to create the INSERT statement.
207      * @throws TorqueException Any exceptions caught during processing will be
208      *         rethrown wrapped into a TorqueException.
209      */
210     public static ObjectKey doInsert(Criteria criteria)
211         throws TorqueException
212     {
213         return BaseJobEntryPeer
214             .doInsert(criteria, (Connection) null);
215     }
216 
217     /***
218      * Method to do inserts.  This method is to be used during a transaction,
219      * otherwise use the doInsert(Criteria) method.  It will take care of
220      * the connection details internally.
221      *
222      * @param criteria object used to create the INSERT statement.
223      * @param con the connection to use
224      * @throws TorqueException Any exceptions caught during processing will be
225      *         rethrown wrapped into a TorqueException.
226      */
227     public static ObjectKey doInsert(Criteria criteria, Connection con)
228         throws TorqueException
229     {
230         correctBooleans(criteria);
231 
232         setDbName(criteria);
233 
234         if (con == null)
235         {
236             return BasePeer.doInsert(criteria);
237         }
238         else
239         {
240             return BasePeer.doInsert(criteria, con);
241         }
242     }
243 
244     /***
245      * Add all the columns needed to create a new object.
246      *
247      * @param criteria object containing the columns to add.
248      * @throws TorqueException Any exceptions caught during processing will be
249      *         rethrown wrapped into a TorqueException.
250      */
251     public static void addSelectColumns(Criteria criteria)
252             throws TorqueException
253     {
254         criteria.addSelectColumn(JOB_ID);
255         criteria.addSelectColumn(SECOND);
256         criteria.addSelectColumn(MINUTE);
257         criteria.addSelectColumn(HOUR);
258         criteria.addSelectColumn(WEEK_DAY);
259         criteria.addSelectColumn(DAY_OF_MONTH);
260         criteria.addSelectColumn(TASK);
261         criteria.addSelectColumn(EMAIL);
262         criteria.addSelectColumn(PROPERTY);
263     }
264 
265     /***
266      * changes the boolean values in the criteria to the appropriate type,
267      * whenever a booleanchar or booleanint column is involved.
268      * This enables the user to create criteria using Boolean values
269      * for booleanchar or booleanint columns
270      * @param criteria the criteria in which the boolean values should be corrected
271      * @throws TorqueException if the database map for the criteria cannot be 
272                obtained.
273      */
274     public static void correctBooleans(Criteria criteria) throws TorqueException
275     {
276         correctBooleans(criteria, getTableMap());
277     }
278 
279     /***
280      * Create a new object of type cls from a resultset row starting
281      * from a specified offset.  This is done so that you can select
282      * other rows than just those needed for this object.  You may
283      * for example want to create two objects from the same row.
284      *
285      * @throws TorqueException Any exceptions caught during processing will be
286      *         rethrown wrapped into a TorqueException.
287      */
288     public static JobEntry row2Object(Record row,
289                                              int offset,
290                                              Class cls)
291         throws TorqueException
292     {
293         try
294         {
295             JobEntry obj = (JobEntry) cls.newInstance();
296             JobEntryPeer.populateObject(row, offset, obj);
297                 obj.setModified(false);
298             obj.setNew(false);
299 
300             return obj;
301         }
302         catch (InstantiationException e)
303         {
304             throw new TorqueException(e);
305         }
306         catch (IllegalAccessException e)
307         {
308             throw new TorqueException(e);
309         }
310     }
311 
312     /***
313      * Populates an object from a resultset row starting
314      * from a specified offset.  This is done so that you can select
315      * other rows than just those needed for this object.  You may
316      * for example want to create two objects from the same row.
317      *
318      * @throws TorqueException Any exceptions caught during processing will be
319      *         rethrown wrapped into a TorqueException.
320      */
321     public static void populateObject(Record row,
322                                       int offset,
323                                       JobEntry obj)
324         throws TorqueException
325     {
326         try
327         {
328             obj.setJobId(row.getValue(offset + 0).asInt());
329             obj.setSecond(row.getValue(offset + 1).asInt());
330             obj.setMinute(row.getValue(offset + 2).asInt());
331             obj.setHour(row.getValue(offset + 3).asInt());
332             obj.setWeekDay(row.getValue(offset + 4).asInt());
333             obj.setDayOfMonth(row.getValue(offset + 5).asInt());
334             obj.setTask(row.getValue(offset + 6).asString());
335             obj.setEmail(row.getValue(offset + 7).asString());
336             obj.setProperty(row.getValue(offset + 8).asBytes());
337         }
338         catch (DataSetException e)
339         {
340             throw new TorqueException(e);
341         }
342     }
343 
344     /***
345      * Method to do selects.
346      *
347      * @param criteria object used to create the SELECT statement.
348      * @return List of selected Objects
349      * @throws TorqueException Any exceptions caught during processing will be
350      *         rethrown wrapped into a TorqueException.
351      */
352     public static List doSelect(Criteria criteria) throws TorqueException
353     {
354         return populateObjects(doSelectVillageRecords(criteria));
355     }
356 
357     /***
358      * Method to do selects within a transaction.
359      *
360      * @param criteria object used to create the SELECT statement.
361      * @param con the connection to use
362      * @return List of selected Objects
363      * @throws TorqueException Any exceptions caught during processing will be
364      *         rethrown wrapped into a TorqueException.
365      */
366     public static List doSelect(Criteria criteria, Connection con)
367         throws TorqueException
368     {
369         return populateObjects(doSelectVillageRecords(criteria, con));
370     }
371 
372     /***
373      * Grabs the raw Village records to be formed into objects.
374      * This method handles connections internally.  The Record objects
375      * returned by this method should be considered readonly.  Do not
376      * alter the data and call save(), your results may vary, but are
377      * certainly likely to result in hard to track MT bugs.
378      *
379      * @throws TorqueException Any exceptions caught during processing will be
380      *         rethrown wrapped into a TorqueException.
381      */
382     public static List doSelectVillageRecords(Criteria criteria)
383         throws TorqueException
384     {
385         return BaseJobEntryPeer
386             .doSelectVillageRecords(criteria, (Connection) null);
387     }
388 
389     /***
390      * Grabs the raw Village records to be formed into objects.
391      * This method should be used for transactions
392      *
393      * @param criteria object used to create the SELECT statement.
394      * @param con the connection to use
395      * @throws TorqueException Any exceptions caught during processing will be
396      *         rethrown wrapped into a TorqueException.
397      */
398     public static List doSelectVillageRecords(Criteria criteria, Connection con)
399         throws TorqueException
400     {
401         if (criteria.getSelectColumns().size() == 0)
402         {
403             addSelectColumns(criteria);
404         }
405         correctBooleans(criteria);
406 
407         setDbName(criteria);
408 
409         // BasePeer returns a List of Value (Village) arrays.  The array
410         // order follows the order columns were placed in the Select clause.
411         if (con == null)
412         {
413             return BasePeer.doSelect(criteria);
414         }
415         else
416         {
417             return BasePeer.doSelect(criteria, con);
418         }
419     }
420 
421     /***
422      * The returned List will contain objects of the default type or
423      * objects that inherit from the default.
424      *
425      * @throws TorqueException Any exceptions caught during processing will be
426      *         rethrown wrapped into a TorqueException.
427      */
428     public static List populateObjects(List records)
429         throws TorqueException
430     {
431         List results = new ArrayList(records.size());
432 
433         // populate the object(s)
434         for (int i = 0; i < records.size(); i++)
435         {
436             Record row = (Record) records.get(i);
437             results.add(JobEntryPeer.row2Object(row, 1,
438                 JobEntryPeer.getOMClass()));
439         }
440         return results;
441     }
442  
443 
444     /***
445      * The class that the Peer will make instances of.
446      * If the BO is abstract then you must implement this method
447      * in the BO.
448      *
449      * @throws TorqueException Any exceptions caught during processing will be
450      *         rethrown wrapped into a TorqueException.
451      */
452     public static Class getOMClass()
453         throws TorqueException
454     {
455         return CLASS_DEFAULT;
456     }
457 
458     /***
459      * Method to do updates.
460      *
461      * @param criteria object containing data that is used to create the UPDATE
462      *        statement.
463      * @throws TorqueException Any exceptions caught during processing will be
464      *         rethrown wrapped into a TorqueException.
465      */
466     public static void doUpdate(Criteria criteria) throws TorqueException
467     {
468          BaseJobEntryPeer
469             .doUpdate(criteria, (Connection) null);
470     }
471 
472     /***
473      * Method to do updates.  This method is to be used during a transaction,
474      * otherwise use the doUpdate(Criteria) method.  It will take care of
475      * the connection details internally.
476      *
477      * @param criteria object containing data that is used to create the UPDATE
478      *        statement.
479      * @param con the connection to use
480      * @throws TorqueException Any exceptions caught during processing will be
481      *         rethrown wrapped into a TorqueException.
482      */
483     public static void doUpdate(Criteria criteria, Connection con)
484         throws TorqueException
485     {
486         Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
487         correctBooleans(criteria);
488 
489 
490          selectCriteria.put(JOB_ID, criteria.remove(JOB_ID));
491 
492 
493 
494 
495 
496 
497 
498 
499 
500         setDbName(criteria);
501 
502         if (con == null)
503         {
504             BasePeer.doUpdate(selectCriteria, criteria);
505         }
506         else
507         {
508             BasePeer.doUpdate(selectCriteria, criteria, con);
509         }
510     }
511 
512     /***
513      * Method to do deletes.
514      *
515      * @param criteria object containing data that is used DELETE from database.
516      * @throws TorqueException Any exceptions caught during processing will be
517      *         rethrown wrapped into a TorqueException.
518      */
519      public static void doDelete(Criteria criteria) throws TorqueException
520      {
521          JobEntryPeer
522             .doDelete(criteria, (Connection) null);
523      }
524 
525     /***
526      * Method to do deletes.  This method is to be used during a transaction,
527      * otherwise use the doDelete(Criteria) method.  It will take care of
528      * the connection details internally.
529      *
530      * @param criteria object containing data that is used DELETE from database.
531      * @param con the connection to use
532      * @throws TorqueException Any exceptions caught during processing will be
533      *         rethrown wrapped into a TorqueException.
534      */
535      public static void doDelete(Criteria criteria, Connection con)
536         throws TorqueException
537      {
538         correctBooleans(criteria);
539 
540         setDbName(criteria);
541 
542         if (con == null)
543         {
544             BasePeer.doDelete(criteria, TABLE_NAME);
545         }
546         else
547         {
548             BasePeer.doDelete(criteria, TABLE_NAME, con);
549         }
550      }
551 
552     /***
553      * Method to do selects
554      *
555      * @throws TorqueException Any exceptions caught during processing will be
556      *         rethrown wrapped into a TorqueException.
557      */
558     public static List doSelect(JobEntry obj) throws TorqueException
559     {
560         return doSelect(buildSelectCriteria(obj));
561     }
562 
563     /***
564      * Method to do inserts
565      *
566      * @throws TorqueException Any exceptions caught during processing will be
567      *         rethrown wrapped into a TorqueException.
568      */
569     public static void doInsert(JobEntry obj) throws TorqueException
570     {
571         obj.setPrimaryKey(doInsert(buildCriteria(obj)));
572         obj.setNew(false);
573         obj.setModified(false);
574     }
575 
576     /***
577      * @param obj the data object to update in the database.
578      * @throws TorqueException Any exceptions caught during processing will be
579      *         rethrown wrapped into a TorqueException.
580      */
581     public static void doUpdate(JobEntry obj) throws TorqueException
582     {
583         doUpdate(buildCriteria(obj));
584         obj.setModified(false);
585     }
586 
587     /***
588      * @param obj the data object to delete in the database.
589      * @throws TorqueException Any exceptions caught during processing will be
590      *         rethrown wrapped into a TorqueException.
591      */
592     public static void doDelete(JobEntry obj) throws TorqueException
593     {
594         doDelete(buildSelectCriteria(obj));
595     }
596 
597     /***
598      * Method to do inserts.  This method is to be used during a transaction,
599      * otherwise use the doInsert(JobEntry) method.  It will take
600      * care of the connection details internally.
601      *
602      * @param obj the data object to insert into the database.
603      * @param con the connection to use
604      * @throws TorqueException Any exceptions caught during processing will be
605      *         rethrown wrapped into a TorqueException.
606      */
607     public static void doInsert(JobEntry obj, Connection con)
608         throws TorqueException
609     {
610         obj.setPrimaryKey(doInsert(buildCriteria(obj), con));
611         obj.setNew(false);
612         obj.setModified(false);
613     }
614 
615     /***
616      * Method to do update.  This method is to be used during a transaction,
617      * otherwise use the doUpdate(JobEntry) method.  It will take
618      * care of the connection details internally.
619      *
620      * @param obj the data object to update in the database.
621      * @param con the connection to use
622      * @throws TorqueException Any exceptions caught during processing will be
623      *         rethrown wrapped into a TorqueException.
624      */
625     public static void doUpdate(JobEntry obj, Connection con)
626         throws TorqueException
627     {
628         doUpdate(buildCriteria(obj), con);
629         obj.setModified(false);
630     }
631 
632     /***
633      * Method to delete.  This method is to be used during a transaction,
634      * otherwise use the doDelete(JobEntry) method.  It will take
635      * care of the connection details internally.
636      *
637      * @param obj the data object to delete in the database.
638      * @param con the connection to use
639      * @throws TorqueException Any exceptions caught during processing will be
640      *         rethrown wrapped into a TorqueException.
641      */
642     public static void doDelete(JobEntry obj, Connection con)
643         throws TorqueException
644     {
645         doDelete(buildSelectCriteria(obj), con);
646     }
647 
648     /***
649      * Method to do deletes.
650      *
651      * @param pk ObjectKey that is used DELETE from database.
652      * @throws TorqueException Any exceptions caught during processing will be
653      *         rethrown wrapped into a TorqueException.
654      */
655     public static void doDelete(ObjectKey pk) throws TorqueException
656     {
657         BaseJobEntryPeer
658            .doDelete(pk, (Connection) null);
659     }
660 
661     /***
662      * Method to delete.  This method is to be used during a transaction,
663      * otherwise use the doDelete(ObjectKey) method.  It will take
664      * care of the connection details internally.
665      *
666      * @param pk the primary key for the object to delete in the database.
667      * @param con the connection to use
668      * @throws TorqueException Any exceptions caught during processing will be
669      *         rethrown wrapped into a TorqueException.
670      */
671     public static void doDelete(ObjectKey pk, Connection con)
672         throws TorqueException
673     {
674         doDelete(buildCriteria(pk), con);
675     }
676 
677     /*** Build a Criteria object from an ObjectKey */
678     public static Criteria buildCriteria( ObjectKey pk )
679     {
680         Criteria criteria = new Criteria();
681             criteria.add(JOB_ID, pk);
682         return criteria;
683      }
684 
685     /*** Build a Criteria object from the data object for this peer */
686     public static Criteria buildCriteria( JobEntry obj )
687     {
688         Criteria criteria = new Criteria(DATABASE_NAME);
689         if (!obj.isNew())
690         criteria.add(JOB_ID, obj.getJobId());
691         criteria.add(SECOND, obj.getSecond());
692         criteria.add(MINUTE, obj.getMinute());
693         criteria.add(HOUR, obj.getHour());
694         criteria.add(WEEK_DAY, obj.getWeekDay());
695         criteria.add(DAY_OF_MONTH, obj.getDayOfMonth());
696         criteria.add(TASK, obj.getTask());
697         criteria.add(EMAIL, obj.getEmail());
698         criteria.add(PROPERTY, obj.getProperty());
699         return criteria;
700     }
701 
702     /*** Build a Criteria object from the data object for this peer, skipping all binary columns */
703     public static Criteria buildSelectCriteria( JobEntry obj )
704     {
705         Criteria criteria = new Criteria(DATABASE_NAME);
706         if (!obj.isNew())
707         {
708             criteria.add(JOB_ID, obj.getJobId());
709         }
710             criteria.add(SECOND, obj.getSecond());
711             criteria.add(MINUTE, obj.getMinute());
712             criteria.add(HOUR, obj.getHour());
713             criteria.add(WEEK_DAY, obj.getWeekDay());
714             criteria.add(DAY_OF_MONTH, obj.getDayOfMonth());
715             criteria.add(TASK, obj.getTask());
716             criteria.add(EMAIL, obj.getEmail());
717         return criteria;
718     }
719  
720 
721     /***
722      * Retrieve a single object by pk
723      *
724      * @param pk the primary key
725      * @throws TorqueException Any exceptions caught during processing will be
726      *         rethrown wrapped into a TorqueException.
727      * @throws NoRowsException Primary key was not found in database.
728      * @throws TooManyRowsException Primary key was not found in database.
729      */
730     public static JobEntry retrieveByPK(int pk)
731         throws TorqueException, NoRowsException, TooManyRowsException
732     {
733         return retrieveByPK(SimpleKey.keyFor(pk));
734     }
735 
736     /***
737      * Retrieve a single object by pk
738      *
739      * @param pk the primary key
740      * @param con the connection to use
741      * @throws TorqueException Any exceptions caught during processing will be
742      *         rethrown wrapped into a TorqueException.
743      * @throws NoRowsException Primary key was not found in database.
744      * @throws TooManyRowsException Primary key was not found in database.
745      */
746     public static JobEntry retrieveByPK(int pk, Connection con)
747         throws TorqueException, NoRowsException, TooManyRowsException
748     {
749         return retrieveByPK(SimpleKey.keyFor(pk), con);
750     }
751 
752     /***
753      * Retrieve a single object by pk
754      *
755      * @param pk the primary key
756      * @throws TorqueException Any exceptions caught during processing will be
757      *         rethrown wrapped into a TorqueException.
758      * @throws NoRowsException Primary key was not found in database.
759      * @throws TooManyRowsException Primary key was not found in database.
760      */
761     public static JobEntry retrieveByPK(ObjectKey pk)
762         throws TorqueException, NoRowsException, TooManyRowsException
763     {
764         Connection db = null;
765         JobEntry retVal = null;
766         try
767         {
768             db = Torque.getConnection(DATABASE_NAME);
769             retVal = retrieveByPK(pk, db);
770         }
771         finally
772         {
773             Torque.closeConnection(db);
774         }
775         return retVal;
776     }
777 
778     /***
779      * Retrieve a single object by pk
780      *
781      * @param pk the primary key
782      * @param con the connection to use
783      * @throws TorqueException Any exceptions caught during processing will be
784      *         rethrown wrapped into a TorqueException.
785      * @throws NoRowsException Primary key was not found in database.
786      * @throws TooManyRowsException Primary key was not found in database.
787      */
788     public static JobEntry retrieveByPK(ObjectKey pk, Connection con)
789         throws TorqueException, NoRowsException, TooManyRowsException
790     {
791         Criteria criteria = buildCriteria(pk);
792         List v = doSelect(criteria, con);
793         if (v.size() == 0)
794         {
795             throw new NoRowsException("Failed to select a row.");
796         }
797         else if (v.size() > 1)
798         {
799             throw new TooManyRowsException("Failed to select only one row.");
800         }
801         else
802         {
803             return (JobEntry)v.get(0);
804         }
805     }
806 
807     /***
808      * Retrieve a multiple objects by pk
809      *
810      * @param pks List of primary keys
811      * @throws TorqueException Any exceptions caught during processing will be
812      *         rethrown wrapped into a TorqueException.
813      */
814     public static List retrieveByPKs(List pks)
815         throws TorqueException
816     {
817         Connection db = null;
818         List retVal = null;
819         try
820         {
821            db = Torque.getConnection(DATABASE_NAME);
822            retVal = retrieveByPKs(pks, db);
823         }
824         finally
825         {
826             Torque.closeConnection(db);
827         }
828         return retVal;
829     }
830 
831     /***
832      * Retrieve a multiple objects by pk
833      *
834      * @param pks List of primary keys
835      * @param dbcon the connection to use
836      * @throws TorqueException Any exceptions caught during processing will be
837      *         rethrown wrapped into a TorqueException.
838      */
839     public static List retrieveByPKs( List pks, Connection dbcon )
840         throws TorqueException
841     {
842         List objs = null;
843         if (pks == null || pks.size() == 0)
844         {
845             objs = new LinkedList();
846         }
847         else
848         {
849             Criteria criteria = new Criteria();
850             criteria.addIn( JOB_ID, pks );
851         objs = doSelect(criteria, dbcon);
852         }
853         return objs;
854     }
855 
856  
857 
858 
859 
860 
861 
862 
863 
864 
865     /***
866      * Returns the TableMap related to this peer.
867      *
868      * @throws TorqueException Any exceptions caught during processing will be
869      *         rethrown wrapped into a TorqueException.
870      */
871     public static TableMap getTableMap()
872         throws TorqueException
873     {
874         return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME);
875     }
876  
877     private static void setDbName(Criteria crit)
878     {
879         // Set the correct dbName if it has not been overridden
880         // crit.getDbName will return the same object if not set to
881         // another value so == check is okay and faster
882         if (crit.getDbName() == Torque.getDefaultDB())
883         {
884             crit.setDbName(DATABASE_NAME);
885         }
886     }
887     
888 
889 }