KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > tigris > scarab > om > BaseAttributeClassPeer


1 package org.tigris.scarab.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.tigris.scarab.om.map.*;
32
33
34 /**
35  */

36 public abstract class BaseAttributeClassPeer
37     extends BasePeer
38 {
39
40     /** the default database name for this class */
41     public static final String JavaDoc DATABASE_NAME = "scarab";
42
43      /** the table name for this class */
44     public static final String JavaDoc TABLE_NAME = "SCARAB_ATTRIBUTE_CLASS";
45
46     /**
47      * @return the map builder for this peer
48      * @throws TorqueException Any exceptions caught during processing will be
49      * rethrown wrapped into a TorqueException.
50      */

51     public static MapBuilder getMapBuilder()
52         throws TorqueException
53     {
54         return getMapBuilder(AttributeClassMapBuilder.CLASS_NAME);
55     }
56
57       /** the column name for the ATTRIBUTE_CLASS_ID field */
58     public static final String JavaDoc ATTRIBUTE_CLASS_ID;
59       /** the column name for the ATTRIBUTE_CLASS_NAME field */
60     public static final String JavaDoc ATTRIBUTE_CLASS_NAME;
61       /** the column name for the ATTRIBUTE_CLASS_DESC field */
62     public static final String JavaDoc ATTRIBUTE_CLASS_DESC;
63       /** the column name for the JAVA_CLASS_NAME field */
64     public static final String JavaDoc JAVA_CLASS_NAME;
65   
66     static
67     {
68           ATTRIBUTE_CLASS_ID = "SCARAB_ATTRIBUTE_CLASS.ATTRIBUTE_CLASS_ID";
69           ATTRIBUTE_CLASS_NAME = "SCARAB_ATTRIBUTE_CLASS.ATTRIBUTE_CLASS_NAME";
70           ATTRIBUTE_CLASS_DESC = "SCARAB_ATTRIBUTE_CLASS.ATTRIBUTE_CLASS_DESC";
71           JAVA_CLASS_NAME = "SCARAB_ATTRIBUTE_CLASS.JAVA_CLASS_NAME";
72           if (Torque.isInit())
73         {
74             try
75             {
76                 getMapBuilder(AttributeClassMapBuilder.CLASS_NAME);
77             }
78             catch (Exception JavaDoc e)
79             {
80                 log.error("Could not initialize Peer", e);
81             }
82         }
83         else
84         {
85             Torque.registerMapBuilder(AttributeClassMapBuilder.CLASS_NAME);
86         }
87     }
88  
89     /** number of columns for this peer */
90     public static final int numColumns = 4;
91
92     /** A class that can be returned by this peer. */
93     protected static final String JavaDoc CLASSNAME_DEFAULT =
94         "org.tigris.scarab.om.AttributeClass";
95
96     /** A class that can be returned by this peer. */
97     protected static final Class JavaDoc CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT);
98
99     /**
100      * Class object initialization method.
101      *
102      * @param className name of the class to initialize
103      * @return the initialized class
104      */

105     private static Class JavaDoc initClass(String JavaDoc className)
106     {
107         Class JavaDoc c = null;
108         try
109         {
110             c = Class.forName(className);
111         }
112         catch (Throwable JavaDoc t)
113         {
114             log.error("A FATAL ERROR has occurred which should not "
115                 + "have happened under any circumstance. Please notify "
116                 + "the Torque developers <torque-dev@db.apache.org> "
117                 + "and give as many details as possible (including the error "
118                 + "stack trace).", t);
119
120             // Error objects should always be propogated.
121
if (t instanceof Error JavaDoc)
122             {
123                 throw (Error JavaDoc) t.fillInStackTrace();
124             }
125         }
126         return c;
127     }
128
129     /**
130      * Get the list of objects for a ResultSet. Please not that your
131      * resultset MUST return columns in the right order. You can use
132      * getFieldNames() in BaseObject to get the correct sequence.
133      *
134      * @param results the ResultSet
135      * @return the list of objects
136      * @throws TorqueException Any exceptions caught during processing will be
137      * rethrown wrapped into a TorqueException.
138      */

