View Javadoc

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