View Javadoc

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