##### Coverage Report - org.apache.turbine.services.security.torque.om.BaseTurbineGroupPeer

Classes in this File | Line Coverage | Branch Coverage | Complexity
BaseTurbineGroupPeer |
0% | 0/175
0% | 0/30
| 1.6470588235294117;1,647

1 |  |
     package org.apache.turbine.services.security.torque.om;
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.security.torque.om.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 | 0 |
     public abstract class BaseTurbineGroupPeer
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(TurbineGroupMapBuilder.CLASS_NAME) instead
61 |  |
          */
62 |  |
         public static MapBuilder getMapBuilder()
63 |  |
             throws TorqueException
64 |  |
         {
65 | 0 |
             return Torque.getMapBuilder(TurbineGroupMapBuilder.CLASS_NAME);
66 |  |
         }
67 |  |
68 |  |
         /** the column name for the GROUP_ID field */
69 |  |
         public static final String GROUP_ID;
70 |  |
         /** the column name for the GROUP_NAME field */
71 |  |
         public static final String GROUP_NAME;
72 |  |
73 |  |
         static
74 |  |
         {
75 | 0 |
             DATABASE_NAME = "default";
76 | 0 |
             TABLE_NAME = "TURBINE_GROUP";
77 |  |
78 | 0 |
             GROUP_ID = "TURBINE_GROUP.GROUP_ID";
79 | 0 |
             GROUP_NAME = "TURBINE_GROUP.GROUP_NAME";
80 | 0 |
             if (Torque.isInit())
81 |  |
             {
82 |  |
                 try
83 |  |
                 {
84 | 0 |
                     Torque.getMapBuilder(TurbineGroupMapBuilder.CLASS_NAME);
85 |  |
                 }
86 | 0 |
                 catch (TorqueException e)
87 |  |
                 {
88 | 0 |
                     log.error("Could not initialize Peer", e);
89 | 0 |
                     throw new TorqueRuntimeException(e);
90 | 0 |
                 }
91 |  |
             }
92 |  |
             else
93 |  |
             {
94 | 0 |
                 Torque.registerMapBuilder(TurbineGroupMapBuilder.CLASS_NAME);
95 |  |
             }
96 |  |
         }
97 |  |
98 |  |
         /** number of columns for this peer */
99 |  |
         public static final int numColumns =  2;
100 |  |
101 |  |
         /** A class that can be returned by this peer. */
102 |  |
         protected static final String CLASSNAME_DEFAULT =
103 |  |
             "org.apache.turbine.services.security.torque.om.TurbineGroup";
104 |  |
105 |  |
         /** A class that can be returned by this peer. */
106 | 0 |
         protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT);
107 |  |
108 |  |
         /**
109 |  |
          * Class object initialization method.
110 |  |
          *
111 |  |
          * @param className name of the class to initialize
112 |  |
          * @return the initialized class
113 |  |
          */
114 |  |
         private static Class initClass(String className)
115 |  |
         {
116 | 0 |
             Class c = null;
117 |  |
             try
118 |  |
             {
119 | 0 |
                 c = Class.forName(className);
120 |  |
             }
121 | 0 |
             catch (Throwable t)
122 |  |
             {
123 | 0 |
                 log.error("A FATAL ERROR has occurred which should not "
124 |  |
                     + "have happened under any circumstance.  Please notify "
125 |  |
                     + "the Torque developers <torque-dev@db.apache.org> "
126 |  |
                     + "and give as many details as possible (including the error "
127 |  |
                     + "stack trace).", t);
128 |  |
129 |  |
                 // Error objects should always be propagated.
130 | 0 |
                 if (t instanceof Error)
131 |  |
                 {
132 | 0 |
                     throw (Error) t.fillInStackTrace();
133 |  |
                 }
134 | 0 |
             }
135 | 0 |
             return c;
136 |  |
         }
137 |  |
138 |  |
         /**
139 |  |
          * Get the list of objects for a ResultSet.  Please not that your
140 |  |
          * resultset MUST return columns in the right order.  You can use
141 |  |
          * getFieldNames() in BaseObject to get the correct sequence.
142 |  |
          *
143 |  |
          * @param results the ResultSet
144 |  |
          * @return the list of objects
145 |  |
          * @throws TorqueException Any exceptions caught during processing will be
146 |  |
          *         rethrown wrapped into a TorqueException.
147 |  |
          */
148 |  |
         public static List<TurbineGroup> resultSet2Objects(java.sql.ResultSet results)
149 |  |
                 throws TorqueException
150 |  |
         {
151 |  |
             try
152 |  |
             {
153 | 0 |
                 QueryDataSet qds = null;
154 | 0 |
                 List<Record> rows = null;
155 |  |
                 try
156 |  |
                 {
157 | 0 |
                     qds = new QueryDataSet(results);
158 | 0 |
                     rows = getSelectResults(qds);
159 |  |
                 }
160 |  |
                 finally
161 |  |
                 {
162 | 0 |
                     if (qds != null)
163 |  |
                     {
164 | 0 |
                         qds.close();
165 |  |
                     }
166 |  |
                 }
167 |  |
168 | 0 |
                 return populateObjects(rows);
169 |  |
             }
170 | 0 |
             catch (SQLException e)
171 |  |
             {
172 | 0 |
                 throw new TorqueException(e);
173 |  |
             }
174 | 0 |
             catch (DataSetException e)
175 |  |
             {
176 | 0 |
                 throw new TorqueException(e);
177 |  |
             }
178 |  |
         }
179 |  |
180 |  |
181 |  |
182 |  |
         /**
183 |  |
          * Method to do inserts.
184 |  |
          *
185 |  |
          * @param criteria object used to create the INSERT statement.
186 |  |
          * @throws TorqueException Any exceptions caught during processing will be
187 |  |
          *         rethrown wrapped into a TorqueException.
188 |  |
          */
