Coverage Report - org.apache.turbine.services.schedule.BaseJobEntryPeer
 
Classes in this File Line Coverage Branch Coverage Complexity
BaseJobEntryPeer
9%
19/209
0%
0/30
1,647
 
 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  
  * [Thu Jun 23 17:25:46 CEST 2011]
 41  
  *
 42  
  */
 43  4
 public abstract class BaseJobEntryPeer
 44  
     extends BasePeer
 45  
 {
 46  
     /** Serial version */
 47  
     private static final long serialVersionUID = 1308842746584L;
 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  0
         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  4
         DATABASE_NAME = "default";
 90  4
         TABLE_NAME = "TURBINE_SCHEDULED_JOB";
 91  
 
 92  4
         JOB_ID = "TURBINE_SCHEDULED_JOB.JOB_ID";
 93  4
         SECOND = "TURBINE_SCHEDULED_JOB.SECOND";
 94  4
         MINUTE = "TURBINE_SCHEDULED_JOB.MINUTE";
 95  4
         HOUR = "TURBINE_SCHEDULED_JOB.HOUR";
 96  4
         WEEK_DAY = "TURBINE_SCHEDULED_JOB.WEEK_DAY";
 97  4
         DAY_OF_MONTH = "TURBINE_SCHEDULED_JOB.DAY_OF_MONTH";
 98  4
         TASK = "TURBINE_SCHEDULED_JOB.TASK";
 99  4
         EMAIL = "TURBINE_SCHEDULED_JOB.EMAIL";
 100  4
         PROPERTY = "TURBINE_SCHEDULED_JOB.PROPERTY";
 101  4
         if (Torque.isInit())
 102  
         {
 103  
             try
 104  
             {
 105  0
                 Torque.getMapBuilder(JobEntryMapBuilder.CLASS_NAME);
 106  
             }
 107  0
             catch (TorqueException e)
 108  
             {
 109  0
                 log.error("Could not initialize Peer", e);
 110  0
                 throw new TorqueRuntimeException(e);
 111  0
             }
 112  
         }
 113  
         else
 114  
         {
 115  4
             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  4
     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  4
         Class c = null;
 138  
         try
 139  
         {
 140  4
             c = Class.forName(className);
 141  
         }
 142  0
         catch (Throwable t)
 143  
         {
 144  0
             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  0
             if (t instanceof Error)
 152  
             {
 153  0
                 throw (Error) t.fillInStackTrace();
 154  
             }
 155  4
         }
 156  4
         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<JobEntry> resultSet2Objects(java.sql.ResultSet results)
 170  
             throws TorqueException
 171  
     {
 172  
         try
 173  
         {
 174  0
             QueryDataSet qds = null;
 175  0
             List<Record> rows = null;
 176  
             try
 177  
             {
 178  0
                 qds = new QueryDataSet(results);
 179  0
                 rows = getSelectResults(qds);
 180  
             }
 181  
             finally
 182  
             {
 183  0
                 if (qds != null)
 184  
                 {
 185  0
                     qds.close();
 186  
                 }
 187  
             }
 188  
 
 189  0
             return populateObjects(rows);
 190  
         }
 191  0
         catch (SQLException e)
 192  
         {
 193  0
             throw new TorqueException(e);
 194  
         }
 195  0
         catch (DataSetException e)
 196  
         {
 197  0
             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  0
         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  0
         correctBooleans(criteria);
 231  
 
 232  0
         setDbName(criteria);
 233  
 
 234  0
         if (con == null)
 235  
         {
 236  0
             return BasePeer.doInsert(criteria);
 237  
         }
 238  
         else
 239  
         {
 240  0
             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  0
         criteria.addSelectColumn(JOB_ID);
 255  0
         criteria.addSelectColumn(SECOND);
 256  0
         criteria.addSelectColumn(MINUTE);
 257  0
         criteria.addSelectColumn(HOUR);
 258  0
         criteria.addSelectColumn(WEEK_DAY);
 259  0
         criteria.addSelectColumn(DAY_OF_MONTH);
 260  0
         criteria.addSelectColumn(TASK);
 261  0
         criteria.addSelectColumn(EMAIL);
 262  0
         criteria.addSelectColumn(PROPERTY);
 263  0
     }
 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  0
         correctBooleans(criteria, getTableMap());
 277  0
     }
 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  0
             JobEntry obj = (JobEntry) cls.newInstance();
 296  0
             JobEntryPeer.populateObject(row, offset, obj);
 297  0
                 obj.setModified(false);
 298  0
             obj.setNew(false);
 299  
 
 300  0
             return obj;
 301  
         }
 302  0
         catch (InstantiationException e)
 303  
         {
 304  0
             throw new TorqueException(e);
 305  
         }
 306  0
         catch (IllegalAccessException e)
 307  
         {
 308  0
             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  0
             obj.setJobId(row.getValue(offset + 0).asInt());
 329  0
             obj.setSecond(row.getValue(offset + 1).asInt());
 330  0
             obj.setMinute(row.getValue(offset + 2).asInt());
 331  0
             obj.setHour(row.getValue(offset + 3).asInt());
 332  0
             obj.setWeekDay(row.getValue(offset + 4).asInt());
 333  0
             obj.setDayOfMonth(row.getValue(offset + 5).asInt());
 334  0
             obj.setTask(row.getValue(offset + 6).asString());
 335  0
             obj.setEmail(row.getValue(offset + 7).asString());
 336  0
             obj.setProperty(row.getValue(offset + 8).asBytes());
 337  
         }
 338  0
         catch (DataSetException e)
 339  
         {
 340  0
             throw new TorqueException(e);
 341  0
         }
 342  0
     }
 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<JobEntry> doSelect(Criteria criteria) throws TorqueException
 353  
     {
 354  0
         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<JobEntry> doSelect(Criteria criteria, Connection con)
 367  
         throws TorqueException
 368  
     {
 369  0
         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<Record> doSelectVillageRecords(Criteria criteria)
 383  
         throws TorqueException
 384  
     {
 385  0
         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<Record> doSelectVillageRecords(Criteria criteria, Connection con)
 399  
         throws TorqueException
 400  
     {
 401  0
         if (criteria.getSelectColumns().size() == 0)
 402  
         {
 403  0
             addSelectColumns(criteria);
 404  
         }
 405  0
         correctBooleans(criteria);
 406  
 
 407  0
         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  0
         if (con == null)
 412  
         {
 413  0
             return BasePeer.doSelect(criteria);
 414  
         }
 415  
         else
 416  
         {
 417  0
             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<JobEntry> populateObjects(List<Record> records)
 429  
         throws TorqueException
 430  
     {
 431  0
         List<JobEntry> results = new ArrayList<JobEntry>(records.size());
 432  
 
 433  
         // populate the object(s)
 434  0
         for (int i = 0; i < records.size(); i++)
 435  
         {
 436  0
             Record row =  records.get(i);
 437  0
             results.add(JobEntryPeer.row2Object(row, 1,
 438  
                 JobEntryPeer.getOMClass()));
 439  
         }
 440  0
         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  0
         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  0
          BaseJobEntryPeer
 469  
             .doUpdate(criteria, (Connection) null);
 470  0
     }
 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  0
         Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
 487  0
         correctBooleans(criteria);
 488  
 
 489  
 
 490  0
          selectCriteria.put(JOB_ID, criteria.remove(JOB_ID));
 491  
 
 492  
 
 493  
 
 494  
 
 495  
 
 496  
 
 497  
 
 498  
 
 499  
 
 500  0
         setDbName(criteria);
 501  
 
 502  0
         if (con == null)
 503  
         {
 504  0
             BasePeer.doUpdate(selectCriteria, criteria);
 505  
         }
 506  
         else
 507  
         {
 508  0
             BasePeer.doUpdate(selectCriteria, criteria, con);
 509  
         }
 510  0
     }
 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  0
          JobEntryPeer
 522  
             .doDelete(criteria, (Connection) null);
 523  0
      }
 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  0
         correctBooleans(criteria);
 539  
 
 540  0
         setDbName(criteria);
 541  
 
 542  0
         if (con == null)
 543  
         {
 544  0
             BasePeer.doDelete(criteria, TABLE_NAME);
 545  
         }
 546  
         else
 547  
         {
 548  0
             BasePeer.doDelete(criteria, TABLE_NAME, con);
 549  
         }
 550  0
      }
 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<JobEntry> doSelect(JobEntry obj) throws TorqueException
 559  
     {
 560  0
         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  0
         obj.setPrimaryKey(doInsert(buildCriteria(obj)));
 572  0
         obj.setNew(false);
 573  0
         obj.setModified(false);
 574  0
     }
 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  0
         doUpdate(buildCriteria(obj));
 584  0
         obj.setModified(false);
 585  0
     }
 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  0
         doDelete(buildSelectCriteria(obj));
 595  0
     }
 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  0
         obj.setPrimaryKey(doInsert(buildCriteria(obj), con));
 611  0
         obj.setNew(false);
 612  0
         obj.setModified(false);
 613  0
     }
 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  0
         doUpdate(buildCriteria(obj), con);
 629  0
         obj.setModified(false);
 630  0
     }
 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  0
         doDelete(buildSelectCriteria(obj), con);
 646  0
     }
 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  0
         BaseJobEntryPeer
 658  
            .doDelete(pk, (Connection) null);
 659  0
     }
 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  0
         doDelete(buildCriteria(pk), con);
 675  0
     }
 676  
 
 677  
     /** Build a Criteria object from an ObjectKey */
 678  
     public static Criteria buildCriteria( ObjectKey pk )
 679  
     {
 680  0
         Criteria criteria = new Criteria();
 681  0
             criteria.add(JOB_ID, pk);
 682  0
         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  0
         Criteria criteria = new Criteria(DATABASE_NAME);
 689  0
         if (!obj.isNew())
 690  0
         criteria.add(JOB_ID, obj.getJobId());
 691  0
         criteria.add(SECOND, obj.getSecond());
 692  0
         criteria.add(MINUTE, obj.getMinute());
 693  0
         criteria.add(HOUR, obj.getHour());
 694  0
         criteria.add(WEEK_DAY, obj.getWeekDay());
 695  0
         criteria.add(DAY_OF_MONTH, obj.getDayOfMonth());
 696  0
         criteria.add(TASK, obj.getTask());
 697  0
         criteria.add(EMAIL, obj.getEmail());
 698  0
         criteria.add(PROPERTY, obj.getProperty());
 699  0
         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  0
         Criteria criteria = new Criteria(DATABASE_NAME);
 706  0
         if (!obj.isNew())
 707  
         {
 708  0
             criteria.add(JOB_ID, obj.getJobId());
 709  
         }
 710  0
             criteria.add(SECOND, obj.getSecond());
 711  0
             criteria.add(MINUTE, obj.getMinute());
 712  0
             criteria.add(HOUR, obj.getHour());
 713  0
             criteria.add(WEEK_DAY, obj.getWeekDay());
 714  0
             criteria.add(DAY_OF_MONTH, obj.getDayOfMonth());
 715  0
             criteria.add(TASK, obj.getTask());
 716  0
             criteria.add(EMAIL, obj.getEmail());
 717  0
         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  0
         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  0
         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  0
         Connection db = null;
 765  0
         JobEntry retVal = null;
 766  
         try
 767  
         {
 768  0
             db = Torque.getConnection(DATABASE_NAME);
 769  0
             retVal = retrieveByPK(pk, db);
 770  
         }
 771  
         finally
 772  
         {
 773  0
             Torque.closeConnection(db);
 774  0
         }
 775  0
         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  0
         Criteria criteria = buildCriteria(pk);
 792  0
         List<JobEntry> v = doSelect(criteria, con);
 793  0
         if (v.size() == 0)
 794  
         {
 795  0
             throw new NoRowsException("Failed to select a row.");
 796  
         }
 797  0
         else if (v.size() > 1)
 798  
         {
 799  0
             throw new TooManyRowsException("Failed to select only one row.");
 800  
         }
 801  
         else
 802  
         {
 803  0
             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<JobEntry> retrieveByPKs(List<ObjectKey> pks)
 815  
         throws TorqueException
 816  
     {
 817  0
         Connection db = null;
 818  0
         List<JobEntry> retVal = null;
 819  
         try
 820  
         {
 821  0
            db = Torque.getConnection(DATABASE_NAME);
 822  0
            retVal = retrieveByPKs(pks, db);
 823  
         }
 824  
         finally
 825  
         {
 826  0
             Torque.closeConnection(db);
 827  0
         }
 828  0
         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<JobEntry> retrieveByPKs( List<ObjectKey> pks, Connection dbcon )
 840  
         throws TorqueException
 841  
     {
 842  0
         List<JobEntry> objs = null;
 843  0
         if (pks == null || pks.size() == 0)
 844  
         {
 845  0
             objs = new LinkedList<JobEntry>();
 846  
         }
 847  
         else
 848  
         {
 849  0
             Criteria criteria = new Criteria();
 850  0
             criteria.addIn( JOB_ID, pks );
 851  0
         objs = doSelect(criteria, dbcon);
 852  
         }
 853  0
         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  0
         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  0
         if (crit.getDbName() == Torque.getDefaultDB())
 883  
         {
 884  0
             crit.setDbName(DATABASE_NAME);
 885  
         }
 886  0
     }
 887  
     
 888  
 
 889  
     // The following methods wrap some methods in BasePeer
 890  
     // to have more support for Java5 generic types in the Peer
 891  
     
 892  
     /**
 893  
      * Utility method which executes a given sql statement.  This
 894  
      * method should be used for select statements only.  Use
 895  
      * executeStatement for update, insert, and delete operations.
 896  
      *
 897  
      * @param queryString A String with the sql statement to execute.
 898  
      * @return List of Record objects.
 899  
      * @throws TorqueException Any exceptions caught during processing will be
 900  
      *         rethrown wrapped into a TorqueException.
 901  
      * @see org.apache.torque.util.BasePeer#executeQuery(String)
 902  
      */
 903  
     public static List<Record> executeQuery(String queryString) throws TorqueException
 904  
     {
 905  0
         return BasePeer.executeQuery(queryString);
 906  
     }
 907  
 
 908  
     /**
 909  
      * Utility method which executes a given sql statement.  This
 910  
      * method should be used for select statements only.  Use
 911  
      * executeStatement for update, insert, and delete operations.
 912  
      *
 913  
      * @param queryString A String with the sql statement to execute.
 914  
      * @param dbName The database to connect to.
 915  
      * @return List of Record objects.
 916  
      * @throws TorqueException Any exceptions caught during processing will be
 917  
      *         rethrown wrapped into a TorqueException.
 918  
      * @see org.apache.torque.util.BasePeer#executeQuery(String,String)
 919  
      */
 920  
     public static List<Record> executeQuery(String queryString, String dbName)
 921  
         throws TorqueException
 922  
     {
 923  0
         return BasePeer.executeQuery(queryString,dbName);
 924  
     }
 925  
     
 926  
 
 927  
     /**
 928  
      * Method for performing a SELECT.  Returns all results.
 929  
      *
 930  
      * @param queryString A String with the sql statement to execute.
 931  
      * @param dbName The database to connect to.
 932  
      * @param singleRecord Whether or not we want to select only a
 933  
      * single record.
 934  
      * @return List of Record objects.
 935  
      * @throws TorqueException Any exceptions caught during processing will be
 936  
      *         rethrown wrapped into a TorqueException.
 937  
      * @see org.apache.torque.util.BasePeer#executeQuery(String,String,boolean)
 938  
      */
 939  
     public static List<Record> executeQuery(
 940  
         String queryString,
 941  
         String dbName,
 942  
         boolean singleRecord)
 943  
         throws TorqueException
 944  
     {
 945  0
         return BasePeer.executeQuery(queryString,dbName,singleRecord);
 946  
     }
 947  
 
 948  
     /**
 949  
      * Method for performing a SELECT.  Returns all results.
 950  
      *
 951  
      * @param queryString A String with the sql statement to execute.
 952  
      * @param singleRecord Whether or not we want to select only a
 953  
      * single record.
 954  
      * @param con A Connection.
 955  
      * @return List of Record objects.
 956  
      * @throws TorqueException Any exceptions caught during processing will be
 957  
      *         rethrown wrapped into a TorqueException.
 958  
      * @see org.apache.torque.util.BasePeer#executeQuery(String,boolean,Connection)
 959  
      */
 960  
     public static List<Record> executeQuery(
 961  
         String queryString,
 962  
         boolean singleRecord,
 963  
         Connection con)
 964  
         throws TorqueException
 965  
     {
 966  0
         return BasePeer.executeQuery(queryString,singleRecord,con);
 967  
     }
 968  
 
 969  
     /**
 970  
      * Method for performing a SELECT.
 971  
      *
 972  
      * @param queryString A String with the sql statement to execute.
 973  
      * @param start The first row to return.
 974  
      * @param numberOfResults The number of rows to return.
 975  
      * @param dbName The database to connect to.
 976  
      * @param singleRecord Whether or not we want to select only a
 977  
      * single record.
 978  
      * @return List of Record objects.
 979  
      * @throws TorqueException Any exceptions caught during processing will be
 980  
      *         rethrown wrapped into a TorqueException.
 981  
      * @see org.apache.torque.util.BasePeer#executeQuery(String,int,int,String,boolean)
 982  
      */
 983  
     public static List<Record> executeQuery(
 984  
         String queryString,
 985  
         int start,
 986  
         int numberOfResults,
 987  
         String dbName,
 988  
         boolean singleRecord)
 989  
         throws TorqueException
 990  
     {
 991  0
         return BasePeer.executeQuery(queryString,start,numberOfResults,dbName,singleRecord);
 992  
     }
 993  
 
 994  
     /**
 995  
      * Method for performing a SELECT.  Returns all results.
 996  
      *
 997  
      * @param queryString A String with the sql statement to execute.
 998  
      * @param start The first row to return.
 999  
      * @param numberOfResults The number of rows to return.
 1000  
      * @param singleRecord Whether or not we want to select only a
 1001  
      * single record.
 1002  
      * @param con A Connection.
 1003  
      * @return List of Record objects.
 1004  
      * @throws TorqueException Any exceptions caught during processing will be
 1005  
      *         rethrown wrapped into a TorqueException.
 1006  
      * @see org.apache.torque.util.BasePeer#executeQuery(String,int,int,String,boolean,Connection)
 1007  
      */
 1008  
     public static List<Record> executeQuery(
 1009  
         String queryString,
 1010  
         int start,
 1011  
         int numberOfResults,
 1012  
         boolean singleRecord,
 1013  
         Connection con)
 1014  
         throws TorqueException
 1015  
     {
 1016  0
         return BasePeer.executeQuery(queryString,start,numberOfResults,singleRecord,con);
 1017  
     }
 1018  
 
 1019  
     /**
 1020  
      * Returns all records in a QueryDataSet as a List of Record
 1021  
      * objects.  Used for functionality like util.LargeSelect.
 1022  
      *
 1023  
      * @see #getSelectResults(QueryDataSet, int, int, boolean)
 1024  
      * @param qds the QueryDataSet
 1025  
      * @return a List of Record objects
 1026  
      * @throws TorqueException Any exceptions caught during processing will be
 1027  
      *         rethrown wrapped into a TorqueException.
 1028  
      * @see org.apache.torque.util.BasePeer#getSelectResults(QueryDataSet)
 1029  
      */
 1030  
     public static List<Record> getSelectResults(QueryDataSet qds)
 1031  
         throws TorqueException
 1032  
     {
 1033  0
         return BasePeer.getSelectResults(qds);
 1034  
     }
 1035  
     
 1036  
     /**
 1037  
      * Returns all records in a QueryDataSet as a List of Record
 1038  
      * objects.  Used for functionality like util.LargeSelect.
 1039  
      *
 1040  
      * @see #getSelectResults(QueryDataSet, int, int, boolean)
 1041  
      * @param qds the QueryDataSet
 1042  
      * @param singleRecord
 1043  
      * @return a List of Record objects
 1044  
      * @throws TorqueException Any exceptions caught during processing will be
 1045  
      *         rethrown wrapped into a TorqueException.
 1046  
      * @see org.apache.torque.util.BasePeer#getSelectResults(QueryDataSet,boolean)
 1047  
      */
 1048  
     public static List<Record> getSelectResults(QueryDataSet qds, boolean singleRecord)
 1049  
         throws TorqueException
 1050  
     {
 1051  0
         return BasePeer.getSelectResults(qds,singleRecord);
 1052  
     }
 1053  
     
 1054  
     /**
 1055  
      * Returns numberOfResults records in a QueryDataSet as a List
 1056  
      * of Record objects.  Starting at record 0.  Used for
 1057  
      * functionality like util.LargeSelect.
 1058  
      *
 1059  
      * @see #getSelectResults(QueryDataSet, int, int, boolean)
 1060  
      * @param qds the QueryDataSet
 1061  
      * @param numberOfResults
 1062  
      * @param singleRecord
 1063  
      * @return a List of Record objects
 1064  
      * @throws TorqueException Any exceptions caught during processing will be
 1065  
      *         rethrown wrapped into a TorqueException.
 1066  
      * @see org.apache.torque.util.BasePeer#getSelectResults(QueryDataSet,int,boolean)
 1067  
      */
 1068  
     public static List<Record> getSelectResults(
 1069  
         QueryDataSet qds,
 1070  
         int numberOfResults,
 1071  
         boolean singleRecord)
 1072  
         throws TorqueException
 1073  
     {
 1074  0
         return BasePeer.getSelectResults(qds,numberOfResults,singleRecord);
 1075  
     }
 1076  
 
 1077  
     /**
 1078  
      * Returns numberOfResults records in a QueryDataSet as a List
 1079  
      * of Record objects.  Starting at record start.  Used for
 1080  
      * functionality like util.LargeSelect.
 1081  
      *
 1082  
      * @param qds The <code>QueryDataSet</code> to extract results
 1083  
      * from.
 1084  
      * @param start The index from which to start retrieving
 1085  
      * <code>Record</code> objects from the data set.
 1086  
      * @param numberOfResults The number of results to return (or
 1087  
      * <code> -1</code> for all results).
 1088  
      * @param singleRecord Whether or not we want to select only a
 1089  
      * single record.
 1090  
      * @return A <code>List</code> of <code>Record</code> objects.
 1091  
      * @exception TorqueException If any <code>Exception</code> occurs.
 1092  
      * @see org.apache.torque.util.BasePeer#getSelectResults(QueryDataSet,int,int,boolean)
 1093  
      */
 1094  
     public static List getSelectResults(
 1095  
         QueryDataSet qds,
 1096  
         int start,
 1097  
         int numberOfResults,
 1098  
         boolean singleRecord)
 1099  
         throws TorqueException
 1100  
     {
 1101  0
         return BasePeer.getSelectResults(qds,start,numberOfResults,singleRecord);
 1102  
     }
 1103  
 
 1104  
     /**
 1105  
      * Performs a SQL <code>select</code> using a PreparedStatement.
 1106  
      * Note: this method does not handle null criteria values.
 1107  
      *
 1108  
      * @param criteria
 1109  
      * @param con
 1110  
      * @return a List of Record objects.
 1111  
      * @throws TorqueException Error performing database query.
 1112  
      * @see org.apache.torque.util.BasePeer#doPSSelect(Criteria,Connection)
 1113  
      */
 1114  
     public static List<Record> doPSSelect(Criteria criteria, Connection con)
 1115  
         throws TorqueException
 1116  
     {
 1117  0
         return BasePeer.doPSSelect(criteria,con);
 1118  
     }
 1119  
 
 1120  
     /**
 1121  
      * Do a Prepared Statement select according to the given criteria
 1122  
      *
 1123  
      * @param criteria
 1124  
      * @return a List of Record objects.
 1125  
      * @throws TorqueException Any exceptions caught during processing will be
 1126  
      *         rethrown wrapped into a TorqueException.
 1127  
      * @see org.apache.torque.util.BasePeer#doPSSelect(Criteria)
 1128  
      */
 1129  
     public static List<Record> doPSSelect(Criteria criteria) throws TorqueException
 1130  
     {
 1131  0
         return BasePeer.doPSSelect(criteria);
 1132  
     }
 1133  
 }