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