189 |  |
         public static ObjectKey doInsert(Criteria criteria)
190 |  |
             throws TorqueException
191 |  |
         {
192 | 0 |
             return BaseTurbineGroupPeer
193 |  |
                 .doInsert(criteria, (Connection) null);
194 |  |
         }
195 |  |
196 |  |
         /**
197 |  |
          * Method to do inserts.  This method is to be used during a transaction,
198 |  |
          * otherwise use the doInsert(Criteria) method.  It will take care of
199 |  |
          * the connection details internally.
200 |  |
          *
201 |  |
          * @param criteria object used to create the INSERT statement.
202 |  |
          * @param con the connection to use
203 |  |
          * @throws TorqueException Any exceptions caught during processing will be
204 |  |
          *         rethrown wrapped into a TorqueException.
205 |  |
          */
206 |  |
         public static ObjectKey doInsert(Criteria criteria, Connection con)
207 |  |
             throws TorqueException
208 |  |
         {
209 | 0 |
             correctBooleans(criteria);
210 |  |
211 | 0 |
             setDbName(criteria);
212 |  |
213 | 0 |
             if (con == null)
214 |  |
             {
215 | 0 |
                 return BasePeer.doInsert(criteria);
216 |  |
             }
217 |  |
             else
218 |  |
             {
219 | 0 |
                 return BasePeer.doInsert(criteria, con);
220 |  |
             }
221 |  |
         }
222 |  |
223 |  |
         /**
224 |  |
          * Add all the columns needed to create a new object.
225 |  |
          *
226 |  |
          * @param criteria object containing the columns to add.
227 |  |
          * @throws TorqueException Any exceptions caught during processing will be
228 |  |
          *         rethrown wrapped into a TorqueException.
229 |  |
          */
230 |  |
         public static void addSelectColumns(Criteria criteria)
231 |  |
                 throws TorqueException
232 |  |
         {
233 | 0 |
             criteria.addSelectColumn(GROUP_ID);
234 | 0 |
             criteria.addSelectColumn(GROUP_NAME);
235 | 0 |
         }
236 |  |
237 |  |
         /**
238 |  |
          * changes the boolean values in the criteria to the appropriate type,
239 |  |
          * whenever a booleanchar or booleanint column is involved.
240 |  |
          * This enables the user to create criteria using Boolean values
241 |  |
          * for booleanchar or booleanint columns
242 |  |
          * @param criteria the criteria in which the boolean values should be corrected
243 |  |
          * @throws TorqueException if the database map for the criteria cannot be
244 |  |
                    obtained.
245 |  |
          */
246 |  |
         public static void correctBooleans(Criteria criteria) throws TorqueException
247 |  |
         {
248 | 0 |
             correctBooleans(criteria, getTableMap());
249 | 0 |
         }
250 |  |
251 |  |
         /**
252 |  |
          * Create a new object of type cls from a resultset row starting
253 |  |
          * from a specified offset.  This is done so that you can select
254 |  |
          * other rows than just those needed for this object.  You may
255 |  |
          * for example want to create two objects from the same row.
256 |  |
          *
257 |  |
          * @throws TorqueException Any exceptions caught during processing will be
258 |  |
          *         rethrown wrapped into a TorqueException.
259 |  |
          */
260 |  |
         public static TurbineGroup row2Object(Record row,
261 |  |
                                                  int offset,
262 |  |
                                                  Class cls)
263 |  |
             throws TorqueException
264 |  |
         {
265 |  |
             try
266 |  |
             {
267 | 0 |
                 TurbineGroup obj = (TurbineGroup) cls.newInstance();
268 | 0 |
                 TurbineGroupPeer.populateObject(row, offset, obj);
269 | 0 |
                     obj.setModified(false);
270 | 0 |
                 obj.setNew(false);
271 |  |
272 | 0 |
                 return obj;
273 |  |
             }
274 | 0 |
             catch (InstantiationException e)
275 |  |
             {
276 | 0 |
                 throw new TorqueException(e);
277 |  |
             }
278 | 0 |
             catch (IllegalAccessException e)
279 |  |
             {
280 | 0 |
                 throw new TorqueException(e);
281 |  |
             }
282 |  |
         }
283 |  |
284 |  |
         /**
285 |  |
          * Populates an object from a resultset row starting
286 |  |
          * from a specified offset.  This is done so that you can select
287 |  |
          * other rows than just those needed for this object.  You may
288 |  |
          * for example want to create two objects from the same row.
289 |  |
          *
290 |  |
          * @throws TorqueException Any exceptions caught during processing will be
291 |  |
          *         rethrown wrapped into a TorqueException.
292 |  |
          */
293 |  |
         public static void populateObject(Record row,
294 |  |
                                           int offset,
295 |  |
                                           TurbineGroup obj)
296 |  |
             throws TorqueException
297 |  |
         {
298 |  |
             try
299 |  |
             {
300 | 0 |
                 obj.setGroupId(row.getValue(offset + 0).asInt());
301 | 0 |
                 obj.setName(row.getValue(offset + 1).asString());
302 |  |
             }
303 | 0 |
             catch (DataSetException e)
304 |  |
             {
305 | 0 |
                 throw new TorqueException(e);
306 | 0 |
             }
307 | 0 |
         }
308 |  |
309 |  |
         /**
310 |  |
          * Method to do selects.
311 |  |
          *
312 |  |
          * @param criteria object used to create the SELECT statement.
313 |  |
          * @return List of selected Objects
314 |  |
          * @throws TorqueException Any exceptions caught during processing will be
315 |  |
          *         rethrown wrapped into a TorqueException.
316 |  |
          */
317 |  |
         public static List<TurbineGroup> doSelect(Criteria criteria) throws TorqueException
318 |  |
         {
319 | 0 |
             return populateObjects(doSelectVillageRecords(criteria));
320 |  |
         }
