KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > campware > cream > om > BaseTurbineUserPeer


1 package org.campware.cream.om;
2
3 import java.math.BigDecimal JavaDoc;
4 import java.sql.Connection JavaDoc;
5 import java.sql.SQLException JavaDoc;
6 import java.util.ArrayList JavaDoc;
7 import java.util.Date JavaDoc;
8 import java.util.Iterator JavaDoc;
9 import java.util.LinkedList JavaDoc;
10 import java.util.List JavaDoc;
11
12 import org.apache.torque.NoRowsException;
13 import org.apache.torque.TooManyRowsException;
14 import org.apache.torque.Torque;
15 import org.apache.torque.TorqueException;
16 import org.apache.torque.map.MapBuilder;
17 import org.apache.torque.map.TableMap;
18 import org.apache.torque.om.DateKey;
19 import org.apache.torque.om.NumberKey;
20 import org.apache.torque.om.StringKey;
21 import org.apache.torque.om.ObjectKey;
22 import org.apache.torque.om.SimpleKey;
23 import org.apache.torque.util.BasePeer;
24 import org.apache.torque.util.Criteria;
25
26 import com.workingdogs.village.DataSetException;
27 import com.workingdogs.village.QueryDataSet;
28 import com.workingdogs.village.Record;
29
30 // Local classes
31
import org.campware.cream.om.map.*;
32
33
34 /**
35  * This class was autogenerated by Torque on:
36  *
37  * [Wed May 04 09:10:56 CEST 2005]
38  *
39  */

40 public abstract class BaseTurbineUserPeer
41     extends BasePeer
42 {
43
44     /** the default database name for this class */
45     public static final String JavaDoc DATABASE_NAME = "cream";
46
47      /** the table name for this class */
48     public static final String JavaDoc TABLE_NAME = "TURBINE_USER";
49
50     /**
51      * @return the map builder for this peer
52      * @throws TorqueException Any exceptions caught during processing will be
53      * rethrown wrapped into a TorqueException.
54      */

55     public static MapBuilder getMapBuilder()
56         throws TorqueException
57     {
58         return getMapBuilder(TurbineUserMapBuilder.CLASS_NAME);
59     }
60
61       /** the column name for the USER_ID field */
62     public static final String JavaDoc USER_ID;
63       /** the column name for the LOGIN_NAME field */
64     public static final String JavaDoc LOGIN_NAME;
65       /** the column name for the PASSWORD_VALUE field */
66     public static final String JavaDoc PASSWORD_VALUE;
67       /** the column name for the FIRST_NAME field */
68     public static final String JavaDoc FIRST_NAME;
69       /** the column name for the LAST_NAME field */
70     public static final String JavaDoc LAST_NAME;
71       /** the column name for the EMAIL field */
72     public static final String JavaDoc EMAIL;
73       /** the column name for the CONFIRM_VALUE field */
74     public static final String JavaDoc CONFIRM_VALUE;
75       /** the column name for the MODIFIED field */
76     public static final String JavaDoc MODIFIED;
77       /** the column name for the CREATED field */
78     public static final String JavaDoc CREATED;
79       /** the column name for the LAST_LOGIN field */
80     public static final String JavaDoc LAST_LOGIN;
81       /** the column name for the OBJECTDATA field */
82     public static final String JavaDoc OBJECTDATA;
83   
84     static
85     {
86           USER_ID = "TURBINE_USER.USER_ID";
87           LOGIN_NAME = "TURBINE_USER.LOGIN_NAME";
88           PASSWORD_VALUE = "TURBINE_USER.PASSWORD_VALUE";
89           FIRST_NAME = "TURBINE_USER.FIRST_NAME";
90           LAST_NAME = "TURBINE_USER.LAST_NAME";
91           EMAIL = "TURBINE_USER.EMAIL";
92           CONFIRM_VALUE = "TURBINE_USER.CONFIRM_VALUE";
93           MODIFIED = "TURBINE_USER.MODIFIED";
94           CREATED = "TURBINE_USER.CREATED";
95           LAST_LOGIN = "TURBINE_USER.LAST_LOGIN";
96           OBJECTDATA = "TURBINE_USER.OBJECTDATA";
97           if (Torque.isInit())
98         {
99             try
100             {
101                 getMapBuilder(TurbineUserMapBuilder.CLASS_NAME);
102             }
103             catch (Exception JavaDoc e)
104             {
105                 log.error("Could not initialize Peer", e);
106             }
107         }
108         else
109         {
110             Torque.registerMapBuilder(TurbineUserMapBuilder.CLASS_NAME);
111         }
112     }
113  
114     /** number of columns for this peer */
115     public static final int numColumns = 11;
116
117     /** A class that can be returned by this peer. */
118     protected static final String JavaDoc CLASSNAME_DEFAULT =
119         "org.campware.cream.om.TurbineUser";
120
121     /** A class that can be returned by this peer. */
122     protected static final Class JavaDoc CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT);
123
124     /**
125      * Class object initialization method.
126      *
127      * @param className name of the class to initialize
128      * @return the initialized class
129      */

