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.Iterator;
7   import java.util.LinkedList;
8   import java.util.List;
9   
10  import olr.om.map.ModelStatementMapBuilder;
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.ObjectKey;
19  import org.apache.torque.om.SimpleKey;
20  import org.apache.torque.util.BasePeer;
21  import org.apache.torque.util.Criteria;
22  
23  import com.workingdogs.village.DataSetException;
24  import com.workingdogs.village.QueryDataSet;
25  import com.workingdogs.village.Record;
26  
27  
28    
29    
30    
31  /***
32   * This class was autogenerated by Torque on:
33   *
34   * [Tue Jul 13 14:47:47 CEST 2004]
35   *
36   */
37  public abstract class BaseModelStatementPeer
38      extends BasePeer
39  {
40  
41      /*** the default database name for this class */
42      public static final String DATABASE_NAME = "default";
43  
44       /*** the table name for this class */
45      public static final String TABLE_NAME = "model_statement";
46  
47      /***
48       * @return the map builder for this peer
49       * @throws TorqueException Any exceptions caught during processing will be
50       *         rethrown wrapped into a TorqueException.
51       */
52      public static MapBuilder getMapBuilder()
53          throws TorqueException
54      {
55          return getMapBuilder(ModelStatementMapBuilder.CLASS_NAME);
56      }
57  
58        /*** the column name for the MODEL_ID field */
59      public static final String MODEL_ID;
60        /*** the column name for the STATEMENT_ID field */
61      public static final String STATEMENT_ID;
62        /*** the column name for the USR field */
63      public static final String USR;
64        /*** the column name for the MODIFIED field */
65      public static final String MODIFIED;
66    
67      static
68      {
69            MODEL_ID = "model_statement.MODEL_ID";
70            STATEMENT_ID = "model_statement.STATEMENT_ID";
71            USR = "model_statement.USR";
72            MODIFIED = "model_statement.MODIFIED";
73            if (Torque.isInit())
74          {
75              try
76              {
77                  getMapBuilder(ModelStatementMapBuilder.CLASS_NAME);
78              }
79              catch (Exception e)
80              {
81                  log.error("Could not initialize Peer", e);
82              }
83          }
84          else
85          {
86              Torque.registerMapBuilder(ModelStatementMapBuilder.CLASS_NAME);
87          }
88      }
89   
90      /*** number of columns for this peer */
91      public static final int numColumns =  4;
92  
93      /*** A class that can be returned by this peer. */
94      protected static final String CLASSNAME_DEFAULT =
95          "olr.om.ModelStatement";
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 BaseModelStatementPeer
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                           
202         // Set the correct dbName if it has not been overridden
203         // criteria.getDbName will return the same object if not set to
204         // another value so == check is okay and faster
205         if (criteria.getDbName() == Torque.getDefaultDB())
206         {
207             criteria.setDbName(DATABASE_NAME);
208         }
209         if (con == null)
210         {
211             return BasePeer.doInsert(criteria);
212         }
213         else
214         {
215             return BasePeer.doInsert(criteria, con);
216         }
217     }
218 
219     /***
220      * Add all the columns needed to create a new object.
221      *
222      * @param criteria object containing the columns to add.
223      * @throws TorqueException Any exceptions caught during processing will be
224      *         rethrown wrapped into a TorqueException.
225      */
226     public static void addSelectColumns(Criteria criteria)
227             throws TorqueException
228     {
229           criteria.addSelectColumn(MODEL_ID);
230           criteria.addSelectColumn(STATEMENT_ID);
231           criteria.addSelectColumn(USR);
232           criteria.addSelectColumn(MODIFIED);
233       }
234 
235     /***
236      * Create a new object of type cls from a resultset row starting
237      * from a specified offset.  This is done so that you can select
238      * other rows than just those needed for this object.  You may
239      * for example want to create two objects from the same row.
240      *
241      * @throws TorqueException Any exceptions caught during processing will be
242      *         rethrown wrapped into a TorqueException.
243      */
244     public static ModelStatement row2Object(Record row,
245                                              int offset,
246                                              Class cls)
247         throws TorqueException
248     {
249         try
250         {
251             ModelStatement obj = (ModelStatement) cls.newInstance();
252             ModelStatementPeer.populateObject(row, offset, obj);
253                   obj.setModified(false);
254               obj.setNew(false);
255 
256             return obj;
257         }
258         catch (InstantiationException e)
259         {
260             throw new TorqueException(e);
261         }
262         catch (IllegalAccessException e)
263         {
264             throw new TorqueException(e);
265         }
266     }
267 
268     /***
269      * Populates an object from a resultset row starting
270      * from a specified offset.  This is done so that you can select
271      * other rows than just those needed for this object.  You may
272      * for example want to create two objects from the same row.
273      *
274      * @throws TorqueException Any exceptions caught during processing will be
275      *         rethrown wrapped into a TorqueException.
276      */
277     public static void populateObject(Record row,
278                                       int offset,
279                                       ModelStatement obj)
280         throws TorqueException
281     {
282         try
283         {
284                 obj.setModelId(row.getValue(offset + 0).asInt());
285                   obj.setStatementId(row.getValue(offset + 1).asInt());
286                   obj.setUsr(row.getValue(offset + 2).asInt());
287                   obj.setModified(row.getValue(offset + 3).asUtilDate());
288               }
289         catch (DataSetException e)
290         {
291             throw new TorqueException(e);
292         }
293     }
294 
295     /***
296      * Method to do selects.
297      *
298      * @param criteria object used to create the SELECT statement.
299      * @return List of selected Objects
300      * @throws TorqueException Any exceptions caught during processing will be
301      *         rethrown wrapped into a TorqueException.
302      */
303     public static List doSelect(Criteria criteria) throws TorqueException
304     {
305         return populateObjects(doSelectVillageRecords(criteria));
306     }
307 
308     /***
309      * Method to do selects within a transaction.
310      *
311      * @param criteria object used to create the SELECT statement.
312      * @param con the connection to use
313      * @return List of selected Objects
314      * @throws TorqueException Any exceptions caught during processing will be
315      *         rethrown wrapped into a TorqueException.
316      */
317     public static List doSelect(Criteria criteria, Connection con)
318         throws TorqueException
319     {
320         return populateObjects(doSelectVillageRecords(criteria, con));
321     }
322 
323     /***
324      * Grabs the raw Village records to be formed into objects.
325      * This method handles connections internally.  The Record objects
326      * returned by this method should be considered readonly.  Do not
327      * alter the data and call save(), your results may vary, but are
328      * certainly likely to result in hard to track MT bugs.
329      *
330      * @throws TorqueException Any exceptions caught during processing will be
331      *         rethrown wrapped into a TorqueException.
332      */
333     public static List doSelectVillageRecords(Criteria criteria)
334         throws TorqueException
335     {
336         return BaseModelStatementPeer
337             .doSelectVillageRecords(criteria, (Connection) null);
338     }
339 
340     /***
341      * Grabs the raw Village records to be formed into objects.
342      * This method should be used for transactions
343      *
344      * @param con the connection to use
345      * @throws TorqueException Any exceptions caught during processing will be
346      *         rethrown wrapped into a TorqueException.
347      */
348     public static List doSelectVillageRecords(Criteria criteria, Connection con)
349         throws TorqueException
350     {
351         if (criteria.getSelectColumns().size() == 0)
352         {
353             addSelectColumns(criteria);
354         }
355 
356                           
357         // Set the correct dbName if it has not been overridden
358         // criteria.getDbName will return the same object if not set to
359         // another value so == check is okay and faster
360         if (criteria.getDbName() == Torque.getDefaultDB())
361         {
362             criteria.setDbName(DATABASE_NAME);
363         }
364         // BasePeer returns a List of Value (Village) arrays.  The array
365         // order follows the order columns were placed in the Select clause.
366         if (con == null)
367         {
368             return BasePeer.doSelect(criteria);
369         }
370         else
371         {
372             return BasePeer.doSelect(criteria, con);
373         }
374     }
375 
376     /***
377      * The returned List will contain objects of the default type or
378      * objects that inherit from the default.
379      *
380      * @throws TorqueException Any exceptions caught during processing will be
381      *         rethrown wrapped into a TorqueException.
382      */
383     public static List populateObjects(List records)
384         throws TorqueException
385     {
386         List results = new ArrayList(records.size());
387 
388         // populate the object(s)
389         for (int i = 0; i < records.size(); i++)
390         {
391             Record row = (Record) records.get(i);
392               results.add(ModelStatementPeer.row2Object(row, 1,
393                 ModelStatementPeer.getOMClass()));
394           }
395         return results;
396     }
397  
398 
399     /***
400      * The class that the Peer will make instances of.
401      * If the BO is abstract then you must implement this method
402      * in the BO.
403      *
404      * @throws TorqueException Any exceptions caught during processing will be
405      *         rethrown wrapped into a TorqueException.
406      */
407     public static Class getOMClass()
408         throws TorqueException
409     {
410         return CLASS_DEFAULT;
411     }
412 
413     /***
414      * Method to do updates.
415      *
416      * @param criteria object containing data that is used to create the UPDATE
417      *        statement.
418      * @throws TorqueException Any exceptions caught during processing will be
419      *         rethrown wrapped into a TorqueException.
420      */
421     public static void doUpdate(Criteria criteria) throws TorqueException
422     {
423          BaseModelStatementPeer
424             .doUpdate(criteria, (Connection) null);
425     }
426 
427     /***
428      * Method to do updates.  This method is to be used during a transaction,
429      * otherwise use the doUpdate(Criteria) method.  It will take care of
430      * the connection details internally.
431      *
432      * @param criteria object containing data that is used to create the UPDATE
433      *        statement.
434      * @param con the connection to use
435      * @throws TorqueException Any exceptions caught during processing will be
436      *         rethrown wrapped into a TorqueException.
437      */
438     public static void doUpdate(Criteria criteria, Connection con)
439         throws TorqueException
440     {
441         Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
442                    selectCriteria.put(MODEL_ID, criteria.remove(MODEL_ID));
443                        selectCriteria.put(STATEMENT_ID, criteria.remove(STATEMENT_ID));
444                           
445         // Set the correct dbName if it has not been overridden
446         // criteria.getDbName will return the same object if not set to
447         // another value so == check is okay and faster
448         if (criteria.getDbName() == Torque.getDefaultDB())
449         {
450             criteria.setDbName(DATABASE_NAME);
451         }
452         if (con == null)
453         {
454             BasePeer.doUpdate(selectCriteria, criteria);
455         }
456         else
457         {
458             BasePeer.doUpdate(selectCriteria, criteria, con);
459         }
460     }
461 
462     /***
463      * Method to do deletes.
464      *
465      * @param criteria object containing data that is used DELETE from database.
466      * @throws TorqueException Any exceptions caught during processing will be
467      *         rethrown wrapped into a TorqueException.
468      */
469      public static void doDelete(Criteria criteria) throws TorqueException
470      {
471          BaseModelStatementPeer
472             .doDelete(criteria, (Connection) null);
473      }
474 
475     /***
476      * Method to do deletes.  This method is to be used during a transaction,
477      * otherwise use the doDelete(Criteria) method.  It will take care of
478      * the connection details internally.
479      *
480      * @param criteria object containing data that is used DELETE from database.
481      * @param con the connection to use
482      * @throws TorqueException Any exceptions caught during processing will be
483      *         rethrown wrapped into a TorqueException.
484      */
485      public static void doDelete(Criteria criteria, Connection con)
486         throws TorqueException
487      {
488                           
489         // Set the correct dbName if it has not been overridden
490         // criteria.getDbName will return the same object if not set to
491         // another value so == check is okay and faster
492         if (criteria.getDbName() == Torque.getDefaultDB())
493         {
494             criteria.setDbName(DATABASE_NAME);
495         }
496         if (con == null)
497         {
498             BasePeer.doDelete(criteria);
499         }
500         else
501         {
502             BasePeer.doDelete(criteria, con);
503         }
504      }
505 
506     /***
507      * Method to do selects
508      *
509      * @throws TorqueException Any exceptions caught during processing will be
510      *         rethrown wrapped into a TorqueException.
511      */
512     public static List doSelect(ModelStatement obj) throws TorqueException
513     {
514         return doSelect(buildCriteria(obj));
515     }
516 
517     /***
518      * Method to do inserts
519      *
520      * @throws TorqueException Any exceptions caught during processing will be
521      *         rethrown wrapped into a TorqueException.
522      */
523     public static void doInsert(ModelStatement obj) throws TorqueException
524     {
525           doInsert(buildCriteria(obj));
526           obj.setNew(false);
527         obj.setModified(false);
528     }
529 
530     /***
531      * @param obj the data object to update in the database.
532      * @throws TorqueException Any exceptions caught during processing will be
533      *         rethrown wrapped into a TorqueException.
534      */
535     public static void doUpdate(ModelStatement obj) throws TorqueException
536     {
537         doUpdate(buildCriteria(obj));
538         obj.setModified(false);
539     }
540 
541     /***
542      * @param obj the data object to delete in the database.
543      * @throws TorqueException Any exceptions caught during processing will be
544      *         rethrown wrapped into a TorqueException.
545      */
546     public static void doDelete(ModelStatement obj) throws TorqueException
547     {
548         doDelete(buildCriteria(obj));
549     }
550 
551     /***
552      * Method to do inserts.  This method is to be used during a transaction,
553      * otherwise use the doInsert(ModelStatement) method.  It will take
554      * care of the connection details internally.
555      *
556      * @param obj the data object to insert into the database.
557      * @param con the connection to use
558      * @throws TorqueException Any exceptions caught during processing will be
559      *         rethrown wrapped into a TorqueException.
560      */
561     public static void doInsert(ModelStatement obj, Connection con)
562         throws TorqueException
563     {
564           doInsert(buildCriteria(obj), con);
565           obj.setNew(false);
566         obj.setModified(false);
567     }
568 
569     /***
570      * Method to do update.  This method is to be used during a transaction,
571      * otherwise use the doUpdate(ModelStatement) method.  It will take
572      * care of the connection details internally.
573      *
574      * @param obj the data object to update in the database.
575      * @param con the connection to use
576      * @throws TorqueException Any exceptions caught during processing will be
577      *         rethrown wrapped into a TorqueException.
578      */
579     public static void doUpdate(ModelStatement obj, Connection con)
580         throws TorqueException
581     {
582         doUpdate(buildCriteria(obj), con);
583         obj.setModified(false);
584     }
585 
586     /***
587      * Method to delete.  This method is to be used during a transaction,
588      * otherwise use the doDelete(ModelStatement) method.  It will take
589      * care of the connection details internally.
590      *
591      * @param obj the data object to delete in the database.
592      * @param con the connection to use
593      * @throws TorqueException Any exceptions caught during processing will be
594      *         rethrown wrapped into a TorqueException.
595      */
596     public static void doDelete(ModelStatement obj, Connection con)
597         throws TorqueException
598     {
599         doDelete(buildCriteria(obj), con);
600     }
601 
602     /***
603      * Method to do deletes.
604      *
605      * @param pk ObjectKey that is used DELETE from database.
606      * @throws TorqueException Any exceptions caught during processing will be
607      *         rethrown wrapped into a TorqueException.
608      */
609     public static void doDelete(ObjectKey pk) throws TorqueException
610     {
611         BaseModelStatementPeer
612            .doDelete(pk, (Connection) null);
613     }
614 
615     /***
616      * Method to delete.  This method is to be used during a transaction,
617      * otherwise use the doDelete(ObjectKey) method.  It will take
618      * care of the connection details internally.
619      *
620      * @param pk the primary key for the object to delete in the database.
621      * @param con the connection to use
622      * @throws TorqueException Any exceptions caught during processing will be
623      *         rethrown wrapped into a TorqueException.
624      */
625     public static void doDelete(ObjectKey pk, Connection con)
626         throws TorqueException
627     {
628         doDelete(buildCriteria(pk), con);
629     }
630 
631     /*** Build a Criteria object from an ObjectKey */
632     public static Criteria buildCriteria( ObjectKey pk )
633     {
634         Criteria criteria = new Criteria();
635           SimpleKey[] keys = (SimpleKey[])pk.getValue();
636                     criteria.add(MODEL_ID, keys[0]);
637                       criteria.add(STATEMENT_ID, keys[1]);
638                     return criteria;
639      }
640 
641     /*** Build a Criteria object from the data object for this peer */
642     public static Criteria buildCriteria( ModelStatement obj )
643     {
644         Criteria criteria = new Criteria(DATABASE_NAME);
645                   criteria.add(MODEL_ID, obj.getModelId());
646                   criteria.add(STATEMENT_ID, obj.getStatementId());
647                   criteria.add(USR, obj.getUsr());
648                   criteria.add(MODIFIED, obj.getModified());
649           return criteria;
650     }
651  
652     
653     
654     /***
655      * Retrieve a single object by pk
656      *
657      * @param pk the primary key
658      * @throws TorqueException Any exceptions caught during processing will be
659      *         rethrown wrapped into a TorqueException.
660      * @throws NoRowsException Primary key was not found in database.
661      * @throws TooManyRowsException Primary key was not found in database.
662      */
663     public static ModelStatement retrieveByPK(ObjectKey pk)
664         throws TorqueException, NoRowsException, TooManyRowsException
665     {
666         Connection db = null;
667         ModelStatement retVal = null;
668         try
669         {
670             db = Torque.getConnection(DATABASE_NAME);
671             retVal = retrieveByPK(pk, db);
672         }
673         finally
674         {
675             Torque.closeConnection(db);
676         }
677         return(retVal);
678     }
679 
680     /***
681      * Retrieve a single object by pk
682      *
683      * @param pk the primary key
684      * @param con the connection to use
685      * @throws TorqueException Any exceptions caught during processing will be
686      *         rethrown wrapped into a TorqueException.
687      * @throws NoRowsException Primary key was not found in database.
688      * @throws TooManyRowsException Primary key was not found in database.
689      */
690     public static ModelStatement retrieveByPK(ObjectKey pk, Connection con)
691         throws TorqueException, NoRowsException, TooManyRowsException
692     {
693         Criteria criteria = buildCriteria(pk);
694         List v = doSelect(criteria, con);
695         if (v.size() == 0)
696         {
697             throw new NoRowsException("Failed to select a row.");
698         }
699         else if (v.size() > 1)
700         {
701             throw new TooManyRowsException("Failed to select only one row.");
702         }
703         else
704         {
705             return (ModelStatement)v.get(0);
706         }
707     }
708 
709     /***
710      * Retrieve a multiple objects by pk
711      *
712      * @param pks List of primary keys
713      * @throws TorqueException Any exceptions caught during processing will be
714      *         rethrown wrapped into a TorqueException.
715      */
716     public static List retrieveByPKs(List pks)
717         throws TorqueException
718     {
719         Connection db = null;
720         List retVal = null;
721         try
722         {
723            db = Torque.getConnection(DATABASE_NAME);
724            retVal = retrieveByPKs(pks, db);
725         }
726         finally
727         {
728             Torque.closeConnection(db);
729         }
730         return(retVal);
731     }
732 
733     /***
734      * Retrieve a multiple objects by pk
735      *
736      * @param pks List of primary keys
737      * @param dbcon the connection to use
738      * @throws TorqueException Any exceptions caught during processing will be
739      *         rethrown wrapped into a TorqueException.
740      */
741     public static List retrieveByPKs( List pks, Connection dbcon )
742         throws TorqueException
743     {
744         List objs = null;
745         if (pks == null || pks.size() == 0)
746         {
747             objs = new LinkedList();
748         }
749         else
750         {
751             Criteria criteria = new Criteria();
752               Iterator iter = pks.iterator();
753             while (iter.hasNext())
754             {
755                 ObjectKey pk = (ObjectKey)iter.next();
756                 SimpleKey[] keys = (SimpleKey[])pk.getValue();
757                             Criteria.Criterion c0 = criteria.getNewCriterion(
758                         MODEL_ID, keys[0], Criteria.EQUAL);
759                                     Criteria.Criterion c1 = criteria.getNewCriterion(
760                         STATEMENT_ID, keys[1], Criteria.EQUAL);
761                                     c0.and(c1);
762                           criteria.or(c0);
763             }
764           objs = doSelect(criteria, dbcon);
765         }
766         return objs;
767     }
768 
769  
770     /***
771      * retrieve object using using pk values.
772      *
773        * @param model_id int
774        * @param statement_id int
775        */
776     public static ModelStatement retrieveByPK(
777        int model_id
778           , int statement_id
779               ) throws TorqueException
780     {
781         Connection db = null;
782         ModelStatement retVal = null;
783         try
784         {
785            db = Torque.getConnection(DATABASE_NAME);
786            retVal = retrieveByPK(
787          model_id
788           , statement_id
789                      , db);
790         }
791         finally
792         {
793             Torque.closeConnection(db);
794         }
795         return(retVal);
796     }
797 
798       /***
799      * retrieve object using using pk values.
800      *
801        * @param model_id int
802        * @param statement_id int
803        * @param Connection con
804      */
805     public static ModelStatement retrieveByPK(
806        int model_id
807           , int statement_id
808              ,Connection con) throws TorqueException
809     {
810 
811         Criteria criteria = new Criteria(5);
812           criteria.add(MODEL_ID, model_id);
813           criteria.add(STATEMENT_ID, statement_id);
814           List v = doSelect(criteria, con);
815         if (v.size() != 1)
816         {
817             throw new TorqueException("Failed to select one and only one row.");
818         }
819         else
820         {
821             return (ModelStatement) v.get(0);
822         }
823     }
824 
825 
826 
827               
828                                               
829                 
830                 
831 
832     /***
833      * selects a collection of ModelStatement objects pre-filled with their
834      * RdfUser objects.
835      *
836      * This method is protected by default in order to keep the public
837      * api reasonable.  You can provide public methods for those you
838      * actually need in ModelStatementPeer.
839      *
840      * @throws TorqueException Any exceptions caught during processing will be
841      *         rethrown wrapped into a TorqueException.
842      */
843     protected static List doSelectJoinRdfUser(Criteria c)
844         throws TorqueException
845     {
846         // Set the correct dbName if it has not been overridden
847         // c.getDbName will return the same object if not set to
848         // another value so == check is okay and faster
849         if (c.getDbName() == Torque.getDefaultDB())
850         {
851             c.setDbName(DATABASE_NAME);
852         }
853 
854         ModelStatementPeer.addSelectColumns(c);
855         int offset = numColumns + 1;
856         RdfUserPeer.addSelectColumns(c);
857 
858 
859                         c.addJoin(ModelStatementPeer.USR,
860             RdfUserPeer.ID);
861         
862 
863                                                                                 
864         List rows = BasePeer.doSelect(c);
865         List results = new ArrayList();
866 
867         for (int i = 0; i < rows.size(); i++)
868         {
869             Record row = (Record) rows.get(i);
870 
871                             Class omClass = ModelStatementPeer.getOMClass();
872                     ModelStatement obj1 = (ModelStatement) ModelStatementPeer
873                 .row2Object(row, 1, omClass);
874                      omClass = RdfUserPeer.getOMClass();
875                     RdfUser obj2 = (RdfUser)RdfUserPeer
876                 .row2Object(row, offset, omClass);
877 
878             boolean newObject = true;
879             for (int j = 0; j < results.size(); j++)
880             {
881                 ModelStatement temp_obj1 = (ModelStatement)results.get(j);
882                 RdfUser temp_obj2 = (RdfUser)temp_obj1.getRdfUser();
883                 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
884                 {
885                     newObject = false;
886                     temp_obj2.addModelStatement(obj1);
887                     break;
888                 }
889             }
890             if (newObject)
891             {
892                 obj2.initModelStatements();
893                 obj2.addModelStatement(obj1);
894             }
895             results.add(obj1);
896         }
897         return results;
898     }
899                                                             
900                 
901                 
902 
903     /***
904      * selects a collection of ModelStatement objects pre-filled with their
905      * Model objects.
906      *
907      * This method is protected by default in order to keep the public
908      * api reasonable.  You can provide public methods for those you
909      * actually need in ModelStatementPeer.
910      *
911      * @throws TorqueException Any exceptions caught during processing will be
912      *         rethrown wrapped into a TorqueException.
913      */
914     protected static List doSelectJoinModel(Criteria c)
915         throws TorqueException
916     {
917         // Set the correct dbName if it has not been overridden
918         // c.getDbName will return the same object if not set to
919         // another value so == check is okay and faster
920         if (c.getDbName() == Torque.getDefaultDB())
921         {
922             c.setDbName(DATABASE_NAME);
923         }
924 
925         ModelStatementPeer.addSelectColumns(c);
926         int offset = numColumns + 1;
927         ModelPeer.addSelectColumns(c);
928 
929 
930                         c.addJoin(ModelStatementPeer.MODEL_ID,
931             ModelPeer.ID);
932         
933 
934                                                                                 
935         List rows = BasePeer.doSelect(c);
936         List results = new ArrayList();
937 
938         for (int i = 0; i < rows.size(); i++)
939         {
940             Record row = (Record) rows.get(i);
941 
942                             Class omClass = ModelStatementPeer.getOMClass();
943                     ModelStatement obj1 = (ModelStatement) ModelStatementPeer
944                 .row2Object(row, 1, omClass);
945                      omClass = ModelPeer.getOMClass();
946                     Model obj2 = (Model)ModelPeer
947                 .row2Object(row, offset, omClass);
948 
949             boolean newObject = true;
950             for (int j = 0; j < results.size(); j++)
951             {
952                 ModelStatement temp_obj1 = (ModelStatement)results.get(j);
953                 Model temp_obj2 = (Model)temp_obj1.getModel();
954                 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
955                 {
956                     newObject = false;
957                     temp_obj2.addModelStatement(obj1);
958                     break;
959                 }
960             }
961             if (newObject)
962             {
963                 obj2.initModelStatements();
964                 obj2.addModelStatement(obj1);
965             }
966             results.add(obj1);
967         }
968         return results;
969     }
970                                                             
971                 
972                 
973 
974     /***
975      * selects a collection of ModelStatement objects pre-filled with their
976      * RdfStatement objects.
977      *
978      * This method is protected by default in order to keep the public
979      * api reasonable.  You can provide public methods for those you
980      * actually need in ModelStatementPeer.
981      *
982      * @throws TorqueException Any exceptions caught during processing will be
983      *         rethrown wrapped into a TorqueException.
984      */
985     protected static List doSelectJoinRdfStatement(Criteria c)
986         throws TorqueException
987     {
988         // Set the correct dbName if it has not been overridden
989         // c.getDbName will return the same object if not set to
990         // another value so == check is okay and faster
991         if (c.getDbName() == Torque.getDefaultDB())
992         {
993             c.setDbName(DATABASE_NAME);
994         }
995 
996         ModelStatementPeer.addSelectColumns(c);
997         int offset = numColumns + 1;
998         RdfStatementPeer.addSelectColumns(c);
999 
1000 
1001                         c.addJoin(ModelStatementPeer.STATEMENT_ID,
1002             RdfStatementPeer.ID);
1003         
1004 
1005                                                                                 
1006         List rows = BasePeer.doSelect(c);
1007         List results = new ArrayList();
1008 
1009         for (int i = 0; i < rows.size(); i++)
1010         {
1011             Record row = (Record) rows.get(i);
1012 
1013                             Class omClass = ModelStatementPeer.getOMClass();
1014                     ModelStatement obj1 = (ModelStatement) ModelStatementPeer
1015                 .row2Object(row, 1, omClass);
1016                      omClass = RdfStatementPeer.getOMClass();
1017                     RdfStatement obj2 = (RdfStatement)RdfStatementPeer
1018                 .row2Object(row, offset, omClass);
1019 
1020             boolean newObject = true;
1021             for (int j = 0; j < results.size(); j++)
1022             {
1023                 ModelStatement temp_obj1 = (ModelStatement)results.get(j);
1024                 RdfStatement temp_obj2 = (RdfStatement)temp_obj1.getRdfStatement();
1025                 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1026                 {
1027                     newObject = false;
1028                     temp_obj2.addModelStatement(obj1);
1029                     break;
1030                 }
1031             }
1032             if (newObject)
1033             {
1034                 obj2.initModelStatements();
1035                 obj2.addModelStatement(obj1);
1036             }
1037             results.add(obj1);
1038         }
1039         return results;
1040     }
1041                     
1042   
1043                                     
1044           
1045         
1046                                   
1047                 
1048 
1049     /***
1050      * selects a collection of ModelStatement objects pre-filled with
1051      * all related objects.
1052      *
1053      * This method is protected by default in order to keep the public
1054      * api reasonable.  You can provide public methods for those you
1055      * actually need in ModelStatementPeer.
1056      *
1057      * @throws TorqueException Any exceptions caught during processing will be
1058      *         rethrown wrapped into a TorqueException.
1059      */
1060     protected static List doSelectJoinAllExceptRdfUser(Criteria c)
1061         throws TorqueException
1062     {
1063         // Set the correct dbName if it has not been overridden
1064         // c.getDbName will return the same object if not set to another value
1065         // so == check is okay and faster
1066         if (c.getDbName() == Torque.getDefaultDB())
1067         {
1068             c.setDbName(DATABASE_NAME);
1069         }
1070 
1071         addSelectColumns(c);
1072         int offset2 = numColumns + 1;
1073                                     
1074                                                   
1075                     ModelPeer.addSelectColumns(c);
1076         int offset3 = offset2 + ModelPeer.numColumns;
1077                                                                 
1078                     RdfStatementPeer.addSelectColumns(c);
1079         int offset4 = offset3 + RdfStatementPeer.numColumns;
1080                                                                                                                             
1081         List rows = BasePeer.doSelect(c);
1082         List results = new ArrayList();
1083 
1084         for (int i = 0; i < rows.size(); i++)
1085         {
1086             Record row = (Record)rows.get(i);
1087 
1088                             Class omClass = ModelStatementPeer.getOMClass();
1089                     ModelStatement obj1 = (ModelStatement)ModelStatementPeer
1090                 .row2Object(row, 1, omClass);
1091                                                 
1092                                                                   
1093                                                         
1094                             
1095               
1096                            omClass = ModelPeer.getOMClass();
1097                           Model obj2 = (Model)ModelPeer
1098                 .row2Object( row, offset2, omClass);
1099 
1100                boolean  newObject = true;
1101             for (int j = 0; j < results.size(); j++)
1102             {
1103                 ModelStatement temp_obj1 = (ModelStatement)results.get(j);
1104                 Model temp_obj2 = (Model)temp_obj1.getModel();
1105                 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1106                 {
1107                     newObject = false;
1108                     temp_obj2.addModelStatement(obj1);
1109                     break;
1110                 }
1111             }
1112             if (newObject)
1113             {
1114                 obj2.initModelStatements();
1115                 obj2.addModelStatement(obj1);
1116             }
1117                                                                     
1118                                                         
1119                             
1120               
1121                            omClass = RdfStatementPeer.getOMClass();
1122                           RdfStatement obj3 = (RdfStatement)RdfStatementPeer
1123                 .row2Object( row, offset3, omClass);
1124 
1125                newObject = true;
1126             for (int j = 0; j < results.size(); j++)
1127             {
1128                 ModelStatement temp_obj1 = (ModelStatement)results.get(j);
1129                 RdfStatement temp_obj3 = (RdfStatement)temp_obj1.getRdfStatement();
1130                 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1131                 {
1132                     newObject = false;
1133                     temp_obj3.addModelStatement(obj1);
1134                     break;
1135                 }
1136             }
1137             if (newObject)
1138             {
1139                 obj3.initModelStatements();
1140                 obj3.addModelStatement(obj1);
1141             }
1142                                                 results.add(obj1);
1143         }
1144         return results;
1145     }
1146         
1147         
1148                                   
1149                 
1150 
1151     /***
1152      * selects a collection of ModelStatement objects pre-filled with
1153      * all related objects.
1154      *
1155      * This method is protected by default in order to keep the public
1156      * api reasonable.  You can provide public methods for those you
1157      * actually need in ModelStatementPeer.
1158      *
1159      * @throws TorqueException Any exceptions caught during processing will be
1160      *         rethrown wrapped into a TorqueException.
1161      */
1162     protected static List doSelectJoinAllExceptModel(Criteria c)
1163         throws TorqueException
1164     {
1165         // Set the correct dbName if it has not been overridden
1166         // c.getDbName will return the same object if not set to another value
1167         // so == check is okay and faster
1168         if (c.getDbName() == Torque.getDefaultDB())
1169         {
1170             c.setDbName(DATABASE_NAME);
1171         }
1172 
1173         addSelectColumns(c);
1174         int offset2 = numColumns + 1;
1175                                     
1176                     RdfUserPeer.addSelectColumns(c);
1177         int offset3 = offset2 + RdfUserPeer.numColumns;
1178                                                                 
1179                                                   
1180                     RdfStatementPeer.addSelectColumns(c);
1181         int offset4 = offset3 + RdfStatementPeer.numColumns;
1182                                                                                                                             
1183         List rows = BasePeer.doSelect(c);
1184         List results = new ArrayList();
1185 
1186         for (int i = 0; i < rows.size(); i++)
1187         {
1188             Record row = (Record)rows.get(i);
1189 
1190                             Class omClass = ModelStatementPeer.getOMClass();
1191                     ModelStatement obj1 = (ModelStatement)ModelStatementPeer
1192                 .row2Object(row, 1, omClass);
1193                                                 
1194                                                         
1195                             
1196               
1197                            omClass = RdfUserPeer.getOMClass();
1198                           RdfUser obj2 = (RdfUser)RdfUserPeer
1199                 .row2Object( row, offset2, omClass);
1200 
1201                boolean  newObject = true;
1202             for (int j = 0; j < results.size(); j++)
1203             {
1204                 ModelStatement temp_obj1 = (ModelStatement)results.get(j);
1205                 RdfUser temp_obj2 = (RdfUser)temp_obj1.getRdfUser();
1206                 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1207                 {
1208                     newObject = false;
1209                     temp_obj2.addModelStatement(obj1);
1210                     break;
1211                 }
1212             }
1213             if (newObject)
1214             {
1215                 obj2.initModelStatements();
1216                 obj2.addModelStatement(obj1);
1217             }
1218                                                                     
1219                                                                   
1220                                                         
1221                             
1222               
1223                            omClass = RdfStatementPeer.getOMClass();
1224                           RdfStatement obj3 = (RdfStatement)RdfStatementPeer
1225                 .row2Object( row, offset3, omClass);
1226 
1227                newObject = true;
1228             for (int j = 0; j < results.size(); j++)
1229             {
1230                 ModelStatement temp_obj1 = (ModelStatement)results.get(j);
1231                 RdfStatement temp_obj3 = (RdfStatement)temp_obj1.getRdfStatement();
1232                 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1233                 {
1234                     newObject = false;
1235                     temp_obj3.addModelStatement(obj1);
1236                     break;
1237                 }
1238             }
1239             if (newObject)
1240             {
1241                 obj3.initModelStatements();
1242                 obj3.addModelStatement(obj1);
1243             }
1244                                                 results.add(obj1);
1245         }
1246         return results;
1247     }
1248         
1249         
1250                                   
1251                 
1252 
1253     /***
1254      * selects a collection of ModelStatement objects pre-filled with
1255      * all related objects.
1256      *
1257      * This method is protected by default in order to keep the public
1258      * api reasonable.  You can provide public methods for those you
1259      * actually need in ModelStatementPeer.
1260      *
1261      * @throws TorqueException Any exceptions caught during processing will be
1262      *         rethrown wrapped into a TorqueException.
1263      */
1264     protected static List doSelectJoinAllExceptRdfStatement(Criteria c)
1265         throws TorqueException
1266     {
1267         // Set the correct dbName if it has not been overridden
1268         // c.getDbName will return the same object if not set to another value
1269         // so == check is okay and faster
1270         if (c.getDbName() == Torque.getDefaultDB())
1271         {
1272             c.setDbName(DATABASE_NAME);
1273         }
1274 
1275         addSelectColumns(c);
1276         int offset2 = numColumns + 1;
1277                                     
1278                     RdfUserPeer.addSelectColumns(c);
1279         int offset3 = offset2 + RdfUserPeer.numColumns;
1280                                                                 
1281                     ModelPeer.addSelectColumns(c);
1282         int offset4 = offset3 + ModelPeer.numColumns;
1283                                                                 
1284                                                                                                               
1285         List rows = BasePeer.doSelect(c);
1286         List results = new ArrayList();
1287 
1288         for (int i = 0; i < rows.size(); i++)
1289         {
1290             Record row = (Record)rows.get(i);
1291 
1292                             Class omClass = ModelStatementPeer.getOMClass();
1293                     ModelStatement obj1 = (ModelStatement)ModelStatementPeer
1294                 .row2Object(row, 1, omClass);
1295                                                 
1296                                                         
1297                             
1298               
1299                            omClass = RdfUserPeer.getOMClass();
1300                           RdfUser obj2 = (RdfUser)RdfUserPeer
1301                 .row2Object( row, offset2, omClass);
1302 
1303                boolean  newObject = true;
1304             for (int j = 0; j < results.size(); j++)
1305             {
1306                 ModelStatement temp_obj1 = (ModelStatement)results.get(j);
1307                 RdfUser temp_obj2 = (RdfUser)temp_obj1.getRdfUser();
1308                 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1309                 {
1310                     newObject = false;
1311                     temp_obj2.addModelStatement(obj1);
1312                     break;
1313                 }
1314             }
1315             if (newObject)
1316             {
1317                 obj2.initModelStatements();
1318                 obj2.addModelStatement(obj1);
1319             }
1320                                                                     
1321                                                         
1322                             
1323               
1324                            omClass = ModelPeer.getOMClass();
1325                           Model obj3 = (Model)ModelPeer
1326                 .row2Object( row, offset3, omClass);
1327 
1328                newObject = true;
1329             for (int j = 0; j < results.size(); j++)
1330             {
1331                 ModelStatement temp_obj1 = (ModelStatement)results.get(j);
1332                 Model temp_obj3 = (Model)temp_obj1.getModel();
1333                 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1334                 {
1335                     newObject = false;
1336                     temp_obj3.addModelStatement(obj1);
1337                     break;
1338                 }
1339             }
1340             if (newObject)
1341             {
1342                 obj3.initModelStatements();
1343                 obj3.addModelStatement(obj1);
1344             }
1345                                                                     
1346                                               results.add(obj1);
1347         }
1348         return results;
1349     }
1350                     
1351   
1352       /***
1353      * Returns the TableMap related to this peer.  This method is not
1354      * needed for general use but a specific application could have a need.
1355      *
1356      * @throws TorqueException Any exceptions caught during processing will be
1357      *         rethrown wrapped into a TorqueException.
1358      */
1359     protected static TableMap getTableMap()
1360         throws TorqueException
1361     {
1362         return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME);
1363     }
1364    }