321 |  |
322 |  |
         /**
323 |  |
          * Method to do selects within a transaction.
324 |  |
          *
325 |  |
          * @param criteria object used to create the SELECT statement.
326 |  |
          * @param con the connection to use
327 |  |
          * @return List of selected Objects
328 |  |
          * @throws TorqueException Any exceptions caught during processing will be
329 |  |
          *         rethrown wrapped into a TorqueException.
330 |  |
          */
331 |  |
         public static List<TurbineGroup> doSelect(Criteria criteria, Connection con)
332 |  |
             throws TorqueException
333 |  |
         {
334 | 0 |
             return populateObjects(doSelectVillageRecords(criteria, con));
335 |  |
         }
336 |  |
337 |  |
         /**
338 |  |
          * Grabs the raw Village records to be formed into objects.
339 |  |
          * This method handles connections internally.  The Record objects
340 |  |
          * returned by this method should be considered readonly.  Do not
341 |  |
          * alter the data and call save(), your results may vary, but are
342 |  |
          * certainly likely to result in hard to track MT bugs.
343 |  |
          *
344 |  |
          * @throws TorqueException Any exceptions caught during processing will be
345 |  |
          *         rethrown wrapped into a TorqueException.
346 |  |
          */
347 |  |
         public static List<Record> doSelectVillageRecords(Criteria criteria)
348 |  |
             throws TorqueException
349 |  |
         {
350 | 0 |
             return BaseTurbineGroupPeer
351 |  |
                 .doSelectVillageRecords(criteria, (Connection) null);
352 |  |
         }
353 |  |
354 |  |
         /**
355 |  |
          * Grabs the raw Village records to be formed into objects.
356 |  |
          * This method should be used for transactions
357 |  |
          *
358 |  |
          * @param criteria object used to create the SELECT statement.
359 |  |
          * @param con the connection to use
360 |  |
          * @throws TorqueException Any exceptions caught during processing will be
361 |  |
          *         rethrown wrapped into a TorqueException.
362 |  |
          */
363 |  |
         public static List<Record> doSelectVillageRecords(Criteria criteria, Connection con)
364 |  |
             throws TorqueException
365 |  |
         {
366 | 0 |
             if (criteria.getSelectColumns().size() == 0)
367 |  |
             {
368 | 0 |
                 addSelectColumns(criteria);
369 |  |
             }
370 | 0 |
             correctBooleans(criteria);
371 |  |
372 | 0 |
             setDbName(criteria);
373 |  |
374 |  |
             // BasePeer returns a List of Value (Village) arrays.  The array
375 |  |
             // order follows the order columns were placed in the Select clause.
376 | 0 |
             if (con == null)
377 |  |
             {
378 | 0 |
                 return BasePeer.doSelect(criteria);
379 |  |
             }
380 |  |
             else
381 |  |
             {
382 | 0 |
                 return BasePeer.doSelect(criteria, con);
383 |  |
             }
384 |  |
         }
385 |  |
386 |  |
         /**
387 |  |
          * The returned List will contain objects of the default type or
388 |  |
          * objects that inherit from the default.
389 |  |
          *
390 |  |
          * @throws TorqueException Any exceptions caught during processing will be
391 |  |
          *         rethrown wrapped into a TorqueException.
392 |  |
          */
393 |  |
         public static List<TurbineGroup> populateObjects(List<Record> records)
394 |  |
             throws TorqueException
395 |  |
         {
396 | 0 |
             List<TurbineGroup> results = new ArrayList<TurbineGroup>(records.size());
397 |  |
398 |  |
             // populate the object(s)
399 | 0 |
             for (int i = 0; i < records.size(); i++)
400 |  |
             {
401 | 0 |
                 Record row =  records.get(i);
402 | 0 |
                 results.add(TurbineGroupPeer.row2Object(row, 1,
403 |  |
                     TurbineGroupPeer.getOMClass()));
404 |  |
             }
405 | 0 |
             return results;
406 |  |
         }
407 |  |
408 |  |
409 |  |
         /**
410 |  |
          * The class that the Peer will make instances of.
411 |  |
          * If the BO is abstract then you must implement this method
412 |  |
          * in the BO.
413 |  |
          *
414 |  |
          * @throws TorqueException Any exceptions caught during processing will be
415 |  |
          *         rethrown wrapped into a TorqueException.
416 |  |
          */
417 |  |
         public static Class getOMClass()
418 |  |
             throws TorqueException
419 |  |
         {
420 | 0 |
             return CLASS_DEFAULT;
421 |  |
         }
422 |  |
423 |  |
         /**
424 |  |
          * Method to do updates.
425 |  |
          *
426 |  |
          * @param criteria object containing data that is used to create the UPDATE
427 |  |
          *        statement.
428 |  |
          * @throws TorqueException Any exceptions caught during processing will be
429 |  |
          *         rethrown wrapped into a TorqueException.
430 |  |
          */
431 |  |
         public static void doUpdate(Criteria criteria) throws TorqueException
432 |  |
         {
433 | 0 |
              BaseTurbineGroupPeer
434 |  |
                 .doUpdate(criteria, (Connection) null);
435 | 0 |
         }
436 |  |
437 |  |
         /**
438 |  |
          * Method to do updates.  This method is to be used during a transaction,
439 |  |
          * otherwise use the doUpdate(Criteria) method.  It will take care of
440 |  |
          * the connection details internally.
441 |  |
          *
442 |  |
          * @param criteria object containing data that is used to create the UPDATE
443 |  |
          *        statement.
444 |  |
          * @param con the connection to use
445 |  |
          * @throws TorqueException Any exceptions caught during processing will be
446 |  |
          *         rethrown wrapped into a TorqueException.
447 |  |
          */
448 |  |
         public static void doUpdate(Criteria criteria, Connection con)
449 |  |
             throws TorqueException
