View Javadoc

1   package org.apache.turbine.services.security.torque.om;
2   
3   import java.math.BigDecimal;
4   import java.sql.Connection;
5   import java.sql.SQLException;
6   import java.util.ArrayList;
7   import java.util.Date;
8   import java.util.Iterator;
9   import java.util.LinkedList;
10  import java.util.List;
11  
12  import org.apache.torque.NoRowsException;
13  import org.apache.torque.TooManyRowsException;
14  import org.apache.torque.Torque;
15  import org.apache.torque.TorqueException;
16  import org.apache.torque.map.MapBuilder;
17  import org.apache.torque.map.TableMap;
18  import org.apache.torque.om.DateKey;
19  import org.apache.torque.om.NumberKey;
20  import org.apache.torque.om.StringKey;
21  import org.apache.torque.om.ObjectKey;
22  import org.apache.torque.om.SimpleKey;
23  import org.apache.torque.util.BasePeer;
24  import org.apache.torque.util.Criteria;
25  
26  import com.workingdogs.village.DataSetException;
27  import com.workingdogs.village.QueryDataSet;
28  import com.workingdogs.village.Record;
29  
30  // Local classes
31  import org.apache.turbine.services.security.torque.om.map.*;
32  
33  
34    
35    
36  /***
37   * This class was autogenerated by Torque on:
38   *
39   * [Mon Oct 03 14:24:58 CEST 2005]
40   *
41   */
42  public abstract class BaseTurbineRolePermissionPeer
43      extends BasePeer
44  {
45  
46      /*** the default database name for this class */
47      public static final String DATABASE_NAME = "default";
48  
49       /*** the table name for this class */
50      public static final String TABLE_NAME = "TURBINE_ROLE_PERMISSION";
51  
52      /***
53       * @return the map builder for this peer
54       * @throws TorqueException Any exceptions caught during processing will be
55       *         rethrown wrapped into a TorqueException.
56       */
57      public static MapBuilder getMapBuilder()
58          throws TorqueException
59      {
60          return getMapBuilder(TurbineRolePermissionMapBuilder.CLASS_NAME);
61      }
62  
63        /*** the column name for the ROLE_ID field */
64      public static final String ROLE_ID;
65        /*** the column name for the PERMISSION_ID field */
66      public static final String PERMISSION_ID;
67    
68      static
69      {
70            ROLE_ID = "TURBINE_ROLE_PERMISSION.ROLE_ID";
71            PERMISSION_ID = "TURBINE_ROLE_PERMISSION.PERMISSION_ID";
72            if (Torque.isInit())
73          {
74              try
75              {
76                  getMapBuilder(TurbineRolePermissionMapBuilder.CLASS_NAME);
77              }
78              catch (Exception e)
79              {
80                  log.error("Could not initialize Peer", e);
81              }
82          }
83          else
84          {
85              Torque.registerMapBuilder(TurbineRolePermissionMapBuilder.CLASS_NAME);
86          }
87      }
88   
89      /*** number of columns for this peer */
90      public static final int numColumns =  2;
91  
92      /*** A class that can be returned by this peer. */
93      protected static final String CLASSNAME_DEFAULT =
94          "org.apache.turbine.services.security.torque.om.TurbineRolePermission";
95  
96      /*** A class that can be returned by this peer. */
97      protected static final Class 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 initClass(String className)
106     {
107         Class c = null;
108         try
109         {
110             c = Class.forName(className);
111         }
112         catch (Throwable 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)
122             {
123                 throw (Error) 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 resultSet2Objects(java.sql.ResultSet results)
140             throws TorqueException
141     {
142         try
143         {
144             QueryDataSet qds = null;
145             List 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 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 BaseTurbineRolePermissionPeer
184             .doInsert(criteria, (Connection) 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 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(ROLE_ID);
224           criteria.addSelectColumn(PERMISSION_ID);
225       }
226 
227     /***
228      * Create a new object of type cls from a resultset row starting
229      * from a specified offset.  This is done so that you can select
230      * other rows than just those needed for this object.  You may
231      * for example want to create two objects from the same row.
232      *
233      * @throws TorqueException Any exceptions caught during processing will be
234      *         rethrown wrapped into a TorqueException.
235      */
236     public static TurbineRolePermission row2Object(Record row,
237                                              int offset,
238                                              Class cls)
239         throws TorqueException
240     {
241         try
242         {
243             TurbineRolePermission obj = (TurbineRolePermission) cls.newInstance();
244             TurbineRolePermissionPeer.populateObject(row, offset, obj);
245                   obj.setModified(false);
246               obj.setNew(false);
247 
248             return obj;
249         }
250         catch (InstantiationException e)
251         {
252             throw new TorqueException(e);
253         }
254         catch (IllegalAccessException e)
255         {
256             throw new TorqueException(e);
257         }
258     }
259 
260     /***
261      * Populates an object from a resultset row starting
262      * from a specified offset.  This is done so that you can select
263      * other rows than just those needed for this object.  You may
264      * for example want to create two objects from the same row.
265      *
266      * @throws TorqueException Any exceptions caught during processing will be
267      *         rethrown wrapped into a TorqueException.
268      */
269     public static void populateObject(Record row,
270                                       int offset,
271                                       TurbineRolePermission obj)
272         throws TorqueException
273     {
274         try
275         {
276                 obj.setRoleId(row.getValue(offset + 0).asInt());
277                   obj.setPermissionId(row.getValue(offset + 1).asInt());
278               }
279         catch (DataSetException e)
280         {
281             throw new TorqueException(e);
282         }
283     }
284 
285     /***
286      * Method to do selects.
287      *
288      * @param criteria object used to create the SELECT statement.
289      * @return List of selected Objects
290      * @throws TorqueException Any exceptions caught during processing will be
291      *         rethrown wrapped into a TorqueException.
292      */
293     public static List doSelect(Criteria criteria) throws TorqueException
294     {
295         return populateObjects(doSelectVillageRecords(criteria));
296     }
297 
298     /***
299      * Method to do selects within a transaction.
300      *
301      * @param criteria object used to create the SELECT statement.
302      * @param con the connection to use
303      * @return List of selected Objects
304      * @throws TorqueException Any exceptions caught during processing will be
305      *         rethrown wrapped into a TorqueException.
306      */
307     public static List doSelect(Criteria criteria, Connection con)
308         throws TorqueException
309     {
310         return populateObjects(doSelectVillageRecords(criteria, con));
311     }
312 
313     /***
314      * Grabs the raw Village records to be formed into objects.
315      * This method handles connections internally.  The Record objects
316      * returned by this method should be considered readonly.  Do not
317      * alter the data and call save(), your results may vary, but are
318      * certainly likely to result in hard to track MT bugs.
319      *
320      * @throws TorqueException Any exceptions caught during processing will be
321      *         rethrown wrapped into a TorqueException.
322      */
323     public static List doSelectVillageRecords(Criteria criteria)
324         throws TorqueException
325     {
326         return BaseTurbineRolePermissionPeer
327             .doSelectVillageRecords(criteria, (Connection) null);
328     }
329 
330     /***
331      * Grabs the raw Village records to be formed into objects.
332      * This method should be used for transactions
333      *
334      * @param criteria object used to create the SELECT statement.
335      * @param con the connection to use
336      * @throws TorqueException Any exceptions caught during processing will be
337      *         rethrown wrapped into a TorqueException.
338      */
339     public static List doSelectVillageRecords(Criteria criteria, Connection con)
340         throws TorqueException
341     {
342         if (criteria.getSelectColumns().size() == 0)
343         {
344             addSelectColumns(criteria);
345         }
346 
347               
348         setDbName(criteria);
349 
350         // BasePeer returns a List of Value (Village) arrays.  The array
351         // order follows the order columns were placed in the Select clause.
352         if (con == null)
353         {
354             return BasePeer.doSelect(criteria);
355         }
356         else
357         {
358             return BasePeer.doSelect(criteria, con);
359         }
360     }
361 
362     /***
363      * The returned List will contain objects of the default type or
364      * objects that inherit from the default.
365      *
366      * @throws TorqueException Any exceptions caught during processing will be
367      *         rethrown wrapped into a TorqueException.
368      */
369     public static List populateObjects(List records)
370         throws TorqueException
371     {
372         List results = new ArrayList(records.size());
373 
374         // populate the object(s)
375         for (int i = 0; i < records.size(); i++)
376         {
377             Record row = (Record) records.get(i);
378               results.add(TurbineRolePermissionPeer.row2Object(row, 1,
379                 TurbineRolePermissionPeer.getOMClass()));
380           }
381         return results;
382     }
383  
384 
385     /***
386      * The class that the Peer will make instances of.
387      * If the BO is abstract then you must implement this method
388      * in the BO.
389      *
390      * @throws TorqueException Any exceptions caught during processing will be
391      *         rethrown wrapped into a TorqueException.
392      */
393     public static Class getOMClass()
394         throws TorqueException
395     {
396         return CLASS_DEFAULT;
397     }
398 
399     /***
400      * Method to do updates.
401      *
402      * @param criteria object containing data that is used to create the UPDATE
403      *        statement.
404      * @throws TorqueException Any exceptions caught during processing will be
405      *         rethrown wrapped into a TorqueException.
406      */
407     public static void doUpdate(Criteria criteria) throws TorqueException
408     {
409          BaseTurbineRolePermissionPeer
410             .doUpdate(criteria, (Connection) null);
411     }
412 
413     /***
414      * Method to do updates.  This method is to be used during a transaction,
415      * otherwise use the doUpdate(Criteria) method.  It will take care of
416      * the connection details internally.
417      *
418      * @param criteria object containing data that is used to create the UPDATE
419      *        statement.
420      * @param con the connection to use
421      * @throws TorqueException Any exceptions caught during processing will be
422      *         rethrown wrapped into a TorqueException.
423      */
424     public static void doUpdate(Criteria criteria, Connection con)
425         throws TorqueException
426     {
427         Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
428                    selectCriteria.put(ROLE_ID, criteria.remove(ROLE_ID));
429                        selectCriteria.put(PERMISSION_ID, criteria.remove(PERMISSION_ID));
430       
431         setDbName(criteria);
432 
433         if (con == null)
434         {
435             BasePeer.doUpdate(selectCriteria, criteria);
436         }
437         else
438         {
439             BasePeer.doUpdate(selectCriteria, criteria, con);
440         }
441     }
442 
443     /***
444      * Method to do deletes.
445      *
446      * @param criteria object containing data that is used DELETE from database.
447      * @throws TorqueException Any exceptions caught during processing will be
448      *         rethrown wrapped into a TorqueException.
449      */
450      public static void doDelete(Criteria criteria) throws TorqueException
451      {
452          TurbineRolePermissionPeer
453             .doDelete(criteria, (Connection) null);
454      }
455 
456     /***
457      * Method to do deletes.  This method is to be used during a transaction,
458      * otherwise use the doDelete(Criteria) method.  It will take care of
459      * the connection details internally.
460      *
461      * @param criteria object containing data that is used DELETE from database.
462      * @param con the connection to use
463      * @throws TorqueException Any exceptions caught during processing will be
464      *         rethrown wrapped into a TorqueException.
465      */
466      public static void doDelete(Criteria criteria, Connection con)
467         throws TorqueException
468      {
469               
470         setDbName(criteria);
471 
472         if (con == null)
473         {
474             BasePeer.doDelete(criteria);
475         }
476         else
477         {
478             BasePeer.doDelete(criteria, con);
479         }
480      }
481 
482     /***
483      * Method to do selects
484      *
485      * @throws TorqueException Any exceptions caught during processing will be
486      *         rethrown wrapped into a TorqueException.
487      */
488     public static List doSelect(TurbineRolePermission obj) throws TorqueException
489     {
490         return doSelect(buildSelectCriteria(obj));
491     }
492 
493     /***
494      * Method to do inserts
495      *
496      * @throws TorqueException Any exceptions caught during processing will be
497      *         rethrown wrapped into a TorqueException.
498      */
499     public static void doInsert(TurbineRolePermission obj) throws TorqueException
500     {
501           doInsert(buildCriteria(obj));
502           obj.setNew(false);
503         obj.setModified(false);
504     }
505 
506     /***
507      * @param obj the data object to update in the database.
508      * @throws TorqueException Any exceptions caught during processing will be
509      *         rethrown wrapped into a TorqueException.
510      */
511     public static void doUpdate(TurbineRolePermission obj) throws TorqueException
512     {
513         doUpdate(buildCriteria(obj));
514         obj.setModified(false);
515     }
516 
517     /***
518      * @param obj the data object to delete in the database.
519      * @throws TorqueException Any exceptions caught during processing will be
520      *         rethrown wrapped into a TorqueException.
521      */
522     public static void doDelete(TurbineRolePermission obj) throws TorqueException
523     {
524         doDelete(buildSelectCriteria(obj));
525     }
526 
527     /***
528      * Method to do inserts.  This method is to be used during a transaction,
529      * otherwise use the doInsert(TurbineRolePermission) method.  It will take
530      * care of the connection details internally.
531      *
532      * @param obj the data object to insert into the database.
533      * @param con the connection to use
534      * @throws TorqueException Any exceptions caught during processing will be
535      *         rethrown wrapped into a TorqueException.
536      */
537     public static void doInsert(TurbineRolePermission obj, Connection con)
538         throws TorqueException
539     {
540           doInsert(buildCriteria(obj), con);
541           obj.setNew(false);
542         obj.setModified(false);
543     }
544 
545     /***
546      * Method to do update.  This method is to be used during a transaction,
547      * otherwise use the doUpdate(TurbineRolePermission) method.  It will take
548      * care of the connection details internally.
549      *
550      * @param obj the data object to update in the database.
551      * @param con the connection to use
552      * @throws TorqueException Any exceptions caught during processing will be
553      *         rethrown wrapped into a TorqueException.
554      */
555     public static void doUpdate(TurbineRolePermission obj, Connection con)
556         throws TorqueException
557     {
558         doUpdate(buildCriteria(obj), con);
559         obj.setModified(false);
560     }
561 
562     /***
563      * Method to delete.  This method is to be used during a transaction,
564      * otherwise use the doDelete(TurbineRolePermission) method.  It will take
565      * care of the connection details internally.
566      *
567      * @param obj the data object to delete in the database.
568      * @param con the connection to use
569      * @throws TorqueException Any exceptions caught during processing will be
570      *         rethrown wrapped into a TorqueException.
571      */
572     public static void doDelete(TurbineRolePermission obj, Connection con)
573         throws TorqueException
574     {
575         doDelete(buildSelectCriteria(obj), con);
576     }
577 
578     /***
579      * Method to do deletes.
580      *
581      * @param pk ObjectKey that is used DELETE from database.
582      * @throws TorqueException Any exceptions caught during processing will be
583      *         rethrown wrapped into a TorqueException.
584      */
585     public static void doDelete(ObjectKey pk) throws TorqueException
586     {
587         BaseTurbineRolePermissionPeer
588            .doDelete(pk, (Connection) null);
589     }
590 
591     /***
592      * Method to delete.  This method is to be used during a transaction,
593      * otherwise use the doDelete(ObjectKey) method.  It will take
594      * care of the connection details internally.
595      *
596      * @param pk the primary key for the object to delete in the database.
597      * @param con the connection to use
598      * @throws TorqueException Any exceptions caught during processing will be
599      *         rethrown wrapped into a TorqueException.
600      */
601     public static void doDelete(ObjectKey pk, Connection con)
602         throws TorqueException
603     {
604         doDelete(buildCriteria(pk), con);
605     }
606 
607     /*** Build a Criteria object from an ObjectKey */
608     public static Criteria buildCriteria( ObjectKey pk )
609     {
610         Criteria criteria = new Criteria();
611           SimpleKey[] keys = (SimpleKey[])pk.getValue();
612                     criteria.add(ROLE_ID, keys[0]);
613                       criteria.add(PERMISSION_ID, keys[1]);
614                     return criteria;
615      }
616 
617     /*** Build a Criteria object from the data object for this peer */
618     public static Criteria buildCriteria( TurbineRolePermission obj )
619     {
620         Criteria criteria = new Criteria(DATABASE_NAME);
621               criteria.add(ROLE_ID, obj.getRoleId());
622               criteria.add(PERMISSION_ID, obj.getPermissionId());
623           return criteria;
624     }
625 
626     /*** Build a Criteria object from the data object for this peer, skipping all binary columns */
627     public static Criteria buildSelectCriteria( TurbineRolePermission obj )
628     {
629         Criteria criteria = new Criteria(DATABASE_NAME);
630                       criteria.add(ROLE_ID, obj.getRoleId());
631                           criteria.add(PERMISSION_ID, obj.getPermissionId());
632               return criteria;
633     }
634  
635     
636     
637     /***
638      * Retrieve a single object by pk
639      *
640      * @param pk the primary key
641      * @throws TorqueException Any exceptions caught during processing will be
642      *         rethrown wrapped into a TorqueException.
643      * @throws NoRowsException Primary key was not found in database.
644      * @throws TooManyRowsException Primary key was not found in database.
645      */
646     public static TurbineRolePermission retrieveByPK(ObjectKey pk)
647         throws TorqueException, NoRowsException, TooManyRowsException
648     {
649         Connection db = null;
650         TurbineRolePermission retVal = null;
651         try
652         {
653             db = Torque.getConnection(DATABASE_NAME);
654             retVal = retrieveByPK(pk, db);
655         }
656         finally
657         {
658             Torque.closeConnection(db);
659         }
660         return(retVal);
661     }
662 
663     /***
664      * Retrieve a single object by pk
665      *
666      * @param pk the primary key
667      * @param con the connection to use
668      * @throws TorqueException Any exceptions caught during processing will be
669      *         rethrown wrapped into a TorqueException.
670      * @throws NoRowsException Primary key was not found in database.
671      * @throws TooManyRowsException Primary key was not found in database.
672      */
673     public static TurbineRolePermission retrieveByPK(ObjectKey pk, Connection con)
674         throws TorqueException, NoRowsException, TooManyRowsException
675     {
676         Criteria criteria = buildCriteria(pk);
677         List v = doSelect(criteria, con);
678         if (v.size() == 0)
679         {
680             throw new NoRowsException("Failed to select a row.");
681         }
682         else if (v.size() > 1)
683         {
684             throw new TooManyRowsException("Failed to select only one row.");
685         }
686         else
687         {
688             return (TurbineRolePermission)v.get(0);
689         }
690     }
691 
692     /***
693      * Retrieve a multiple objects by pk
694      *
695      * @param pks List of primary keys
696      * @throws TorqueException Any exceptions caught during processing will be
697      *         rethrown wrapped into a TorqueException.
698      */
699     public static List retrieveByPKs(List pks)
700         throws TorqueException
701     {
702         Connection db = null;
703         List retVal = null;
704         try
705         {
706            db = Torque.getConnection(DATABASE_NAME);
707            retVal = retrieveByPKs(pks, db);
708         }
709         finally
710         {
711             Torque.closeConnection(db);
712         }
713         return(retVal);
714     }
715 
716     /***
717      * Retrieve a multiple objects by pk
718      *
719      * @param pks List of primary keys
720      * @param dbcon the connection to use
721      * @throws TorqueException Any exceptions caught during processing will be
722      *         rethrown wrapped into a TorqueException.
723      */
724     public static List retrieveByPKs( List pks, Connection dbcon )
725         throws TorqueException
726     {
727         List objs = null;
728         if (pks == null || pks.size() == 0)
729         {
730             objs = new LinkedList();
731         }
732         else
733         {
734             Criteria criteria = new Criteria();
735               Iterator iter = pks.iterator();
736             while (iter.hasNext())
737             {
738                 ObjectKey pk = (ObjectKey)iter.next();
739                 SimpleKey[] keys = (SimpleKey[])pk.getValue();
740                             Criteria.Criterion c0 = criteria.getNewCriterion(
741                         ROLE_ID, keys[0], Criteria.EQUAL);
742                                     Criteria.Criterion c1 = criteria.getNewCriterion(
743                         PERMISSION_ID, keys[1], Criteria.EQUAL);
744                                     c0.and(c1);
745                           criteria.or(c0);
746             }
747           objs = doSelect(criteria, dbcon);
748         }
749         return objs;
750     }
751 
752  
753     /***
754      * retrieve object using using pk values.
755      *
756        * @param role_id int
757        * @param permission_id int
758        */
759     public static TurbineRolePermission retrieveByPK(
760        int role_id
761           , int permission_id
762               ) throws TorqueException
763     {
764         Connection db = null;
765         TurbineRolePermission retVal = null;
766         try
767         {
768            db = Torque.getConnection(DATABASE_NAME);
769            retVal = retrieveByPK(
770          role_id
771           , permission_id
772                      , db);
773         }
774         finally
775         {
776             Torque.closeConnection(db);
777         }
778         return(retVal);
779     }
780 
781       /***
782      * retrieve object using using pk values.
783      *
784        * @param role_id int
785        * @param permission_id int
786        * @param con Connection
787      */
788     public static TurbineRolePermission retrieveByPK(
789        int role_id
790           , int permission_id
791              ,Connection con) throws TorqueException
792     {
793 
794         Criteria criteria = new Criteria(5);
795           criteria.add(ROLE_ID, role_id);
796           criteria.add(PERMISSION_ID, permission_id);
797           List v = doSelect(criteria, con);
798         if (v.size() != 1)
799         {
800             throw new TorqueException("Failed to select one and only one row.");
801         }
802         else
803         {
804             return (TurbineRolePermission) v.get(0);
805         }
806     }
807 
808 
809 
810             
811                                               
812                 
813                 
814 
815     /***
816      * selects a collection of TurbineRolePermission objects pre-filled with their
817      * TurbineRole objects.
818      *
819      * This method is protected by default in order to keep the public
820      * api reasonable.  You can provide public methods for those you
821      * actually need in TurbineRolePermissionPeer.
822      *
823      * @throws TorqueException Any exceptions caught during processing will be
824      *         rethrown wrapped into a TorqueException.
825      */
826     protected static List doSelectJoinTurbineRole(Criteria criteria)
827         throws TorqueException
828     {
829         setDbName(criteria);
830 
831         TurbineRolePermissionPeer.addSelectColumns(criteria);
832         int offset = numColumns + 1;
833         TurbineRolePeer.addSelectColumns(criteria);
834 
835 
836                         criteria.addJoin(TurbineRolePermissionPeer.ROLE_ID,
837             TurbineRolePeer.ROLE_ID);
838         
839 
840                                             
841         List rows = BasePeer.doSelect(criteria);
842         List results = new ArrayList();
843 
844         for (int i = 0; i < rows.size(); i++)
845         {
846             Record row = (Record) rows.get(i);
847 
848                             Class omClass = TurbineRolePermissionPeer.getOMClass();
849                     TurbineRolePermission obj1 = (TurbineRolePermission) TurbineRolePermissionPeer
850                 .row2Object(row, 1, omClass);
851                      omClass = TurbineRolePeer.getOMClass();
852                     TurbineRole obj2 = (TurbineRole)TurbineRolePeer
853                 .row2Object(row, offset, omClass);
854 
855             boolean newObject = true;
856             for (int j = 0; j < results.size(); j++)
857             {
858                 TurbineRolePermission temp_obj1 = (TurbineRolePermission)results.get(j);
859                 TurbineRole temp_obj2 = (TurbineRole)temp_obj1.getTurbineRole();
860                 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
861                 {
862                     newObject = false;
863                               temp_obj2.addTurbineRolePermission(obj1);
864                               break;
865                 }
866             }
867                       if (newObject)
868             {
869                 obj2.initTurbineRolePermissions();
870                 obj2.addTurbineRolePermission(obj1);
871             }
872                       results.add(obj1);
873         }
874         return results;
875     }
876                                                             
877                 
878                 
879 
880     /***
881      * selects a collection of TurbineRolePermission objects pre-filled with their
882      * TurbinePermission objects.
883      *
884      * This method is protected by default in order to keep the public
885      * api reasonable.  You can provide public methods for those you
886      * actually need in TurbineRolePermissionPeer.
887      *
888      * @throws TorqueException Any exceptions caught during processing will be
889      *         rethrown wrapped into a TorqueException.
890      */
891     protected static List doSelectJoinTurbinePermission(Criteria criteria)
892         throws TorqueException
893     {
894         setDbName(criteria);
895 
896         TurbineRolePermissionPeer.addSelectColumns(criteria);
897         int offset = numColumns + 1;
898         TurbinePermissionPeer.addSelectColumns(criteria);
899 
900 
901                         criteria.addJoin(TurbineRolePermissionPeer.PERMISSION_ID,
902             TurbinePermissionPeer.PERMISSION_ID);
903         
904 
905                                             
906         List rows = BasePeer.doSelect(criteria);
907         List results = new ArrayList();
908 
909         for (int i = 0; i < rows.size(); i++)
910         {
911             Record row = (Record) rows.get(i);
912 
913                             Class omClass = TurbineRolePermissionPeer.getOMClass();
914                     TurbineRolePermission obj1 = (TurbineRolePermission) TurbineRolePermissionPeer
915                 .row2Object(row, 1, omClass);
916                      omClass = TurbinePermissionPeer.getOMClass();
917                     TurbinePermission obj2 = (TurbinePermission)TurbinePermissionPeer
918                 .row2Object(row, offset, omClass);
919 
920             boolean newObject = true;
921             for (int j = 0; j < results.size(); j++)
922             {
923                 TurbineRolePermission temp_obj1 = (TurbineRolePermission)results.get(j);
924                 TurbinePermission temp_obj2 = (TurbinePermission)temp_obj1.getTurbinePermission();
925                 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
926                 {
927                     newObject = false;
928                               temp_obj2.addTurbineRolePermission(obj1);
929                               break;
930                 }
931             }
932                       if (newObject)
933             {
934                 obj2.initTurbineRolePermissions();
935                 obj2.addTurbineRolePermission(obj1);
936             }
937                       results.add(obj1);
938         }
939         return results;
940     }
941                     
942   
943     
944   
945       /***
946      * Returns the TableMap related to this peer.  This method is not
947      * needed for general use but a specific application could have a need.
948      *
949      * @throws TorqueException Any exceptions caught during processing will be
950      *         rethrown wrapped into a TorqueException.
951      */
952     protected static TableMap getTableMap()
953         throws TorqueException
954     {
955         return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME);
956     }
957    
958     private static void setDbName(Criteria crit)
959     {
960         // Set the correct dbName if it has not been overridden
961         // crit.getDbName will return the same object if not set to
962         // another value so == check is okay and faster
963         if (crit.getDbName() == Torque.getDefaultDB())
964         {
965             crit.setDbName(DATABASE_NAME);
966         }
967     }
968 }