View Javadoc

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