139     public static List JavaDoc resultSet2Objects(java.sql.ResultSet JavaDoc results)
140             throws TorqueException
141     {
142         try
143         {
144             QueryDataSet qds = null;
145             List JavaDoc rows = null;
146             try
147             {
148                 qds = new QueryDataSet(results);
149                 rows = getSelectResults(qds);
150             }
151             finally
152             {
153                 if (qds != null)
154                 {
155                     qds.close();
156                 }
157             }
158
159             return populateObjects(rows);
160         }
161         catch (SQLException JavaDoc e)
162         {
163             throw new TorqueException(e);
164         }
165         catch (DataSetException e)
166         {
167             throw new TorqueException(e);
168         }
169     }
170
171
172   
173     /**
174      * Method to do inserts.
175      *
176      * @param criteria object used to create the INSERT statement.
177      * @throws TorqueException Any exceptions caught during processing will be
178      * rethrown wrapped into a TorqueException.
179      */

180     public static ObjectKey doInsert(Criteria criteria)
181         throws TorqueException
182     {
183         return BaseAttributeClassPeer
184             .doInsert(criteria, (Connection JavaDoc) null);
185     }
186
187     /**
188      * Method to do inserts. This method is to be used during a transaction,
189      * otherwise use the doInsert(Criteria) method. It will take care of
190      * the connection details internally.
191      *
192      * @param criteria object used to create the INSERT statement.
193      * @param con the connection to use
194      * @throws TorqueException Any exceptions caught during processing will be
195      * rethrown wrapped into a TorqueException.
196      */

197     public static ObjectKey doInsert(Criteria criteria, Connection JavaDoc con)
198         throws TorqueException
199     {
200                           
201         setDbName(criteria);
202
203         if (con == null)
204         {
205             return BasePeer.doInsert(criteria);
206         }
207         else
208         {
209             return BasePeer.doInsert(criteria, con);
210         }
211     }
212
213     /**
214      * Add all the columns needed to create a new object.
215      *
216      * @param criteria object containing the columns to add.
217      * @throws TorqueException Any exceptions caught during processing will be
218      * rethrown wrapped into a TorqueException.
219      */

220     public static void addSelectColumns(Criteria criteria)
221             throws TorqueException
222     {
223           criteria.addSelectColumn(ATTRIBUTE_CLASS_ID);
224           criteria.addSelectColumn(ATTRIBUTE_CLASS_NAME);
225           criteria.addSelectColumn(ATTRIBUTE_CLASS_DESC);
226           criteria.addSelectColumn(JAVA_CLASS_NAME);
227       }
228
229     /**
230      * Create a new object of type cls from a resultset row starting
231      * from a specified offset. This is done so that you can select
232      * other rows than just those needed for this object. You may
233      * for example want to create two objects from the same row.
234      *
235      * @throws TorqueException Any exceptions caught during processing will be
236      * rethrown wrapped into a TorqueException.
237      */

238     public static AttributeClass row2Object(Record row,
239                                              int offset,
240                                              Class JavaDoc cls)
241         throws TorqueException
242     {
243         try
244         {
245             AttributeClass obj = (AttributeClass) cls.newInstance();
246             AttributeClassPeer.populateObject(row, offset, obj);
247                   obj.setModified(false);
248               obj.setNew(false);
249
250             return obj;
251         }
252         catch (InstantiationException JavaDoc e)
253         {
254             throw new TorqueException(e);
255         }
256         catch (IllegalAccessException JavaDoc e)
257         {
258             throw new TorqueException(e);
259         }
260     }
261
262     /**
263      * Populates an object from a resultset row starting
264      * from a specified offset. This is done so that you can select
265      * other rows than just those needed for this object. You may
266      * for example want to create two objects from the same row.
267      *
268      * @throws TorqueException Any exceptions caught during processing will be
269      * rethrown wrapped into a TorqueException.
270      */

271     public static void populateObject(Record row,
272                                       int offset,
273                                       AttributeClass obj)
274         throws TorqueException
275     {
276         try
277         {
278                 obj.setAttributeClassId(row.getValue(offset + 0).asIntegerObj());
279                   obj.setName(row.getValue(offset + 1).asString());
280                   obj.setDesc(row.getValue(offset + 2).asString());
281                   obj.setJavaClassName(row.getValue(offset + 3).asString());
282               }
283         catch (DataSetException e)
284         {
285             throw new TorqueException(e);
286         }
287     }
288
289     /**
290      * Method to do selects.
291      *
292      * @param criteria object used to create the SELECT statement.
293      * @return List of selected Objects
294      * @throws TorqueException Any exceptions caught during processing will be
295      * rethrown wrapped into a TorqueException.
296      */