130     private static Class JavaDoc initClass(String JavaDoc className)
131     {
132         Class JavaDoc c = null;
133         try
134         {
135             c = Class.forName(className);
136         }
137         catch (Throwable JavaDoc t)
138         {
139             log.error("A FATAL ERROR has occurred which should not "
140                 + "have happened under any circumstance. Please notify "
141                 + "the Torque developers <torque-dev@db.apache.org> "
142                 + "and give as many details as possible (including the error "
143                 + "stack trace).", t);
144
145             // Error objects should always be propogated.
146
if (t instanceof Error JavaDoc)
147             {
148                 throw (Error JavaDoc) t.fillInStackTrace();
149             }
150         }
151         return c;
152     }
153
154     /**
155      * Get the list of objects for a ResultSet. Please not that your
156      * resultset MUST return columns in the right order. You can use
157      * getFieldNames() in BaseObject to get the correct sequence.
158      *
159      * @param results the ResultSet
160      * @return the list of objects
161      * @throws TorqueException Any exceptions caught during processing will be
162      * rethrown wrapped into a TorqueException.
163      */

164     public static List JavaDoc resultSet2Objects(java.sql.ResultSet JavaDoc results)
165             throws TorqueException
166     {
167         try
168         {
169             QueryDataSet qds = null;
170             List JavaDoc rows = null;
171             try
172             {
173                 qds = new QueryDataSet(results);
174                 rows = getSelectResults(qds);
175             }
176             finally
177             {
178                 if (qds != null)
179                 {
180                     qds.close();
181                 }
182             }
183
184             return populateObjects(rows);
185         }
186         catch (SQLException JavaDoc e)
187         {
188             throw new TorqueException(e);
189         }
190         catch (DataSetException e)
191         {
192             throw new TorqueException(e);
193         }
194     }
195
196
197   
198     /**
199      * Method to do inserts.
200      *
201      * @param criteria object used to create the INSERT statement.
202      * @throws TorqueException Any exceptions caught during processing will be
203      * rethrown wrapped into a TorqueException.
204      */

205     public static ObjectKey doInsert(Criteria criteria)
206         throws TorqueException
207     {
208         return BaseTurbineUserPeer
209             .doInsert(criteria, (Connection JavaDoc) null);
210     }
211
212     /**
213      * Method to do inserts. This method is to be used during a transaction,
214      * otherwise use the doInsert(Criteria) method. It will take care of
215      * the connection details internally.
216      *
217      * @param criteria object used to create the INSERT statement.
218      * @param con the connection to use
219      * @throws TorqueException Any exceptions caught during processing will be
220      * rethrown wrapped into a TorqueException.
221      */

222     public static ObjectKey doInsert(Criteria criteria, Connection JavaDoc con)
223         throws TorqueException
224     {
225                                                                     
226         setDbName(criteria);
227
228         if (con == null)
229         {
230             return BasePeer.doInsert(criteria);
231         }
232         else
233         {
234             return BasePeer.doInsert(criteria, con);
235         }
236     }
237
238     /**
239      * Add all the columns needed to create a new object.
240      *
241      * @param criteria object containing the columns to add.
242      * @throws TorqueException Any exceptions caught during processing will be
243      * rethrown wrapped into a TorqueException.
244      */