450 |  |
         {
451 | 0 |
             Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
452 | 0 |
             correctBooleans(criteria);
453 |  |
454 |  |
455 | 0 |
              selectCriteria.put(GROUP_ID, criteria.remove(GROUP_ID));
456 |  |
457 |  |
458 | 0 |
             setDbName(criteria);
459 |  |
460 | 0 |
             if (con == null)
461 |  |
             {
462 | 0 |
                 BasePeer.doUpdate(selectCriteria, criteria);
463 |  |
             }
464 |  |
             else
465 |  |
             {
466 | 0 |
                 BasePeer.doUpdate(selectCriteria, criteria, con);
467 |  |
             }
468 | 0 |
         }
469 |  |
470 |  |
         /**
471 |  |
          * Method to do deletes.
472 |  |
          *
473 |  |
          * @param criteria object containing data that is used DELETE from database.
474 |  |
          * @throws TorqueException Any exceptions caught during processing will be
475 |  |
          *         rethrown wrapped into a TorqueException.
476 |  |
          */
477 |  |
          public static void doDelete(Criteria criteria) throws TorqueException
478 |  |
          {
479 | 0 |
              TurbineGroupPeer
480 |  |
                 .doDelete(criteria, (Connection) null);
481 | 0 |
          }
482 |  |
483 |  |
         /**
484 |  |
          * Method to do deletes.  This method is to be used during a transaction,
485 |  |
          * otherwise use the doDelete(Criteria) method.  It will take care of
486 |  |
          * the connection details internally.
487 |  |
          *
488 |  |
          * @param criteria object containing data that is used DELETE from database.
489 |  |
          * @param con the connection to use
490 |  |
          * @throws TorqueException Any exceptions caught during processing will be
491 |  |
          *         rethrown wrapped into a TorqueException.
492 |  |
          */
493 |  |
          public static void doDelete(Criteria criteria, Connection con)
494 |  |
             throws TorqueException
495 |  |
          {
496 | 0 |
             correctBooleans(criteria);
497 |  |
498 | 0 |
             setDbName(criteria);
499 |  |
500 | 0 |
             if (con == null)
501 |  |
             {
502 | 0 |
                 BasePeer.doDelete(criteria, TABLE_NAME);
503 |  |
             }
504 |  |
             else
505 |  |
             {
506 | 0 |
                 BasePeer.doDelete(criteria, TABLE_NAME, con);
507 |  |
             }
508 | 0 |
          }
509 |  |
510 |  |
         /**
511 |  |
          * Method to do selects
512 |  |
          *
513 |  |
          * @throws TorqueException Any exceptions caught during processing will be
514 |  |
          *         rethrown wrapped into a TorqueException.
515 |  |
          */
516 |  |
         public static List<TurbineGroup> doSelect(TurbineGroup obj) throws TorqueException
517 |  |
         {
518 | 0 |
             return doSelect(buildSelectCriteria(obj));
519 |  |
         }
520 |  |
521 |  |
         /**
522 |  |
          * Method to do inserts
523 |  |
          *
524 |  |
          * @throws TorqueException Any exceptions caught during processing will be
525 |  |
          *         rethrown wrapped into a TorqueException.
526 |  |
          */
527 |  |
         public static void doInsert(TurbineGroup obj) throws TorqueException
528 |  |
         {
529 | 0 |
             obj.setPrimaryKey(doInsert(buildCriteria(obj)));
530 | 0 |
             obj.setNew(false);
531 | 0 |
             obj.setModified(false);
532 | 0 |
         }
533 |  |
534 |  |
         /**
535 |  |
          * @param obj the data object to update in the database.
536 |  |
          * @throws TorqueException Any exceptions caught during processing will be
537 |  |
          *         rethrown wrapped into a TorqueException.
538 |  |
          */
539 |  |
         public static void doUpdate(TurbineGroup obj) throws TorqueException
540 |  |
         {
541 | 0 |
             doUpdate(buildCriteria(obj));
542 | 0 |
             obj.setModified(false);
543 | 0 |
         }
544 |  |
545 |  |
         /**
546 |  |
          * @param obj the data object to delete in the database.
547 |  |
          * @throws TorqueException Any exceptions caught during processing will be
548 |  |
          *         rethrown wrapped into a TorqueException.
549 |  |
          */
550 |  |
         public static void doDelete(TurbineGroup obj) throws TorqueException
551 |  |
         {
552 | 0 |
             doDelete(buildSelectCriteria(obj));
553 | 0 |
         }
554 |  |
555 |  |
         /**
556 |  |
          * Method to do inserts.  This method is to be used during a transaction,
557 |  |
          * otherwise use the doInsert(TurbineGroup) method.  It will take
558 |  |
          * care of the connection details internally.
559 |  |
          *
560 |  |
          * @param obj the data object to insert into the database.
561 |  |
          * @param con the connection to use
562 |  |
          * @throws TorqueException Any exceptions caught during processing will be
563 |  |
          *         rethrown wrapped into a TorqueException.
564 |  |
          */
565 |  |
         public static void doInsert(TurbineGroup obj, Connection con)
566 |  |
             throws TorqueException
567 |  |
         {
568 | 0 |
             obj.setPrimaryKey(doInsert(buildCriteria(obj), con));
569 | 0 |
             obj.setNew(false);
570 | 0 |
             obj.setModified(false);
571 | 0 |
         }
572 |  |
573 |  |
         /**
574 |  |
          * Method to do update.  This method is to be used during a transaction,
575 |  |
          * otherwise use the doUpdate(TurbineGroup) method.  It will take
576 |  |
          * care of the connection details internally.
577 |  |
          *
578 |  |
          * @param obj the data object to update in the database.
579 |  |
          * @param con the connection to use
580 |  |
          * @throws TorqueException Any exceptions caught during processing will be
581 |  |
          *         rethrown wrapped into a TorqueException.
582 |  |
          */
583 |  |
         public static void doUpdate(TurbineGroup obj, Connection con)