297     public static List JavaDoc doSelect(Criteria criteria) throws TorqueException
298     {
299         return populateObjects(doSelectVillageRecords(criteria));
300     }
301
302     /**
303      * Method to do selects within a transaction.
304      *
305      * @param criteria object used to create the SELECT statement.
306      * @param con the connection to use
307      * @return List of selected Objects
308      * @throws TorqueException Any exceptions caught during processing will be
309      * rethrown wrapped into a TorqueException.
310      */

311     public static List JavaDoc doSelect(Criteria criteria, Connection JavaDoc con)
312         throws TorqueException
313     {
314         return populateObjects(doSelectVillageRecords(criteria, con));
315     }
316
317     /**
318      * Grabs the raw Village records to be formed into objects.
319      * This method handles connections internally. The Record objects
320      * returned by this method should be considered readonly. Do not
321      * alter the data and call save(), your results may vary, but are
322      * certainly likely to result in hard to track MT bugs.
323      *
324      * @throws TorqueException Any exceptions caught during processing will be
325      * rethrown wrapped into a TorqueException.
326      */

327     public static List JavaDoc doSelectVillageRecords(Criteria criteria)
328         throws TorqueException
329     {
330         return BaseAttributeClassPeer
331             .doSelectVillageRecords(criteria, (Connection JavaDoc) null);
332     }
333
334     /**
335      * Grabs the raw Village records to be formed into objects.
336      * This method should be used for transactions
337      *
338      * @param criteria object used to create the SELECT statement.
339      * @param con the connection to use
340      * @throws TorqueException Any exceptions caught during processing will be
341      * rethrown wrapped into a TorqueException.
342      */

343     public static List JavaDoc doSelectVillageRecords(Criteria criteria, Connection JavaDoc con)
344         throws TorqueException
345     {
346         if (criteria.getSelectColumns().size() == 0)
347         {
348             addSelectColumns(criteria);
349         }
350
351                           
352         setDbName(criteria);
353
354         // BasePeer returns a List of Value (Village) arrays. The array
355
// order follows the order columns were placed in the Select clause.
356
if (con == null)
357         {
358             return BasePeer.doSelect(criteria);
359         }
360         else
361         {
362             return BasePeer.doSelect(criteria, con);
363         }
364     }
365
366     /**
367      * The returned List will contain objects of the default type or
368      * objects that inherit from the default.
369      *
370      * @throws TorqueException Any exceptions caught during processing will be
371      * rethrown wrapped into a TorqueException.
372      */

373     public static List JavaDoc populateObjects(List JavaDoc records)
374         throws TorqueException
375     {
376         List JavaDoc results = new ArrayList JavaDoc(records.size());
377
378         // populate the object(s)
379
for (int i = 0; i < records.size(); i++)
380         {
381             Record row = (Record) records.get(i);
382               results.add(AttributeClassPeer.row2Object(row, 1,
383                 AttributeClassPeer.getOMClass()));
384           }
385         return results;
386     }
387  
388
389     /**
390      * The class that the Peer will make instances of.
391      * If the BO is abstract then you must implement this method
392      * in the BO.
393      *
394      * @throws TorqueException Any exceptions caught during processing will be
395      * rethrown wrapped into a TorqueException.
396      */

397     public static Class JavaDoc getOMClass()
398         throws TorqueException
399     {
400         return CLASS_DEFAULT;
401     }
402
403     /**
404      * Method to do updates.
405      *
406      * @param criteria object containing data that is used to create the UPDATE
407      * statement.
408      * @throws TorqueException Any exceptions caught during processing will be
409      * rethrown wrapped into a TorqueException.
410      */

