##### Coverage Report - org.apache.turbine.services.schedule.BaseJobEntryTorquePeerImpl

Classes in this File | Line Coverage | Branch Coverage | Complexity
BaseJobEntryTorquePeerImpl |
0% | 0/158
0% | 0/40
| 1.935483870967742;1,935

1 |  |
     package org.apache.turbine.services.schedule;
2 |  |
3 |  |
     import java.sql.Blob;
4 |  |
     import java.sql.Clob;
5 |  |
     import java.sql.Connection;
6 |  |
     import java.sql.SQLException;
7 |  |
     import java.sql.ResultSet;
8 |  |
     import java.sql.PreparedStatement;
9 |  |
     import java.sql.Types;
10 |  |
     import java.io.IOException;
11 |  |
     import java.io.InputStream;
12 |  |
     import java.io.ByteArrayInputStream;
13 |  |
     import java.io.ByteArrayOutputStream;
14 |  |
     import java.io.Reader;
15 |  |
     import java.io.StringReader;
16 |  |
     import java.io.StringWriter;
17 |  |
     import java.util.ArrayList;
18 |  |
     import java.util.Collection;
19 |  |
     import java.util.Date;
20 |  |
     import java.util.Iterator;
21 |  |
     import java.util.LinkedList;
22 |  |
     import java.util.List;
23 |  |
     import java.util.Map;
24 |  |
     import java.util.HashMap;
25 |  |
     import java.util.Set;
26 |  |
     import java.util.HashSet;
27 |  |
28 |  |
     import org.apache.commons.lang.ObjectUtils;
29 |  |
     import org.apache.commons.logging.Log;
30 |  |
     import org.apache.commons.logging.LogFactory;
31 |  |
     import org.apache.torque.NoRowsException;
32 |  |
     import org.apache.torque.OptimisticLockingFailedException;
33 |  |
     import org.apache.torque.TooManyRowsException;
34 |  |
     import org.apache.torque.Torque;
35 |  |
     import org.apache.torque.TorqueException;
36 |  |
     import org.apache.torque.TorqueRuntimeException;
37 |  |
     import org.apache.torque.criteria.Criteria;
38 |  |
     import org.apache.torque.criteria.Criterion;
39 |  |
     import org.apache.torque.om.mapper.RecordMapper;
40 |  |
     import org.apache.torque.om.mapper.CompositeMapper;
41 |  |
     import org.apache.torque.om.DateKey;
42 |  |
     import org.apache.torque.om.NumberKey;
43 |  |
     import org.apache.torque.om.StringKey;
44 |  |
     import org.apache.torque.om.ObjectKey;
45 |  |
     import org.apache.torque.om.SimpleKey;
46 |  |
     import org.apache.torque.om.ComboKey;
47 |  |
     import org.apache.torque.map.TableMap;
48 |  |
     import org.apache.torque.util.Transaction;
49 |  |
     import org.apache.torque.util.ColumnValues;
50 |  |
     import org.apache.torque.util.JdbcTypedValue;
51 |  |
52 |  |
53 |  |
54 |  |
     /**
55 |  |
      * The skeleton for this class was autogenerated by Torque on:
56 |  |
      *
57 |  |
      * [Mon Dec 21 20:40:21 CET 2015]
58 |  |
      *
59 |  |
      * You should not use this class directly.  It should not even be
60 |  |
      * extended; all references should be to JobEntryTorquePeer
61 |  |
      */
62 |  |
63 |  |
     public abstract class BaseJobEntryTorquePeerImpl
64 |  |
         extends org.apache.torque.util.BasePeerImpl<JobEntryTorque>