584 |  |
             throws TorqueException
585 |  |
         {
586 | 0 |
             doUpdate(buildCriteria(obj), con);
587 | 0 |
             obj.setModified(false);
588 | 0 |
         }
589 |  |
590 |  |
         /**
591 |  |
          * Method to delete.  This method is to be used during a transaction,
592 |  |
          * otherwise use the doDelete(TurbineGroup) method.  It will take
593 |  |
          * care of the connection details internally.
594 |  |
          *
595 |  |
          * @param obj the data object to delete in the database.
596 |  |
          * @param con the connection to use
597 |  |
          * @throws TorqueException Any exceptions caught during processing will be
598 |  |
          *         rethrown wrapped into a TorqueException.
599 |  |
          */
600 |  |
         public static void doDelete(TurbineGroup obj, Connection con)
601 |  |
             throws TorqueException
602 |  |
         {
603 | 0 |
             doDelete(buildSelectCriteria(obj), con);
604 | 0 |
         }
605 |  |
606 |  |
         /**
607 |  |
          * Method to do deletes.
608 |  |
          *
609 |  |
          * @param pk ObjectKey that is used DELETE from database.
610 |  |
          * @throws TorqueException Any exceptions caught during processing will be
611 |  |
          *         rethrown wrapped into a TorqueException.
612 |  |
          */
613 |  |
         public static void doDelete(ObjectKey pk) throws TorqueException
614 |  |
         {
615 | 0 |
             BaseTurbineGroupPeer
616 |  |
                .doDelete(pk, (Connection) null);
617 | 0 |
         }
618 |  |
619 |  |
         /**
620 |  |
          * Method to delete.  This method is to be used during a transaction,
621 |  |
          * otherwise use the doDelete(ObjectKey) method.  It will take
622 |  |
          * care of the connection details internally.
623 |  |
          *
624 |  |
          * @param pk the primary key for the object to delete in the database.
625 |  |
          * @param con the connection to use
626 |  |
          * @throws TorqueException Any exceptions caught during processing will be
627 |  |
          *         rethrown wrapped into a TorqueException.
628 |  |
          */
629 |  |
         public static void doDelete(ObjectKey pk, Connection con)
630 |  |
             throws TorqueException
631 |  |
         {
632 | 0 |
             doDelete(buildCriteria(pk), con);
633 | 0 |
         }
634 |  |
635 |  |
         /** Build a Criteria object from an ObjectKey */
636 |  |
         public static Criteria buildCriteria( ObjectKey pk )
637 |  |
         {
638 | 0 |
             Criteria criteria = new Criteria();
639 | 0 |
                 criteria.add(GROUP_ID, pk);
640 | 0 |
             return criteria;
641 |  |
          }
642 |  |
643 |  |
         /** Build a Criteria object from the data object for this peer */
644 |  |
         public static Criteria buildCriteria( TurbineGroup obj )
645 |  |
         {
646 | 0 |
             Criteria criteria = new Criteria(DATABASE_NAME);
647 | 0 |
             if (!obj.isNew())
648 | 0 |
             criteria.add(GROUP_ID, obj.getGroupId());
649 | 0 |
             criteria.add(GROUP_NAME, obj.getName());
650 | 0 |
             return criteria;
651 |  |
         }
652 |  |
653 |  |
         /** Build a Criteria object from the data object for this peer, skipping all binary columns */
654 |  |
         public static Criteria buildSelectCriteria( TurbineGroup obj )
655 |  |
         {
656 | 0 |
             Criteria criteria = new Criteria(DATABASE_NAME);
657 | 0 |
             if (!obj.isNew())
658 |  |
             {
659 | 0 |
                 criteria.add(GROUP_ID, obj.getGroupId());
660 |  |
             }
661 | 0 |
                 criteria.add(GROUP_NAME, obj.getName());
662 | 0 |
             return criteria;
663 |  |
         }
664 |  |
665 |  |
666 |  |
         /**
667 |  |
          * Retrieve a single object by pk
668 |  |
          *
669 |  |
          * @param pk the primary key
670 |  |
          * @throws TorqueException Any exceptions caught during processing will be
671 |  |
          *         rethrown wrapped into a TorqueException.
672 |  |
          * @throws NoRowsException Primary key was not found in database.
673 |  |
          * @throws TooManyRowsException Primary key was not found in database.
674 |  |
          */
675 |  |
         public static TurbineGroup retrieveByPK(int pk)
676 |  |
             throws TorqueException, NoRowsException, TooManyRowsException
677 |  |
         {
678 | 0 |
             return retrieveByPK(SimpleKey.keyFor(pk));
679 |  |
         }
680 |  |
681 |  |
         /**
682 |  |
          * Retrieve a single object by pk
683 |  |
          *
684 |  |
          * @param pk the primary key
685 |  |
          * @param con the connection to use
686 |  |
          * @throws TorqueException Any exceptions caught during processing will be
687 |  |
          *         rethrown wrapped into a TorqueException.
688 |  |
          * @throws NoRowsException Primary key was not found in database.
689 |  |
          * @throws TooManyRowsException Primary key was not found in database.
690 |  |
          */
691 |  |
         public static TurbineGroup retrieveByPK(int pk, Connection con)
692 |  |
             throws TorqueException, NoRowsException, TooManyRowsException
693 |  |
         {
694 | 0 |
             return retrieveByPK(SimpleKey.keyFor(pk), con);
695 |  |
         }
696 |  |
697 |  |
         /**
698 |  |
          * Retrieve a single object by pk
699 |  |
          *
700 |  |
          * @param pk the primary key
701 |  |
          * @throws TorqueException Any exceptions caught during processing will be
702 |  |
          *         rethrown wrapped into a TorqueException.
703 |  |
          * @throws NoRowsException Primary key was not found in database.
704 |  |
          * @throws TooManyRowsException Primary key was not found in database.
705 |  |
          */