411     public static void doUpdate(Criteria criteria) throws TorqueException
412     {
413          BaseAttributeClassPeer
414             .doUpdate(criteria, (Connection JavaDoc) null);
415     }
416
417     /**
418      * Method to do updates. This method is to be used during a transaction,
419      * otherwise use the doUpdate(Criteria) method. It will take care of
420      * the connection details internally.
421      *
422      * @param criteria object containing data that is used to create the UPDATE
423      * statement.
424      * @param con the connection to use
425      * @throws TorqueException Any exceptions caught during processing will be
426      * rethrown wrapped into a TorqueException.
427      */

428     public static void doUpdate(Criteria criteria, Connection JavaDoc con)
429         throws TorqueException
430     {
431         Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
432                    selectCriteria.put(ATTRIBUTE_CLASS_ID, criteria.remove(ATTRIBUTE_CLASS_ID));
433                                     
434         setDbName(criteria);
435
436         if (con == null)
437         {
438             BasePeer.doUpdate(selectCriteria, criteria);
439         }
440         else
441         {
442             BasePeer.doUpdate(selectCriteria, criteria, con);
443         }
444     }
445
446     /**
447      * Method to do deletes.
448      *
449      * @param criteria object containing data that is used DELETE from database.
450      * @throws TorqueException Any exceptions caught during processing will be
451      * rethrown wrapped into a TorqueException.
452      */

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

469      public static void doDelete(Criteria criteria, Connection JavaDoc con)
470         throws TorqueException
471      {
472                           
473         setDbName(criteria);
474
475         if (con == null)
476         {
477             BasePeer.doDelete(criteria);
478         }
479         else
480         {
481             BasePeer.doDelete(criteria, con);
482         }
483      }
484
485     /**
486      * Method to do selects
487      *
488      * @throws TorqueException Any exceptions caught during processing will be
489      * rethrown wrapped into a TorqueException.
490      */

491     public static List JavaDoc doSelect(AttributeClass obj) throws TorqueException
492     {
493         return doSelect(buildSelectCriteria(obj));
494     }
495
496     /**
497      * Method to do inserts
498      *
499      * @throws TorqueException Any exceptions caught during processing will be
500      * rethrown wrapped into a TorqueException.
501      */

502     public static void doInsert(AttributeClass obj) throws TorqueException
503     {
504           obj.setPrimaryKey(doInsert(buildCriteria(obj)));
505           obj.setNew(false);
506         obj.setModified(false);
507     }
508
509     /**
510      * @param obj the data object to update in the database.
511      * @throws TorqueException Any exceptions caught during processing will be
512      * rethrown wrapped into a TorqueException.
513      */

514     public static void doUpdate(AttributeClass obj) throws TorqueException
515     {
516         doUpdate(buildCriteria(obj));
517         obj.setModified(false);
518     }
519
520     /**
521      * @param obj the data object to delete in the database.
522      * @throws TorqueException Any exceptions caught during processing will be
523      * rethrown wrapped into a TorqueException.
524      */

525     public static void doDelete(AttributeClass obj) throws TorqueException
526     {
527         doDelete(buildSelectCriteria(obj));
528     }
529
530     /**
531      * Method to do inserts. This method is to be used during a transaction,
532      * otherwise use the doInsert(AttributeClass) method. It will take
533      * care of the connection details internally.
534      *
535      * @param obj the data object to insert into the database.
536      * @param con the connection to use
537      * @throws TorqueException Any exceptions caught during processing will be
538      * rethrown wrapped into a TorqueException.
539      */

540     public static void doInsert(AttributeClass obj, Connection JavaDoc con)
541         throws TorqueException
542     {
543           obj.setPrimaryKey(doInsert(buildCriteria(obj), con));
544           obj.setNew(false);
545         obj.setModified(false);
546     }
547
548     /**
549      * Method to do update. This method is to be used during a transaction,
550      * otherwise use the doUpdate(AttributeClass) method. It will take
551      * care of the connection details internally.
552      *
553      * @param obj the data object to update in the database.
554      * @param con the connection to use
555      * @throws TorqueException Any exceptions caught during processing will be
556      * rethrown wrapped into a TorqueException.
557      */