245     public static void addSelectColumns(Criteria criteria)
246             throws TorqueException
247     {
248           criteria.addSelectColumn(USER_ID);
249           criteria.addSelectColumn(LOGIN_NAME);
250           criteria.addSelectColumn(PASSWORD_VALUE);
251           criteria.addSelectColumn(FIRST_NAME);
252           criteria.addSelectColumn(LAST_NAME);
253           criteria.addSelectColumn(EMAIL);
254           criteria.addSelectColumn(CONFIRM_VALUE);
255           criteria.addSelectColumn(MODIFIED);
256           criteria.addSelectColumn(CREATED);
257           criteria.addSelectColumn(LAST_LOGIN);
258           criteria.addSelectColumn(OBJECTDATA);
259       }
260
261     /**
262      * Create a new object of type cls from a resultset row starting
263      * from a specified offset. This is done so that you can select
264      * other rows than just those needed for this object. You may
265      * for example want to create two objects from the same row.
266      *
267      * @throws TorqueException Any exceptions caught during processing will be
268      * rethrown wrapped into a TorqueException.
269      */

270     public static TurbineUser row2Object(Record row,
271                                              int offset,
272                                              Class JavaDoc cls)
273         throws TorqueException
274     {
275         try
276         {
277             TurbineUser obj = (TurbineUser) cls.newInstance();
278             TurbineUserPeer.populateObject(row, offset, obj);
279                   obj.setModified(false);
280               obj.setNew(false);
281
282             return obj;
283         }
284         catch (InstantiationException JavaDoc e)
285         {
286             throw new TorqueException(e);
287         }
288         catch (IllegalAccessException JavaDoc e)
289         {
290             throw new TorqueException(e);
291         }
292     }
293
294     /**
295      * Populates an object from a resultset row starting
296      * from a specified offset. This is done so that you can select
297      * other rows than just those needed for this object. You may
298      * for example want to create two objects from the same row.
299      *
300      * @throws TorqueException Any exceptions caught during processing will be
301      * rethrown wrapped into a TorqueException.
302      */

303     public static void populateObject(Record row,
304                                       int offset,
305                                       TurbineUser obj)
306         throws TorqueException
307     {
308         try
309         {
310                 obj.setUserId(row.getValue(offset + 0).asInt());
311                   obj.setUserName(row.getValue(offset + 1).asString());
312                   obj.setPassword(row.getValue(offset + 2).asString());
313                   obj.setFirstName(row.getValue(offset + 3).asString());
314                   obj.setLastName(row.getValue(offset + 4).asString());
315                   obj.setEmail(row.getValue(offset + 5).asString());
316                   obj.setConfirmed(row.getValue(offset + 6).asString());
317                   obj.setModified(row.getValue(offset + 7).asUtilDate());
318                   obj.setCreateDate(row.getValue(offset + 8).asUtilDate());
319                   obj.setLastLogin(row.getValue(offset + 9).asUtilDate());
320                   obj.setObjectdata(row.getValue(offset + 10).asBytes());
321               }
322         catch (DataSetException e)
323         {
324             throw new TorqueException(e);
325         }
326     }
327
328     /**
329      * Method to do selects.
330      *
331      * @param criteria object used to create the SELECT statement.
332      * @return List of selected Objects
333      * @throws TorqueException Any exceptions caught during processing will be
334      * rethrown wrapped into a TorqueException.
335      */

336     public static List JavaDoc doSelect(Criteria criteria) throws TorqueException
337     {
338         return populateObjects(doSelectVillageRecords(criteria));
339     }
340
341     /**
342      * Method to do selects within a transaction.
343      *
344      * @param criteria object used to create the SELECT statement.
345      * @param con the connection to use
346      * @return List of selected Objects
347      * @throws TorqueException Any exceptions caught during processing will be
348      * rethrown wrapped into a TorqueException.
349      */

350     public static List JavaDoc doSelect(Criteria criteria, Connection JavaDoc con)
351         throws TorqueException
352     {
353         return populateObjects(doSelectVillageRecords(criteria, con));
354     }
355
356     /**
357      * Grabs the raw Village records to be formed into objects.
358      * This method handles connections internally. The Record objects
359      * returned by this method should be considered readonly. Do not
360      * alter the data and call save(), your results may vary, but are
361      * certainly likely to result in hard to track MT bugs.
362      *
363      * @throws TorqueException Any exceptions caught during processing will be
364      * rethrown wrapped into a TorqueException.
365      */

