View Javadoc

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