558     public static void doUpdate(AttributeClass obj, Connection JavaDoc con)
559         throws TorqueException
560     {
561         doUpdate(buildCriteria(obj), con);
562         obj.setModified(false);
563     }
564
565     /**
566      * Method to delete. This method is to be used during a transaction,
567      * otherwise use the doDelete(AttributeClass) method. It will take
568      * care of the connection details internally.
569      *
570      * @param obj the data object to delete in the database.
571      * @param con the connection to use
572      * @throws TorqueException Any exceptions caught during processing will be
573      * rethrown wrapped into a TorqueException.
574      */

575     public static void doDelete(AttributeClass obj, Connection JavaDoc con)
576         throws TorqueException
577     {
578         doDelete(buildSelectCriteria(obj), con);
579     }
580
581     /**
582      * Method to do deletes.
583      *
584      * @param pk ObjectKey that is used DELETE from database.
585      * @throws TorqueException Any exceptions caught during processing will be
586      * rethrown wrapped into a TorqueException.
587      */

588     public static void doDelete(ObjectKey pk) throws TorqueException
589     {
590         BaseAttributeClassPeer
591            .doDelete(pk, (Connection JavaDoc) null);
592     }
593
594     /**
595      * Method to delete. This method is to be used during a transaction,
596      * otherwise use the doDelete(ObjectKey) method. It will take
597      * care of the connection details internally.
598      *
599      * @param pk the primary key for the object to delete in the database.
600      * @param con the connection to use
601      * @throws TorqueException Any exceptions caught during processing will be
602      * rethrown wrapped into a TorqueException.
603      */

604     public static void doDelete(ObjectKey pk, Connection JavaDoc con)
605         throws TorqueException
606     {
607         doDelete(buildCriteria(pk), con);
608     }
609
610     /** Build a Criteria object from an ObjectKey */
611     public static Criteria buildCriteria( ObjectKey pk )
612     {
613         Criteria criteria = new Criteria();
614               criteria.add(ATTRIBUTE_CLASS_ID, pk);
615           return criteria;
616      }
617
618     /** Build a Criteria object from the data object for this peer */
619     public static Criteria buildCriteria( AttributeClass obj )
620     {
621         Criteria criteria = new Criteria(DATABASE_NAME);
622               if (!obj.isNew())
623             criteria.add(ATTRIBUTE_CLASS_ID, obj.getAttributeClassId());
624               criteria.add(ATTRIBUTE_CLASS_NAME, obj.getName());
625               criteria.add(ATTRIBUTE_CLASS_DESC, obj.getDesc());
626               criteria.add(JAVA_CLASS_NAME, obj.getJavaClassName());
627           return criteria;
628     }
629
630     /** Build a Criteria object from the data object for this peer, skipping all binary columns */
631     public static Criteria buildSelectCriteria( AttributeClass obj )
632     {
633         Criteria criteria = new Criteria(DATABASE_NAME);
634               if (!obj.isNew())
635                     criteria.add(ATTRIBUTE_CLASS_ID, obj.getAttributeClassId());
636                           criteria.add(ATTRIBUTE_CLASS_NAME, obj.getName());
637                           criteria.add(ATTRIBUTE_CLASS_DESC, obj.getDesc());
638                           criteria.add(JAVA_CLASS_NAME, obj.getJavaClassName());
639               return criteria;
640     }
641  
642     
643         /**
644      * Retrieve a single object by pk
645      *
646      * @param pk the primary key
647      * @throws TorqueException Any exceptions caught during processing will be
648      * rethrown wrapped into a TorqueException.
649      * @throws NoRowsException Primary key was not found in database.
650      * @throws TooManyRowsException Primary key was not found in database.
651      */

652     public static AttributeClass retrieveByPK(Integer JavaDoc pk)
653         throws TorqueException, NoRowsException, TooManyRowsException
654     {
655         return retrieveByPK(SimpleKey.keyFor(pk));
656     }
657
658     /**
659      * Retrieve a single object by pk
660      *
661      * @param pk the primary key
662      * @param con the connection to use
663      * @throws TorqueException Any exceptions caught during processing will be
664      * rethrown wrapped into a TorqueException.
665      * @throws NoRowsException Primary key was not found in database.
666      * @throws TooManyRowsException Primary key was not found in database.
667      */