65 |  |
     {
66 |  |
         /** The class log. */
67 | 0 |
         private static Log log = LogFactory.getLog(BaseJobEntryTorquePeerImpl.class);
68 |  |
69 |  |
         /** Serial version */
70 |  |
         private static final long serialVersionUID = 1450726821151L;
71 |  |
72 |  |
73 |  |
74 |  |
         /**
75 |  |
          * Constructor.
76 |  |
          * The recordMapper, tableMap and databaseName fields are correctly
77 |  |
          * initialized.
78 |  |
          */
79 |  |
         public BaseJobEntryTorquePeerImpl()
80 |  |
         {
81 | 0 |
             this(new JobEntryTorqueRecordMapper(),
82 |  |
                 JobEntryTorquePeer.TABLE,
83 |  |
                 JobEntryTorquePeer.DATABASE_NAME);
84 | 0 |
         }
85 |  |
86 |  |
         /**
87 |  |
          * Constructor providing the objects to be injected as parameters.
88 |  |
          *
89 |  |
          * @param recordMapper a record mapper to map JDBC result sets to objects
90 |  |
          * @param tableMap the default table map
91 |  |
          * @param databaseName the name of the database
92 |  |
          */
93 |  |
         public BaseJobEntryTorquePeerImpl(
94 |  |
                 RecordMapper<JobEntryTorque> recordMapper,
95 |  |
                 TableMap tableMap,
96 |  |
                 String databaseName)
97 |  |
         {
98 | 0 |
             super(recordMapper, tableMap, databaseName);
99 | 0 |
         }
100 |  |
101 |  |
102 |  |
         /**
103 |  |
          * Selects JobEntryTorque objects from the database which have
104 |  |
          * the same content as the passed object.
105 |  |
          *
106 |  |
          * @return The list of selected objects, not null.
107 |  |
          *
108 |  |
          * @throws TorqueException Any exceptions caught during processing will be
109 |  |
          *         rethrown wrapped into a TorqueException.
110 |  |
          */
111 |  |
         public List<JobEntryTorque> doSelect(JobEntryTorque obj)
112 |  |
                 throws TorqueException
113 |  |
         {
114 | 0 |
             return doSelect(buildSelectCriteria(obj));
115 |  |
         }
116 |  |
117 |  |
         /**
118 |  |
          * Selects at most one JobEntryTorque object from the database
119 |  |
          * which has the same content as the passed object.
120 |  |
          *
121 |  |
          * @return the selected Object, or null if no object was selected.
122 |  |
          *
123 |  |
          * @throws TorqueException Any exceptions caught during processing will be
124 |  |
          *         rethrown wrapped into a TorqueException.
125 |  |
          */
126 |  |
         public JobEntryTorque doSelectSingleRecord(
127 |  |
                     JobEntryTorque obj)
128 |  |
                 throws TorqueException
129 |  |
         {
130 | 0 |
             List<JobEntryTorque> jobEntryTorqueList = doSelect(obj);
131 | 0 |
             JobEntryTorque jobEntryTorque = null;
132 | 0 |
             if (jobEntryTorqueList.size() > 1)
133 |  |
             {
134 | 0 |
                 throw new TooManyRowsException("Object " + obj
135 |  |
                     + " matched more than one record");
136 |  |
             }
137 | 0 |
             if (!jobEntryTorqueList.isEmpty())
138 |  |
             {
139 | 0 |
                 jobEntryTorque = jobEntryTorqueList.get(0);
140 |  |
             }
141 | 0 |
             return jobEntryTorque;
142 |  |
         }
143 |  |
144 |  |
         /**
145 |  |
          * Returns a new instance of the Data object class
146 |  |
          */
147 |  |
         public JobEntryTorque getDbObjectInstance()
148 |  |
         {
149 | 0 |
             return new JobEntryTorque();
150 |  |
         }
151 |  |
152 |  |
153 |  |
         /**
154 |  |
          * Method to do inserts.
155 |  |
          *
156 |  |
          * @param columnValues the values to insert.
157 |  |
          *
158 |  |
          * @return the primary key of the inserted row.
159 |  |
          *
160 |  |
          * @throws TorqueException Any exceptions caught during processing will be
161 |  |
          *         rethrown wrapped into a TorqueException.
162 |  |
          */
163 |  |
         public ObjectKey doInsert(ColumnValues columnValues) throws TorqueException
164 |  |
         {
165 | 0 |
             Connection connection = null;
166 |  |
             try
167 |  |
             {
168 | 0 |
                 connection = Transaction.begin(
169 |  |
                         JobEntryTorquePeer.DATABASE_NAME);
170 | 0 |
                 ObjectKey result = doInsert(columnValues, connection);
171 | 0 |
                 Transaction.commit(connection);
172 | 0 |
                 connection = null;
173 | 0 |
                 return result;
174 |  |
             }
175 |  |
             finally
176 |  |
             {
177 | 0 |
                 if (connection != null)
178 |  |
                 {
179 | 0 |
                     Transaction.safeRollback(connection);
180 |  |
                 }
181 |  |
             }
182 |  |
         }
183 |  |
184 |  |
         /**
185 |  |
          * Method to do inserts.  This method is to be used during a transaction,
186 |  |
          * otherwise use the doInsert(Criteria) method.
187 |  |
          *
188 |  |
          * @param columnValues the values to insert.
189 |  |
          * @param con the connection to use, not null.
190 |  |
          *
191 |  |
          * @return the primary key of the inserted row.
192 |  |
          *
193 |  |
          * @throws TorqueException Any exceptions caught during processing will be
194 |  |
          *         rethrown wrapped into a TorqueException.
195 |  |
          */
196 |  |
         public ObjectKey doInsert(ColumnValues columnValues, Connection con)
197 |  |
             throws TorqueException
198 |  |
         {
199 | 0 |
             correctBooleans(columnValues);
200 | 0 |
             return super.doInsert(columnValues, con);
201 |  |
         }
202 |  |
203 |  |
         /**
204 |  |
          * Method to do inserts
205 |  |
          *
206 |  |
          * @throws TorqueException Any exceptions caught during processing will be
207 |  |
          *         rethrown wrapped into a TorqueException.
208 |  |
          */
209 |  |
         public void doInsert(JobEntryTorque obj) throws TorqueException
210 |  |
         {
211 | 0 |
             obj.setPrimaryKey(doInsert(buildColumnValues(obj)));
212 | 0 |
             obj.setNew(false);
213 | 0 |
             obj.setModified(false);
214 | 0 |
         }
215 |  |
216 |  |
         /**
217 |  |
          * Method to do inserts.  This method is to be used during a transaction,
218 |  |
          * otherwise use the doInsert(JobEntryTorque) method.  It will take
219 |  |
          * care of the connection details internally.
220 |  |
          *
221 |  |
          * @param obj the data object to insert into the database.
222 |  |
          * @param con the connection to use
223 |  |
          * @throws TorqueException Any exceptions caught during processing will be
224 |  |
          *         rethrown wrapped into a TorqueException.
225 |  |
          */
226 |  |
         public void doInsert(JobEntryTorque obj, Connection con)
227 |  |
             throws TorqueException
228 |  |
         {
229 | 0 |
             ObjectKey primaryKey = doInsert(buildColumnValues(obj), con);
230 | 0 |
             if (primaryKey != null)
231 |  |
             {
232 | 0 |
                 obj.setPrimaryKey(primaryKey);
233 |  |
             }
234 | 0 |
             obj.setNew(false);
235 | 0 |
             obj.setModified(false);
236 | 0 |
         }
237 |  |
238 |  |
         /**
239 |  |
          * Method to do updates.
240 |  |
          *
241 |  |
          * @param columnValues the values to update plus the primary key
242 |  |
          *        identifying the row to update.
243 |  |
          *
244 |  |
          * @return the number of affected rows.
245 |  |
          *
246 |  |
          * @throws TorqueException Any exceptions caught during processing will be
247 |  |
          *         rethrown wrapped into a TorqueException.
248 |  |
          */
249 |  |
         public int doUpdate(ColumnValues columnValues) throws TorqueException
250 |  |
         {
251 | 0 |
             Connection connection = null;
252 |  |
             try
253 |  |
             {
254 | 0 |
                 connection = Transaction.begin(
255 |  |
                         JobEntryTorquePeer.DATABASE_NAME);
256 | 0 |
                 int result = doUpdate(columnValues, connection);
257 | 0 |
                 Transaction.commit(connection);
258 | 0 |
                 connection = null;
259 | 0 |
                 return result;
260 |  |
             }
261 |  |
             finally
262 |  |
             {
263 | 0 |
                 if (connection != null)
264 |  |
                 {
265 | 0 |
                     Transaction.safeRollback(connection);
266 |  |
                 }
267 |  |
             }
268 |  |
         }
269 |  |
270 |  |
         /**
271 |  |
          * Method to do updates.  This method is to be used during a transaction,
272 |  |
          * otherwise use the doUpdate(Criteria) method.
273 |  |
          *
274 |  |
          * @param columnValues the values to update plus the primary key
275 |  |
          *        identifying the row to update.
276 |  |
          * @param con the connection to use, not null.
277 |  |
          *
278 |  |
          * @return the number of affected rows.
279 |  |
          *
280 |  |
          * @throws TorqueException Any exceptions caught during processing will be
281 |  |
          *         rethrown wrapped into a TorqueException.
282 |  |
          */
283 |  |
         public int doUpdate(ColumnValues columnValues, Connection con)
284 |  |
             throws TorqueException
285 |  |
         {
286 | 0 |
             Criteria selectCriteria
287 |  |
                     = new Criteria(JobEntryTorquePeer.DATABASE_NAME);
288 | 0 |
             correctBooleans(columnValues);
289 |  |
290 | 0 |
             selectCriteria.where(
291 |  |
                     JobEntryTorquePeer.JOB_ID,
292 |  |
                     columnValues.remove(JobEntryTorquePeer.JOB_ID).getValue());
293 |  |
294 |  |
295 | 0 |
             int rowCount = doUpdate(selectCriteria, columnValues, con);
296 | 0 |
             return rowCount;
297 |  |
         }
298 |  |
299 |  |
         /**
300 |  |
          * Updates an JobEntryTorque in the database.
301 |  |
          * The primary key is used to identify the object to update.
302 |  |
          *
303 |  |
          * @param obj the data object to update in the database.
304 |  |
          *
305 |  |
          * @return the number of affected rows.
306 |  |
          *
307 |  |
          * @throws TorqueException Any exceptions caught during processing will be
308 |  |
          *         rethrown wrapped into a TorqueException.
309 |  |
          */
310 |  |
         public int doUpdate(JobEntryTorque obj) throws TorqueException
311 |  |
         {
312 | 0 |
             ColumnValues columnValues = buildColumnValues(obj);
313 | 0 |
             int result = doUpdate(columnValues);
314 | 0 |
             obj.setModified(false);
315 | 0 |
             return result;
316 |  |
         }
317 |  |
318 |  |
         /**
319 |  |
          * Updates a JobEntryTorque in the database.
320 |  |
          * The primary key is used to identify the object to update.
321 |  |
          * This method is to be used during a transaction,
322 |  |
          * otherwise the doUpdate(JobEntryTorque) method can be used.
323 |  |
          *
324 |  |
          * @param obj the data object to update in the database.
325 |  |
          * @param con the connection to use, not null.
326 |  |
327 |  |
          * @return the number of affected rows.
328 |  |
          *
329 |  |
          * @throws TorqueException Any exceptions caught during processing will be
330 |  |
          *         rethrown wrapped into a TorqueException.
331 |  |
          */
332 |  |
         public int doUpdate(JobEntryTorque obj, Connection con)
333 |  |
             throws TorqueException
334 |  |
         {
335 | 0 |
             ColumnValues columnValues = buildColumnValues(obj);
336 | 0 |
             int result = doUpdate(columnValues, con);
337 | 0 |
             obj.setModified(false);
338 | 0 |
             return result;
339 |  |
         }
340 |  |
341 |  |
         /**
342 |  |
          * Deletes a data object, i.e. a row in a table, in the database.
343 |  |
          *
344 |  |
          * @param obj the data object to delete in the database, not null.
345 |  |
          *
346 |  |
          * @return the number of deleted rows.
347 |  |
          *
348 |  |
          * @throws TorqueException Any exceptions caught during processing will be
349 |  |
          *         rethrown wrapped into a TorqueException.
350 |  |
          */
351 |  |
         public int doDelete(JobEntryTorque obj) throws TorqueException
352 |  |
         {
353 | 0 |
             int result = doDelete(buildCriteria(obj.getPrimaryKey()));
354 | 0 |
             obj.setDeleted(true);
355 | 0 |
             return result;
356 |  |
         }
357 |  |
358 |  |
         /**
359 |  |
          * Deletes a data object, i.e. a row in a table, in the database.
360 |  |
          * This method is to be used during a transaction, otherwise use the
361 |  |
          * doDelete(JobEntryTorque) method.
362 |  |
          *
363 |  |
          * @param obj the data object to delete in the database, not null.
364 |  |
          * @param con the connection to use, not null.
365 |  |
          *
366 |  |
          * @return the number of deleted rows.
367 |  |
          *
368 |  |
          * @throws TorqueException Any exceptions caught during processing will be
369 |  |
          *         rethrown wrapped into a TorqueException.
370 |  |
          */
371 |  |
         public int doDelete(JobEntryTorque obj, Connection con)
372 |  |
             throws TorqueException
373 |  |
         {
374 | 0 |
             int result = doDelete(buildCriteria(obj.getPrimaryKey()), con);
375 | 0 |
             obj.setDeleted(true);
376 | 0 |
             return result;
377 |  |
         }
378 |  |
379 |  |
         /**
380 |  |
          * Deletes data objects, i.e. rows in a table, in the database.
381 |  |
          *
382 |  |
          * @param objects the data object to delete in the database, not null,
383 |  |
          *        may not contain null.
384 |  |
          *
385 |  |
          * @return the number of deleted rows.
386 |  |
          *
387 |  |
          * @throws TorqueException Any exceptions caught during processing will be
388 |  |
          *         rethrown wrapped into a TorqueException.
389 |  |
          */
390 |  |
         public int doDelete(Collection<JobEntryTorque> objects)
391 |  |
                 throws TorqueException
392 |  |
         {
393 | 0 |
             int result = doDelete(buildPkCriteria(objects));
394 | 0 |
             for (JobEntryTorque object : objects)
395 |  |
             {
396 | 0 |
                 object.setDeleted(true);
397 | 0 |
             }
398 | 0 |
             return result;
399 |  |
         }
400 |  |
401 |  |
         /**
402 |  |
          * Deletes data objects, i.e. rows in a table, in the database.
403 |  |
          * This method uses the passed connection to delete the rows;
404 |  |
          * if a transaction is open in the connection, the deletion happens inside
405 |  |
          * this transaction.
406 |  |
          *
407 |  |
          * @param objects the data objects to delete in the database, not null,
408 |  |
          *        may not contain null.
409 |  |
          * @param con the connection to use for deleting, not null.
410 |  |
          *
411 |  |
          * @return the number of deleted rows.
412 |  |
          *
413 |  |
          * @throws TorqueException Any exceptions caught during processing will be
414 |  |
          *         rethrown wrapped into a TorqueException.
415 |  |
          */
416 |  |
         public int doDelete(
417 |  |
                 Collection<JobEntryTorque> objects,
418 |  |
                 Connection con)
419 |  |
             throws TorqueException
420 |  |
         {
421 | 0 |
             int result = doDelete(buildPkCriteria(objects), con);
422 | 0 |
             for (JobEntryTorque object : objects)
423 |  |
             {
424 | 0 |
                 object.setDeleted(true);
425 | 0 |
             }
426 | 0 |
             return result;
427 |  |
         }
428 |  |
429 |  |
         /**
430 |  |
          * Deletes a row in the database.
431 |  |
          *
432 |  |
          * @param pk the ObjectKey that identifies the row to delete.
433 |  |
          *
434 |  |
          * @return the number of deleted rows.
435 |  |
          *
436 |  |
          * @throws TorqueException Any exceptions caught during processing will be
437 |  |
          *         rethrown wrapped into a TorqueException.
438 |  |
          */
439 |  |
         public int doDelete(ObjectKey pk) throws TorqueException
440 |  |
         {
441 | 0 |
             Connection connection = null;
442 |  |
             try
443 |  |
             {
444 | 0 |
                 connection = Transaction.begin(
445 |  |
                         JobEntryTorquePeer.DATABASE_NAME);
446 | 0 |
                 int deletedRows = doDelete(pk, connection);
447 | 0 |
                 Transaction.commit(connection);
448 | 0 |
                 connection = null;
449 | 0 |
                 return deletedRows;
450 |  |
             }
451 |  |
             finally
452 |  |
             {
453 | 0 |
                 if (connection != null)
454 |  |
                 {
455 | 0 |
                     Transaction.safeRollback(connection);
456 |  |
                 }
457 |  |
             }
458 |  |
         }
459 |  |
460 |  |
         /**
461 |  |
          * Deletes a row in the database.
462 |  |
          * This method is to be used during a transaction,
463 |  |
          * otherwise use the doDelete(ObjectKey) method.
464 |  |
          *
465 |  |
          * @param pk the ObjectKey that identifies the row to delete.
466 |  |
          * @param con the connection to use for deleting, not null.
467 |  |
          *
468 |  |
          * @return the number of deleted rows.
469 |  |
          *
470 |  |
          * @throws TorqueException Any exceptions caught during processing will be
471 |  |
          *         rethrown wrapped into a TorqueException.
472 |  |
          */
473 |  |
         public int doDelete(ObjectKey pk, Connection con)
474 |  |
             throws TorqueException
475 |  |
         {
476 | 0 |
             return doDelete(buildCriteria(pk), con);
477 |  |
         }
478 |  |
479 |  |
         /**
480 |  |
          * Build a Criteria object which selects all objects which have a given
481 |  |
          * primary key.
482 |  |
          *
483 |  |
          * @param pk the primary key value to build the criteria from, not null.
484 |  |
          */
485 |  |
         public Criteria buildCriteria(ObjectKey pk)
486 |  |
         {
487 | 0 |
             Criteria criteria = new Criteria();
488 | 0 |
             criteria.and(JobEntryTorquePeer.JOB_ID, pk);
489 | 0 |
             return criteria;
490 |  |
          }
491 |  |
492 |  |
         /**
493 |  |
          * Build a Criteria object which selects all objects which primary keys
494 |  |
          * are contained in the passed collection.
495 |  |
          *
496 |  |
          * @param pks the primary key values to build the criteria from, not null,
497 |  |
          *        may not contain null.
498 |  |
          */
499 |  |
         public Criteria buildCriteria(Collection<ObjectKey> pks)
500 |  |
         {
501 | 0 |
             Criteria criteria = new Criteria();
502 | 0 |
             criteria.andIn(JobEntryTorquePeer.JOB_ID, pks);
503 | 0 |
             return criteria;
504 |  |
          }
505 |  |
506 |  |
507 |  |
         /**
508 |  |
          * Build a Criteria object which selects all passed objects using their
509 |  |
          * primary key. Objects which do not yet have a primary key are ignored.
510 |  |
          *
511 |  |
          * @param objects the objects to build the criteria from, not null,
512 |  |
          *        may not contain null.
513 |  |
          */
514 |  |
         public Criteria buildPkCriteria(
515 |  |
                 Collection<JobEntryTorque> objects)
516 |  |
         {
517 | 0 |
             List<ObjectKey> pks = new ArrayList<ObjectKey>(objects.size());
518 | 0 |
             for (JobEntryTorque object : objects)
519 |  |
             {
520 | 0 |
                 ObjectKey pk = object.getPrimaryKey();
521 | 0 |
                 if (pk != null)
522 |  |
                 {
523 | 0 |
                     pks.add(pk);
524 |  |
                 }
525 | 0 |
             }
526 | 0 |
             return buildCriteria(pks);
527 |  |
         }
528 |  |
529 |  |
         /**
530 |  |
          * Build a Criteria object from the data object for this peer.
531 |  |
          * The primary key columns are only added if the object is not new.
532 |  |
          *
533 |  |
          * @param obj the object to build the criteria from, not null.
534 |  |
          */
535 |  |
         public Criteria buildCriteria(JobEntryTorque obj)
536 |  |
         {
537 | 0 |
             Criteria criteria = new Criteria(JobEntryTorquePeer.DATABASE_NAME);
538 | 0 |
             if (!obj.isNew())
539 |  |
             {
540 | 0 |
                 criteria.and(JobEntryTorquePeer.JOB_ID, obj.getJobId());
541 |  |
             }
542 | 0 |
             criteria.and(JobEntryTorquePeer.SECOND, obj.getSecond());
543 | 0 |
             criteria.and(JobEntryTorquePeer.MINUTE, obj.getMinute());
544 | 0 |
             criteria.and(JobEntryTorquePeer.HOUR, obj.getHour());
545 | 0 |
             criteria.and(JobEntryTorquePeer.WEEK_DAY, obj.getWeekDay());
546 | 0 |
             criteria.and(JobEntryTorquePeer.DAY_OF_MONTH, obj.getDayOfMonth());
547 | 0 |
             criteria.and(JobEntryTorquePeer.TASK, obj.getTask());
548 | 0 |
             criteria.and(JobEntryTorquePeer.EMAIL, obj.getEmail());
549 | 0 |
             criteria.and(JobEntryTorquePeer.PROPERTY, obj.getProperty());
550 | 0 |
             return criteria;
551 |  |
         }
552 |  |
553 |  |
         /**
554 |  |
          * Build a Criteria object from the data object for this peer,
555 |  |
          * skipping all binary columns.
556 |  |
          *
557 |  |
          * @param obj the object to build the criteria from, not null.
558 |  |
          */
559 |  |
         public Criteria buildSelectCriteria(JobEntryTorque obj)
560 |  |
         {
561 | 0 |
             Criteria criteria = new Criteria(JobEntryTorquePeer.DATABASE_NAME);
562 | 0 |
             if (!obj.isNew())
563 |  |
             {
564 | 0 |
                 criteria.and(JobEntryTorquePeer.JOB_ID, obj.getJobId());
565 |  |
             }
566 | 0 |
             criteria.and(JobEntryTorquePeer.SECOND, obj.getSecond());
567 | 0 |
             criteria.and(JobEntryTorquePeer.MINUTE, obj.getMinute());
568 | 0 |
             criteria.and(JobEntryTorquePeer.HOUR, obj.getHour());
569 | 0 |
             criteria.and(JobEntryTorquePeer.WEEK_DAY, obj.getWeekDay());
570 | 0 |
             criteria.and(JobEntryTorquePeer.DAY_OF_MONTH, obj.getDayOfMonth());
571 | 0 |
             criteria.and(JobEntryTorquePeer.TASK, obj.getTask());
572 | 0 |
             criteria.and(JobEntryTorquePeer.EMAIL, obj.getEmail());
573 | 0 |
             return criteria;
574 |  |
         }
575 |  |
576 |  |
         /**
577 |  |
          * Returns the contents of the object as ColumnValues object.
578 |  |
          * Primary key columns which are generated on insertion are not
579 |  |
          * added to the returned object if they still have their initial
580 |  |
          * value. Also, columns which have the useDatabaseDefaultValue
581 |  |
          * flag set to true are also not added to the returned object
582 |  |
          * if they still have their initial value.
583 |  |
          *
584 |  |
          * @throws TorqueException if the table map cannot be retrieved
585 |  |
          *         (should not happen).
586 |  |
          */
587 |  |
         public ColumnValues buildColumnValues(JobEntryTorque jobEntryTorque)
588 |  |
                 throws TorqueException
589 |  |
         {
590 | 0 |
             ColumnValues columnValues = new ColumnValues();
591 | 0 |
             if (!jobEntryTorque.isNew()
592 |  |
                 || jobEntryTorque.getJobId() != 0)
593 |  |
             {
594 | 0 |
                 columnValues.put(
595 |  |
                         JobEntryTorquePeer.JOB_ID,
596 |  |
                         new JdbcTypedValue(
597 |  |
                             jobEntryTorque.getJobId(),
598 |  |
                             4));
599 |  |
             }
600 | 0 |
             columnValues.put(
601 |  |
                     JobEntryTorquePeer.SECOND,
602 |  |
                     new JdbcTypedValue(
603 |  |
                         jobEntryTorque.getSecond(),
604 |  |
                         4));
605 | 0 |
             columnValues.put(
606 |  |
                     JobEntryTorquePeer.MINUTE,
607 |  |
                     new JdbcTypedValue(
608 |  |
                         jobEntryTorque.getMinute(),
609 |  |
                         4));
610 | 0 |
             columnValues.put(
611 |  |
                     JobEntryTorquePeer.HOUR,
612 |  |
                     new JdbcTypedValue(
613 |  |
                         jobEntryTorque.getHour(),
614 |  |
                         4));
615 | 0 |
             columnValues.put(
616 |  |
                     JobEntryTorquePeer.WEEK_DAY,
617 |  |
                     new JdbcTypedValue(
618 |  |
                         jobEntryTorque.getWeekDay(),
619 |  |
                         4));
620 | 0 |
             columnValues.put(
621 |  |
                     JobEntryTorquePeer.DAY_OF_MONTH,
622 |  |
                     new JdbcTypedValue(
623 |  |
                         jobEntryTorque.getDayOfMonth(),
624 |  |
                         4));
625 | 0 |
             columnValues.put(
626 |  |
                     JobEntryTorquePeer.TASK,
627 |  |
                     new JdbcTypedValue(
628 |  |
                         jobEntryTorque.getTask(),
629 |  |
                         12));
630 | 0 |
             columnValues.put(
631 |  |
                     JobEntryTorquePeer.EMAIL,
632 |  |
                     new JdbcTypedValue(
633 |  |
                         jobEntryTorque.getEmail(),
634 |  |
                         12));
635 | 0 |
             columnValues.put(
636 |  |
                     JobEntryTorquePeer.PROPERTY,
637 |  |
                     new JdbcTypedValue(
638 |  |
                         jobEntryTorque.getProperty(),
639 |  |
                         -3));
640 | 0 |
             return columnValues;
641 |  |
         }
642 |  |
643 |  |
         /**
644 |  |
          * Retrieve a single object by pk
645 |  |
          *
646 |  |
          * @param pk the primary key
647 |  |
          * @throws TorqueException Any exceptions caught during processing will be
648 |  |
          *         rethrown wrapped into a TorqueException.
649 |  |
          * @throws NoRowsException Primary key was not found in database.
650 |  |
          * @throws TooManyRowsException Primary key was not found in database.
651 |  |
          */
652 |  |
         public JobEntryTorque retrieveByPK(int pk)
653 |  |
             throws TorqueException, NoRowsException, TooManyRowsException
654 |  |
         {
655 | 0 |
             return retrieveByPK(SimpleKey.keyFor(pk));
656 |  |
         }
657 |  |
658 |  |
         /**
659 |  |
          * Retrieve a single object by pk
660 |  |
          *
661 |  |
          * @param pk the primary key
662 |  |
          * @param con the connection to use
663 |  |
          * @throws TorqueException Any exceptions caught during processing will be
664 |  |
          *         rethrown wrapped into a TorqueException.
665 |  |
          * @throws NoRowsException Primary key was not found in database.
666 |  |
          * @throws TooManyRowsException Primary key was not found in database.
667 |  |
          */
668 |  |
         public JobEntryTorque retrieveByPK(int pk, Connection con)
669 |  |
             throws TorqueException, NoRowsException, TooManyRowsException
670 |  |
         {
671 | 0 |
             return retrieveByPK(SimpleKey.keyFor(pk), con);
672 |  |
         }
673 |  |
674 |  |
675 |  |
676 |  |
677 |  |
         /**
678 |  |
          * Retrieve a single object by pk
679 |  |
          *
680 |  |
          * @param pk the primary key
681 |  |
          * @throws TorqueException Any exceptions caught during processing will be
682 |  |
          *         rethrown wrapped into a TorqueException.
683 |  |
          * @throws NoRowsException Primary key was not found in database.
684 |  |
          * @throws TooManyRowsException Primary key was not found in database.
685 |  |
          */
686 |  |
         public JobEntryTorque retrieveByPK(ObjectKey pk)
687 |  |
             throws TorqueException, NoRowsException, TooManyRowsException
688 |  |
         {
689 | 0 |
             Connection connection = null;
690 |  |
             try
691 |  |
             {
692 | 0 |
                 connection = Transaction.begin(JobEntryTorquePeer.DATABASE_NAME);
693 | 0 |
                 JobEntryTorque result = retrieveByPK(pk, connection);
694 | 0 |
                 Transaction.commit(connection);
695 | 0 |
                 connection = null;
696 | 0 |
                 return result;
697 |  |
             }
698 |  |
             finally
699 |  |
             {
700 | 0 |
                 if (connection != null)
701 |  |
                 {
702 | 0 |
                     Transaction.safeRollback(connection);
703 |  |
                 }
704 |  |
             }
705 |  |
         }
706 |  |
707 |  |
         /**
708 |  |
          * Retrieve a single object by pk
709 |  |
          *
710 |  |
          * @param pk the primary key
711 |  |
          * @param con the connection to use
712 |  |
          * @throws TorqueException Any exceptions caught during processing will be
713 |  |
          *         rethrown wrapped into a TorqueException.
714 |  |
          * @throws NoRowsException Primary key was not found in database.
715 |  |
          * @throws TooManyRowsException Primary key was not found in database.
716 |  |
          */
717 |  |
         public JobEntryTorque retrieveByPK(ObjectKey pk, Connection con)
718 |  |
             throws TorqueException, NoRowsException, TooManyRowsException
719 |  |
         {
720 | 0 |
             Criteria criteria = buildCriteria(pk);
721 | 0 |
             List<JobEntryTorque> v = doSelect(criteria, con);
722 | 0 |
             if (v.size() == 0)
723 |  |
             {
724 | 0 |
                 throw new NoRowsException("Failed to select a row.");
725 |  |
             }
726 | 0 |
             else if (v.size() > 1)
727 |  |
             {
728 | 0 |
                 throw new TooManyRowsException("Failed to select only one row.");
729 |  |
             }
730 |  |
             else
731 |  |
             {
732 | 0 |
                 return (JobEntryTorque)v.get(0);
733 |  |
             }
734 |  |
         }
735 |  |
736 |  |
737 |  |
         /**
738 |  |
          * Retrieve a multiple objects by pk
739 |  |
          *
740 |  |
          * @param pks List of primary keys
741 |  |
          * @throws TorqueException Any exceptions caught during processing will be
742 |  |
          *         rethrown wrapped into a TorqueException.
743 |  |
          */
744 |  |
         public List<JobEntryTorque> retrieveByPKs(Collection<ObjectKey> pks)
745 |  |
             throws TorqueException
746 |  |
         {
747 | 0 |
             Connection connection = null;
748 |  |
             try
749 |  |
             {
750 | 0 |
                 connection = Transaction.begin(JobEntryTorquePeer.DATABASE_NAME);
751 | 0 |
                 List<JobEntryTorque> result = retrieveByPKs(pks, connection);
752 | 0 |
                 Transaction.commit(connection);
753 | 0 |
                 connection = null;
754 | 0 |
                 return result;
755 |  |
             }
756 |  |
             finally
757 |  |
             {
758 | 0 |
                 if (connection != null)
759 |  |
                 {
760 | 0 |
                     Transaction.safeRollback(connection);
761 |  |
                 }
762 |  |
             }
763 |  |
         }
764 |  |
765 |  |
         /**
766 |  |
          * Retrieve multiple objects by pk
767 |  |
          *
768 |  |
          * @param pks List of primary keys
769 |  |
          * @param dbcon the connection to use
770 |  |
          * @throws TorqueException Any exceptions caught during processing will be
771 |  |
          *         rethrown wrapped into a TorqueException.
772 |  |
          */
773 |  |
         public List<JobEntryTorque> retrieveByPKs(
774 |  |
                     Collection<ObjectKey> pks,
775 |  |
                     Connection dbcon)
776 |  |
                 throws TorqueException
777 |  |
         {
778 | 0 |
             if (pks == null || pks.size() == 0)
779 |  |
             {
780 | 0 |
                 return new ArrayList<JobEntryTorque>();
781 |  |
             }
782 | 0 |
             Criteria criteria = buildCriteria(pks);
783 | 0 |
             List<JobEntryTorque> result = doSelect(criteria, dbcon);
784 | 0 |
             return result;
785 |  |
         }
786 |  |
787 |  |
788 |  |
789 |  |
790 |  |
791 |  |
792 |  |
     }