706 |  |
         public static TurbineGroup retrieveByPK(ObjectKey pk)
707 |  |
             throws TorqueException, NoRowsException, TooManyRowsException
708 |  |
         {
709 | 0 |
             Connection db = null;
710 | 0 |
             TurbineGroup retVal = null;
711 |  |
             try
712 |  |
             {
713 | 0 |
                 db = Torque.getConnection(DATABASE_NAME);
714 | 0 |
                 retVal = retrieveByPK(pk, db);
715 |  |
             }
716 |  |
             finally
717 |  |
             {
718 | 0 |
                 Torque.closeConnection(db);
719 | 0 |
             }
720 | 0 |
             return retVal;
721 |  |
         }
722 |  |
723 |  |
         /**
724 |  |
          * Retrieve a single object by pk
725 |  |
          *
726 |  |
          * @param pk the primary key
727 |  |
          * @param con the connection to use
728 |  |
          * @throws TorqueException Any exceptions caught during processing will be
729 |  |
          *         rethrown wrapped into a TorqueException.
730 |  |
          * @throws NoRowsException Primary key was not found in database.
731 |  |
          * @throws TooManyRowsException Primary key was not found in database.
732 |  |
          */
733 |  |
         public static TurbineGroup retrieveByPK(ObjectKey pk, Connection con)
734 |  |
             throws TorqueException, NoRowsException, TooManyRowsException
735 |  |
         {
736 | 0 |
             Criteria criteria = buildCriteria(pk);
737 | 0 |
             List<TurbineGroup> v = doSelect(criteria, con);
738 | 0 |
             if (v.size() == 0)
739 |  |
             {
740 | 0 |
                 throw new NoRowsException("Failed to select a row.");
741 |  |
             }
742 | 0 |
             else if (v.size() > 1)
743 |  |
             {
744 | 0 |
                 throw new TooManyRowsException("Failed to select only one row.");
745 |  |
             }
746 |  |
             else
747 |  |
             {
748 | 0 |
                 return (TurbineGroup)v.get(0);
749 |  |
             }
750 |  |
         }
751 |  |
752 |  |
         /**
753 |  |
          * Retrieve a multiple objects by pk
754 |  |
          *
755 |  |
          * @param pks List of primary keys
756 |  |
          * @throws TorqueException Any exceptions caught during processing will be
757 |  |
          *         rethrown wrapped into a TorqueException.
758 |  |
          */
759 |  |
         public static List<TurbineGroup> retrieveByPKs(List<ObjectKey> pks)
760 |  |
             throws TorqueException
761 |  |
         {
762 | 0 |
             Connection db = null;
763 | 0 |
             List<TurbineGroup> retVal = null;
764 |  |
             try
765 |  |
             {
766 | 0 |
                db = Torque.getConnection(DATABASE_NAME);
767 | 0 |
                retVal = retrieveByPKs(pks, db);
768 |  |
             }
769 |  |
             finally
770 |  |
             {
771 | 0 |
                 Torque.closeConnection(db);
772 | 0 |
             }
773 | 0 |
             return retVal;
774 |  |
         }
775 |  |
776 |  |
         /**
777 |  |
          * Retrieve a multiple objects by pk
778 |  |
          *
779 |  |
          * @param pks List of primary keys
780 |  |
          * @param dbcon the connection to use
781 |  |
          * @throws TorqueException Any exceptions caught during processing will be
782 |  |
          *         rethrown wrapped into a TorqueException.
783 |  |
          */
784 |  |
         public static List<TurbineGroup> retrieveByPKs( List<ObjectKey> pks, Connection dbcon )
785 |  |
             throws TorqueException
786 |  |
         {
787 | 0 |
             List<TurbineGroup> objs = null;
788 | 0 |
             if (pks == null || pks.size() == 0)
789 |  |
             {
790 | 0 |
                 objs = new LinkedList<TurbineGroup>();
791 |  |
             }
792 |  |
             else
793 |  |
             {
794 | 0 |
                 Criteria criteria = new Criteria();
795 | 0 |
                 criteria.addIn( GROUP_ID, pks );
796 | 0 |
             objs = doSelect(criteria, dbcon);
797 |  |
             }
798 | 0 |
             return objs;
799 |  |
         }
800 |  |
801 |  |
802 |  |
803 |  |
804 |  |
805 |  |
806 |  |
807 |  |
808 |  |
809 |  |
810 |  |
         /**
811 |  |
          * Returns the TableMap related to this peer.
812 |  |
          *
813 |  |
          * @throws TorqueException Any exceptions caught during processing will be
814 |  |
          *         rethrown wrapped into a TorqueException.
815 |  |
          */
816 |  |
         public static TableMap getTableMap()
817 |  |
             throws TorqueException
818 |  |
         {
819 | 0 |
             return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME);
820 |  |
         }
821 |  |
822 |  |
         private static void setDbName(Criteria crit)
823 |  |
         {
824 |  |
             // Set the correct dbName if it has not been overridden
825 |  |
             // crit.getDbName will return the same object if not set to
826 |  |
             // another value so == check is okay and faster
827 | 0 |
             if (crit.getDbName() == Torque.getDefaultDB())
828 |  |
             {
829 | 0 |
                 crit.setDbName(DATABASE_NAME);
830 |  |
             }
831 | 0 |
         }
832 |  |
833 |  |
834 |  |
         // The following methods wrap some methods in BasePeer
835 |  |
         // to have more support for Java5 generic types in the Peer
836 |  |
837 |  |
         /**
838 |  |
          * Utility method which executes a given sql statement.  This
839 |  |
          * method should be used for select statements only.  Use
840 |  |
          * executeStatement for update, insert, and delete operations.
841 |  |
          *
842 |  |
          * @param queryString A String with the sql statement to execute.
843 |  |
          * @return List of Record objects.
844 |  |
          * @throws TorqueException Any exceptions caught during processing will be
845 |  |
          *         rethrown wrapped into a TorqueException.
846 |  |
          * @see org.apache.torque.util.BasePeer#executeQuery(String)
847 |  |
          */