366     public static List JavaDoc doSelectVillageRecords(Criteria criteria)
367         throws TorqueException
368     {
369         return BaseTurbineUserPeer
370             .doSelectVillageRecords(criteria, (Connection JavaDoc) null);
371     }
372
373     /**
374      * Grabs the raw Village records to be formed into objects.
375      * This method should be used for transactions
376      *
377      * @param criteria object used to create the SELECT statement.
378      * @param con the connection to use
379      * @throws TorqueException Any exceptions caught during processing will be
380      * rethrown wrapped into a TorqueException.
381      */

382     public static List JavaDoc doSelectVillageRecords(Criteria criteria, Connection JavaDoc con)
383         throws TorqueException
384     {
385         if (criteria.getSelectColumns().size() == 0)
386         {
387             addSelectColumns(criteria);
388         }
389
390                                                                     
391         setDbName(criteria);
392
393         // BasePeer returns a List of Value (Village) arrays. The array
394
// order follows the order columns were placed in the Select clause.
395
if (con == null)
396         {
397             return BasePeer.doSelect(criteria);
398         }
399         else
400         {
401             return BasePeer.doSelect(criteria, con);
402         }
403     }
404
405     /**
406      * The returned List will contain objects of the default type or
407      * objects that inherit from the default.
408      *
409      * @throws TorqueException Any exceptions caught during processing will be
410      * rethrown wrapped into a TorqueException.
411      */

412     public static List JavaDoc populateObjects(List JavaDoc records)
413         throws TorqueException
414     {
415         List JavaDoc results = new ArrayList JavaDoc(records.size());
416
417         // populate the object(s)
418
for (int i = 0; i < records.size(); i++)
419         {
420             Record row = (Record) records.get(i);
421               results.add(TurbineUserPeer.row2Object(row, 1,
422                 TurbineUserPeer.getOMClass()));
423           }
424         return results;
425     }
426  
427
428     /**
429      * The class that the Peer will make instances of.
430      * If the BO is abstract then you must implement this method
431      * in the BO.
432      *
433      * @throws TorqueException Any exceptions caught during processing will be
434      * rethrown wrapped into a TorqueException.
435      */

436     public static Class JavaDoc getOMClass()
437         throws TorqueException
438     {
439         return CLASS_DEFAULT;
440     }
441
442     /**
443      * Method to do updates.
444      *
445      * @param criteria object containing data that is used to create the UPDATE
446      * statement.
447      * @throws TorqueException Any exceptions caught during processing will be
448      * rethrown wrapped into a TorqueException.
449      */

450     public static void doUpdate(Criteria criteria) throws TorqueException
451     {
452          BaseTurbineUserPeer
453             .doUpdate(criteria, (Connection JavaDoc) null);
454     }
455
456     /**
457      * Method to do updates. This method is to be used during a transaction,
458      * otherwise use the doUpdate(Criteria) method. It will take care of
459      * the connection details internally.
460      *
461      * @param criteria object containing data that is used to create the UPDATE
462      * statement.
463      * @param con the connection to use
464      * @throws TorqueException Any exceptions caught during processing will be
465      * rethrown wrapped into a TorqueException.
466      */

467     public static void doUpdate(Criteria criteria, Connection JavaDoc con)
468         throws TorqueException
469     {
470         Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
471                    selectCriteria.put(USER_ID, criteria.remove(USER_ID));
472                                                                                                           
473         setDbName(criteria);
474
475         if (con == null)
476         {
477             BasePeer.doUpdate(selectCriteria, criteria);
478         }
479         else
480         {
481             BasePeer.doUpdate(selectCriteria, criteria, con);
482         }
483     }
484
485     /**
486      * Method to do deletes.
487      *
488      * @param criteria object containing data that is used DELETE from database.
489      * @throws TorqueException Any exceptions caught during processing will be
490      * rethrown wrapped into a TorqueException.
491      */