668     public static AttributeClass retrieveByPK(Integer JavaDoc pk, Connection JavaDoc con)
669         throws TorqueException, NoRowsException, TooManyRowsException
670     {
671         return retrieveByPK(SimpleKey.keyFor(pk), con);
672     }
673   
674     /**
675      * Retrieve a single object by pk
676      *
677      * @param pk the primary key
678      * @throws TorqueException Any exceptions caught during processing will be
679      * rethrown wrapped into a TorqueException.
680      * @throws NoRowsException Primary key was not found in database.
681      * @throws TooManyRowsException Primary key was not found in database.
682      */

683     public static AttributeClass retrieveByPK(ObjectKey pk)
684         throws TorqueException, NoRowsException, TooManyRowsException
685     {
686         Connection JavaDoc db = null;
687         AttributeClass retVal = null;
688         try
689         {
690             db = Torque.getConnection(DATABASE_NAME);
691             retVal = retrieveByPK(pk, db);
692         }
693         finally
694         {
695             Torque.closeConnection(db);
696         }
697         return(retVal);
698     }
699
700     /**
701      * Retrieve a single object by pk
702      *
703      * @param pk the primary key
704      * @param con the connection to use
705      * @throws TorqueException Any exceptions caught during processing will be
706      * rethrown wrapped into a TorqueException.
707      * @throws NoRowsException Primary key was not found in database.
708      * @throws TooManyRowsException Primary key was not found in database.
709      */

710     public static AttributeClass retrieveByPK(ObjectKey pk, Connection JavaDoc con)
711         throws TorqueException, NoRowsException, TooManyRowsException
712     {
713         Criteria criteria = buildCriteria(pk);
714         List JavaDoc v = doSelect(criteria, con);
715         if (v.size() == 0)
716         {
717             throw new NoRowsException("Failed to select a row.");
718         }
719         else if (v.size() > 1)
720         {
721             throw new TooManyRowsException("Failed to select only one row.");
722         }
723         else
724         {
725             return (AttributeClass)v.get(0);
726         }
727     }
728
729     /**
730      * Retrieve a multiple objects by pk
731      *
732      * @param pks List of primary keys
733      * @throws TorqueException Any exceptions caught during processing will be
734      * rethrown wrapped into a TorqueException.
735      */

736     public static List JavaDoc retrieveByPKs(List JavaDoc pks)
737         throws TorqueException
738     {
739         Connection JavaDoc db = null;
740         List JavaDoc retVal = null;
741         try
742         {
743            db = Torque.getConnection(DATABASE_NAME);
744            retVal = retrieveByPKs(pks, db);
745         }
746         finally
747         {
748             Torque.closeConnection(db);
749         }
750         return(retVal);
751     }
752
753     /**
754      * Retrieve a multiple objects by pk
755      *
756      * @param pks List of primary keys
757      * @param dbcon the connection to use
758      * @throws TorqueException Any exceptions caught during processing will be
759      * rethrown wrapped into a TorqueException.
760      */

761     public static List JavaDoc retrieveByPKs( List JavaDoc pks, Connection JavaDoc dbcon )
762         throws TorqueException
763     {
764         List JavaDoc objs = null;
765         if (pks == null || pks.size() == 0)
766         {
767             objs = new LinkedList JavaDoc();
768         }
769         else
770         {
771             Criteria criteria = new Criteria();
772               criteria.addIn( ATTRIBUTE_CLASS_ID, pks );
773           objs = doSelect(criteria, dbcon);
774         }
775         return objs;
776     }
777
778  
779
780
781
782         
783   
784   
785     
786   
787       /**
788      * Returns the TableMap related to this peer. This method is not
789      * needed for general use but a specific application could have a need.
790      *
791      * @throws TorqueException Any exceptions caught during processing will be
792      * rethrown wrapped into a TorqueException.
793      */

794     protected static TableMap getTableMap()
795         throws TorqueException
796     {
797         return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME);
798     }
799    
800     private static void setDbName(Criteria crit)
801     {
802         // Set the correct dbName if it has not been overridden
803
// crit.getDbName will return the same object if not set to
804
// another value so == check is okay and faster
805
if (crit.getDbName() == Torque.getDefaultDB())
806         {
807             crit.setDbName(DATABASE_NAME);
808         }
809     }
810 }
811
Popular Tags