848 |  |
         public static List<Record> executeQuery(String queryString) throws TorqueException
849 |  |
         {
850 | 0 |
             return BasePeer.executeQuery(queryString);
851 |  |
         }
852 |  |
853 |  |
         /**
854 |  |
          * Utility method which executes a given sql statement.  This
855 |  |
          * method should be used for select statements only.  Use
856 |  |
          * executeStatement for update, insert, and delete operations.
857 |  |
          *
858 |  |
          * @param queryString A String with the sql statement to execute.
859 |  |
          * @param dbName The database to connect to.
860 |  |
          * @return List of Record objects.
861 |  |
          * @throws TorqueException Any exceptions caught during processing will be
862 |  |
          *         rethrown wrapped into a TorqueException.
863 |  |
          * @see org.apache.torque.util.BasePeer#executeQuery(String,String)
864 |  |
          */
865 |  |
         public static List<Record> executeQuery(String queryString, String dbName)
866 |  |
             throws TorqueException
867 |  |
         {
868 | 0 |
             return BasePeer.executeQuery(queryString,dbName);
869 |  |
         }
870 |  |
871 |  |
872 |  |
         /**
873 |  |
          * Method for performing a SELECT.  Returns all results.
874 |  |
          *
875 |  |
          * @param queryString A String with the sql statement to execute.
876 |  |
          * @param dbName The database to connect to.
877 |  |
          * @param singleRecord Whether or not we want to select only a
878 |  |
          * single record.
879 |  |
          * @return List of Record objects.
880 |  |
          * @throws TorqueException Any exceptions caught during processing will be
881 |  |
          *         rethrown wrapped into a TorqueException.
882 |  |
          * @see org.apache.torque.util.BasePeer#executeQuery(String,String,boolean)
883 |  |
          */
884 |  |
         public static List<Record> executeQuery(
885 |  |
             String queryString,
886 |  |
             String dbName,
887 |  |
             boolean singleRecord)
888 |  |
             throws TorqueException
889 |  |
         {
890 | 0 |
             return BasePeer.executeQuery(queryString,dbName,singleRecord);
891 |  |
         }
892 |  |
893 |  |
         /**
894 |  |
          * Method for performing a SELECT.  Returns all results.
895 |  |
          *
896 |  |
          * @param queryString A String with the sql statement to execute.
897 |  |
          * @param singleRecord Whether or not we want to select only a
898 |  |
          * single record.
899 |  |
          * @param con A Connection.
900 |  |
          * @return List of Record objects.
901 |  |
          * @throws TorqueException Any exceptions caught during processing will be
902 |  |
          *         rethrown wrapped into a TorqueException.
903 |  |
          * @see org.apache.torque.util.BasePeer#executeQuery(String,boolean,Connection)
904 |  |
          */
905 |  |
         public static List<Record> executeQuery(
906 |  |
             String queryString,
907 |  |
             boolean singleRecord,
908 |  |
             Connection con)
909 |  |
             throws TorqueException
910 |  |
         {
911 | 0 |
             return BasePeer.executeQuery(queryString,singleRecord,con);
912 |  |
         }
913 |  |
914 |  |
         /**
915 |  |
          * Method for performing a SELECT.
916 |  |
          *
917 |  |
          * @param queryString A String with the sql statement to execute.
918 |  |
          * @param start The first row to return.
919 |  |
          * @param numberOfResults The number of rows to return.
920 |  |
          * @param dbName The database to connect to.
921 |  |
          * @param singleRecord Whether or not we want to select only a
922 |  |
          * single record.
923 |  |
          * @return List of Record objects.
924 |  |
          * @throws TorqueException Any exceptions caught during processing will be
925 |  |
          *         rethrown wrapped into a TorqueException.
926 |  |
          * @see org.apache.torque.util.BasePeer#executeQuery(String,int,int,String,boolean)
927 |  |
          */
928 |  |
         public static List<Record> executeQuery(
929 |  |
             String queryString,
930 |  |
             int start,
931 |  |
             int numberOfResults,
932 |  |
             String dbName,
933 |  |
             boolean singleRecord)
934 |  |
             throws TorqueException
935 |  |
         {
936 | 0 |
             return BasePeer.executeQuery(queryString,start,numberOfResults,dbName,singleRecord);
937 |  |
         }
938 |  |
939 |  |
         /**
940 |  |
          * Method for performing a SELECT.  Returns all results.
941 |  |
          *
942 |  |
          * @param queryString A String with the sql statement to execute.
943 |  |
          * @param start The first row to return.
944 |  |
          * @param numberOfResults The number of rows to return.
945 |  |
          * @param singleRecord Whether or not we want to select only a
946 |  |
          * single record.
947 |  |
          * @param con A Connection.
948 |  |
          * @return List of Record objects.
949 |  |
          * @throws TorqueException Any exceptions caught during processing will be
950 |  |
          *         rethrown wrapped into a TorqueException.
951 |  |
          * @see org.apache.torque.util.BasePeer#executeQuery(String,int,int,String,boolean,Connection)
952 |  |
          */
953 |  |
         public static List<Record> executeQuery(
954 |  |
             String queryString,
955 |  |
             int start,
956 |  |
             int numberOfResults,
957 |  |
             boolean singleRecord,
958 |  |
             Connection con)
959 |  |
             throws TorqueException
960 |  |
         {
961 | 0 |
             return BasePeer.executeQuery(queryString,start,numberOfResults,singleRecord,con);
962 |  |
         }