492      public static void doDelete(Criteria criteria) throws TorqueException
493      {
494          TurbineUserPeer
495             .doDelete(criteria, (Connection JavaDoc) null);
496      }
497
498     /**
499      * Method to do deletes. This method is to be used during a transaction,
500      * otherwise use the doDelete(Criteria) method. It will take care of
501      * the connection details internally.
502      *
503      * @param criteria object containing data that is used DELETE from database.
504      * @param con the connection to use
505      * @throws TorqueException Any exceptions caught during processing will be
506      * rethrown wrapped into a TorqueException.
507      */

508      public static void doDelete(Criteria criteria, Connection JavaDoc con)
509         throws TorqueException
510      {
511                                                                     
512         setDbName(criteria);
513
514         if (con == null)
515         {
516             BasePeer.doDelete(criteria);
517         }
518         else
519         {
520             BasePeer.doDelete(criteria, con);
521         }
522      }
523
524     /**
525      * Method to do selects
526      *
527      * @throws TorqueException Any exceptions caught during processing will be
528      * rethrown wrapped into a TorqueException.
529      */

530     public static List JavaDoc doSelect(TurbineUser obj) throws TorqueException
531     {
532         return doSelect(buildSelectCriteria(obj));
533     }
534
535     /**
536      * Method to do inserts
537      *
538      * @throws TorqueException Any exceptions caught during processing will be
539      * rethrown wrapped into a TorqueException.
540      */

541     public static void doInsert(TurbineUser obj) throws TorqueException
542     {
543           obj.setPrimaryKey(doInsert(buildCriteria(obj)));
544           obj.setNew(false);
545         obj.setModified(false);
546     }
547
548     /**
549      * @param obj the data object to update in the database.
550      * @throws TorqueException Any exceptions caught during processing will be
551      * rethrown wrapped into a TorqueException.
552      */

553     public static void doUpdate(TurbineUser obj) throws TorqueException
554     {
555         doUpdate(buildCriteria(obj));
556         obj.setModified(false);
557     }
558
559     /**
560      * @param obj the data object to delete in the database.
561      * @throws TorqueException Any exceptions caught during processing will be
562      * rethrown wrapped into a TorqueException.
563      */

564     public static void doDelete(TurbineUser obj) throws TorqueException
565     {
566         doDelete(buildSelectCriteria(obj));
567     }
568
569     /**
570      * Method to do inserts. This method is to be used during a transaction,
571      * otherwise use the doInsert(TurbineUser) method. It will take
572      * care of the connection details internally.
573      *
574      * @param obj the data object to insert into the database.
575      * @param con the connection to use
576      * @throws TorqueException Any exceptions caught during processing will be
577      * rethrown wrapped into a TorqueException.
578      */

579     public static void doInsert(TurbineUser obj, Connection JavaDoc con)
580         throws TorqueException
581     {
582           obj.setPrimaryKey(doInsert(buildCriteria(obj), con));
583           obj.setNew(false);
584         obj.setModified(false);
585     }
586
587     /**
588      * Method to do update. This method is to be used during a transaction,
589      * otherwise use the doUpdate(TurbineUser) method. It will take
590      * care of the connection details internally.
591      *
592      * @param obj the data object to update in the database.
593      * @param con the connection to use
594      * @throws TorqueException Any exceptions caught during processing will be
595      * rethrown wrapped into a TorqueException.
596      */

597     public static void doUpdate(TurbineUser obj, Connection JavaDoc con)
598         throws TorqueException
599     {
600         doUpdate(buildCriteria(obj), con);
601         obj.setModified(false);
602     }
603
604     /**
605      * Method to delete. This method is to be used during a transaction,
606      * otherwise use the doDelete(TurbineUser) method. It will take
607      * care of the connection details internally.
608      *
609      * @param obj the data object to delete in the database.
610      * @param con the connection to use
611      * @throws TorqueException Any exceptions caught during processing will be
612      * rethrown wrapped into a TorqueException.
613      */

614     public static void doDelete(TurbineUser obj, Connection JavaDoc con)
615         throws TorqueException
616     {
617         doDelete(buildSelectCriteria(obj), con);
618     }
619
620     /**
621      * Method to do deletes.
622      *
623      * @param pk ObjectKey that is used DELETE from database.
624      * @throws TorqueException Any exceptions caught during processing will be
625      * rethrown wrapped into a TorqueException.
626      */

627     public static void doDelete(ObjectKey pk) throws TorqueException
628     {
629         BaseTurbineUserPeer
630            .doDelete(pk, (Connection JavaDoc) null);
631     }
632
633     /**
634      * Method to delete. This method is to be used during a transaction,
635      * otherwise use the doDelete(ObjectKey) method. It will take
636      * care of the connection details internally.
637      *
638      * @param pk the primary key for the object to delete in the database.
639      * @param con the connection to use
640      * @throws TorqueException Any exceptions caught during processing will be
641      * rethrown wrapped into a TorqueException.
642      */

643     public static void doDelete(ObjectKey pk, Connection JavaDoc con)
644         throws TorqueException
645     {
646         doDelete(buildCriteria(pk), con);
647     }
648
649     /** Build a Criteria object from an ObjectKey */
650     public static Criteria buildCriteria( ObjectKey pk )
651     {
652         Criteria criteria = new Criteria();
653               criteria.add(USER_ID, pk);
654           return criteria;
655      }
656
657     /** Build a Criteria object from the data object for this peer */
658     public static Criteria buildCriteria( TurbineUser obj )
659     {
660         Criteria criteria = new Criteria(DATABASE_NAME);
661               if (!obj.isNew())
662             criteria.add(USER_ID, obj.getUserId());
663               criteria.add(LOGIN_NAME, obj.getUserName());
664               criteria.add(PASSWORD_VALUE, obj.getPassword());
665               criteria.add(FIRST_NAME, obj.getFirstName());
666               criteria.add(LAST_NAME, obj.getLastName());
667               criteria.add(EMAIL, obj.getEmail());
668               criteria.add(CONFIRM_VALUE, obj.getConfirmed());
669               criteria.add(MODIFIED, obj.getModified());
670               criteria.add(CREATED, obj.getCreateDate());
671               criteria.add(LAST_LOGIN, obj.getLastLogin());
672               criteria.add(OBJECTDATA, obj.getObjectdata());
673           return criteria;
674     }
675
676     /** Build a Criteria object from the data object for this peer, skipping all binary columns */
677     public static Criteria buildSelectCriteria( TurbineUser obj )
678     {
679         Criteria criteria = new Criteria(DATABASE_NAME);
680               if (!obj.isNew())
681                     criteria.add(USER_ID, obj.getUserId());
682                           criteria.add(LOGIN_NAME, obj.getUserName());
683                           criteria.add(PASSWORD_VALUE, obj.getPassword());
684                           criteria.add(FIRST_NAME, obj.getFirstName());
685                           criteria.add(LAST_NAME, obj.getLastName());
686                           criteria.add(EMAIL, obj.getEmail());
687                           criteria.add(CONFIRM_VALUE, obj.getConfirmed());
688                           criteria.add(MODIFIED, obj.getModified());
689                           criteria.add(CREATED, obj.getCreateDate());
690                           criteria.add(LAST_LOGIN, obj.getLastLogin());
691                         return criteria;
692     }
693  
694     
695         /**
696      * Retrieve a single object by pk
697      *
698      * @param pk the primary key
699      * @throws TorqueException Any exceptions caught during processing will be
700      * rethrown wrapped into a TorqueException.
701      * @throws NoRowsException Primary key was not found in database.
702      * @throws TooManyRowsException Primary key was not found in database.
703      */

704     public static TurbineUser retrieveByPK(int pk)
705         throws TorqueException, NoRowsException, TooManyRowsException
706     {
707         return retrieveByPK(SimpleKey.keyFor(pk));
708     }
709
710     /**
711      * Retrieve a single object by pk
712      *
713      * @param pk the primary key
714      * @param con the connection to use
715      * @throws TorqueException Any exceptions caught during processing will be
716      * rethrown wrapped into a TorqueException.
717      * @throws NoRowsException Primary key was not found in database.
718      * @throws TooManyRowsException Primary key was not found in database.
719      */