963 |  |
964 |  |
         /**
965 |  |
          * Returns all records in a QueryDataSet as a List of Record
966 |  |
          * objects.  Used for functionality like util.LargeSelect.
967 |  |
          *
968 |  |
          * @see #getSelectResults(QueryDataSet, int, int, boolean)
969 |  |
          * @param qds the QueryDataSet
970 |  |
          * @return a List of Record objects
971 |  |
          * @throws TorqueException Any exceptions caught during processing will be
972 |  |
          *         rethrown wrapped into a TorqueException.
973 |  |
          * @see org.apache.torque.util.BasePeer#getSelectResults(QueryDataSet)
974 |  |
          */
975 |  |
         public static List<Record> getSelectResults(QueryDataSet qds)
976 |  |
             throws TorqueException
977 |  |
         {
978 | 0 |
             return BasePeer.getSelectResults(qds);
979 |  |
         }
980 |  |
981 |  |
         /**
982 |  |
          * Returns all records in a QueryDataSet as a List of Record
983 |  |
          * objects.  Used for functionality like util.LargeSelect.
984 |  |
          *
985 |  |
          * @see #getSelectResults(QueryDataSet, int, int, boolean)
986 |  |
          * @param qds the QueryDataSet
987 |  |
          * @param singleRecord
988 |  |
          * @return a List of Record objects
989 |  |
          * @throws TorqueException Any exceptions caught during processing will be
990 |  |
          *         rethrown wrapped into a TorqueException.
991 |  |
          * @see org.apache.torque.util.BasePeer#getSelectResults(QueryDataSet,boolean)
992 |  |
          */
993 |  |
         public static List<Record> getSelectResults(QueryDataSet qds, boolean singleRecord)
994 |  |
             throws TorqueException
995 |  |
         {
996 | 0 |
             return BasePeer.getSelectResults(qds,singleRecord);
997 |  |
         }
998 |  |
999 |  |
         /**
1000 |  |
          * Returns numberOfResults records in a QueryDataSet as a List
1001 |  |
          * of Record objects.  Starting at record 0.  Used for
1002 |  |
          * functionality like util.LargeSelect.
1003 |  |
          *
1004 |  |
          * @see #getSelectResults(QueryDataSet, int, int, boolean)
1005 |  |
          * @param qds the QueryDataSet
1006 |  |
          * @param numberOfResults
1007 |  |
          * @param singleRecord
1008 |  |
          * @return a List of Record objects
1009 |  |
          * @throws TorqueException Any exceptions caught during processing will be
1010 |  |
          *         rethrown wrapped into a TorqueException.
1011 |  |
          * @see org.apache.torque.util.BasePeer#getSelectResults(QueryDataSet,int,boolean)
1012 |  |
          */
1013 |  |
         public static List<Record> getSelectResults(
1014 |  |
             QueryDataSet qds,
1015 |  |
             int numberOfResults,
1016 |  |
             boolean singleRecord)
1017 |  |
             throws TorqueException
1018 |  |
         {
1019 | 0 |
             return BasePeer.getSelectResults(qds,numberOfResults,singleRecord);
1020 |  |
         }
1021 |  |
1022 |  |
         /**
1023 |  |
          * Returns numberOfResults records in a QueryDataSet as a List
1024 |  |
          * of Record objects.  Starting at record start.  Used for
1025 |  |
          * functionality like util.LargeSelect.
1026 |  |
          *
1027 |  |
          * @param qds The <code>QueryDataSet</code> to extract results
1028 |  |
          * from.
1029 |  |
          * @param start The index from which to start retrieving
1030 |  |
          * <code>Record</code> objects from the data set.
1031 |  |
          * @param numberOfResults The number of results to return (or
1032 |  |
          * <code> -1</code> for all results).
1033 |  |
          * @param singleRecord Whether or not we want to select only a
1034 |  |
          * single record.
1035 |  |
          * @return A <code>List</code> of <code>Record</code> objects.
1036 |  |
          * @exception TorqueException If any <code>Exception</code> occurs.
1037 |  |
          * @see org.apache.torque.util.BasePeer#getSelectResults(QueryDataSet,int,int,boolean)
1038 |  |
          */
1039 |  |
         public static List getSelectResults(
1040 |  |
             QueryDataSet qds,
1041 |  |
             int start,
1042 |  |
             int numberOfResults,
1043 |  |
             boolean singleRecord)
1044 |  |
             throws TorqueException
1045 |  |
         {
1046 | 0 |
             return BasePeer.getSelectResults(qds,start,numberOfResults,singleRecord);
1047 |  |
         }
1048 |  |
1049 |  |
         /**
1050 |  |
          * Performs a SQL <code>select</code> using a PreparedStatement.
1051 |  |
          * Note: this method does not handle null criteria values.
1052 |  |
          *
1053 |  |
          * @param criteria
1054 |  |
          * @param con
1055 |  |
          * @return a List of Record objects.
1056 |  |
          * @throws TorqueException Error performing database query.
1057 |  |
          * @see org.apache.torque.util.BasePeer#doPSSelect(Criteria,Connection)
1058 |  |
          */
1059 |  |
         public static List<Record> doPSSelect(Criteria criteria, Connection con)
1060 |  |
             throws TorqueException
1061 |  |
         {
1062 | 0 |
             return BasePeer.doPSSelect(criteria,con);
1063 |  |
         }
1064 |  |
1065 |  |
         /**
1066 |  |
          * Do a Prepared Statement select according to the given criteria
1067 |  |
          *
1068 |  |
          * @param criteria
1069 |  |
          * @return a List of Record objects.
1070 |  |
          * @throws TorqueException Any exceptions caught during processing will be
1071 |  |
          *         rethrown wrapped into a TorqueException.
1072 |  |
          * @see org.apache.torque.util.BasePeer#doPSSelect(Criteria)
1073 |  |
          */
1074 |  |
         public static List<Record> doPSSelect(Criteria criteria) throws TorqueException
1075 |  |
         {
1076 | 0 |
             return BasePeer.doPSSelect(criteria);
1077 |  |
         }
1078 |  |
     }