720     public static TurbineUser retrieveByPK(int pk, Connection JavaDoc con)
721         throws TorqueException, NoRowsException, TooManyRowsException
722     {
723         return retrieveByPK(SimpleKey.keyFor(pk), con);
724     }
725   
726     /**
727      * Retrieve a single object by pk
728      *
729      * @param pk the primary key
730      * @throws TorqueException Any exceptions caught during processing will be
731      * rethrown wrapped into a TorqueException.
732      * @throws NoRowsException Primary key was not found in database.
733      * @throws TooManyRowsException Primary key was not found in database.
734      */

735     public static TurbineUser retrieveByPK(ObjectKey pk)
736         throws TorqueException, NoRowsException, TooManyRowsException
737     {
738         Connection JavaDoc db = null;
739         TurbineUser retVal = null;
740         try
741         {
742             db = Torque.getConnection(DATABASE_NAME);
743             retVal = retrieveByPK(pk, db);
744         }
745         finally
746         {
747             Torque.closeConnection(db);
748         }
749         return(retVal);
750     }
751
752     /**
753      * Retrieve a single object by pk
754      *
755      * @param pk the primary key
756      * @param con the connection to use
757      * @throws TorqueException Any exceptions caught during processing will be
758      * rethrown wrapped into a TorqueException.
759      * @throws NoRowsException Primary key was not found in database.
760      * @throws TooManyRowsException Primary key was not found in database.
761      */

762     public static TurbineUser retrieveByPK(ObjectKey pk, Connection JavaDoc con)
763         throws TorqueException, NoRowsException, TooManyRowsException
764     {
765         Criteria criteria = buildCriteria(pk);
766         List JavaDoc v = doSelect(criteria, con);
767         if (v.size() == 0)
768         {
769             throw new NoRowsException("Failed to select a row.");
770         }
771         else if (v.size() > 1)
772         {
773             throw new TooManyRowsException("Failed to select only one row.");
774         }
775         else
776         {
777             return (TurbineUser)v.get(0);
778         }
779     }
780
781     /**
782      * Retrieve a multiple objects by pk
783      *
784      * @param pks List of primary keys
785      * @throws TorqueException Any exceptions caught during processing will be
786      * rethrown wrapped into a TorqueException.
787      */

788     public static List JavaDoc retrieveByPKs(List JavaDoc pks)
789         throws TorqueException
790     {
791         Connection JavaDoc db = null;
792         List JavaDoc retVal = null;
793         try
794         {
795            db = Torque.getConnection(DATABASE_NAME);
796            retVal = retrieveByPKs(pks, db);
797         }
798         finally
799         {
800             Torque.closeConnection(db);
801         }
802         return(retVal);
803     }
804
805     /**
806      * Retrieve a multiple objects by pk
807      *
808      * @param pks List of primary keys
809      * @param dbcon the connection to use
810      * @throws TorqueException Any exceptions caught during processing will be
811      * rethrown wrapped into a TorqueException.
812      */

813     public static List JavaDoc retrieveByPKs( List JavaDoc pks, Connection JavaDoc dbcon )
814         throws TorqueException
815     {
816         List JavaDoc objs = null;
817         if (pks == null || pks.size() == 0)
818         {
819             objs = new LinkedList JavaDoc();
820         }
821         else
822         {
823             Criteria criteria = new Criteria();
824               criteria.addIn( USER_ID, pks );
825           objs = doSelect(criteria, dbcon);
826         }
827         return objs;
828     }
829
830  
831
832
833
834         
835   
836   
837     
838   
839       /**
840      * Returns the TableMap related to this peer. This method is not
841      * needed for general use but a specific application could have a need.
842      *
843      * @throws TorqueException Any exceptions caught during processing will be
844      * rethrown wrapped into a TorqueException.
845      */

846     protected static TableMap getTableMap()
847         throws TorqueException
848     {
849         return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME);
850     }
851    
852     private static void setDbName(Criteria crit)
853     {
854         // Set the correct dbName if it has not been overridden
855
// crit.getDbName will return the same object if not set to
856
// another value so == check is okay and faster
857
if (crit.getDbName() == Torque.getDefaultDB())
858         {
859             crit.setDbName(DATABASE_NAME);
860         }
861     }
862 }
863
Popular Tags