KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fulcrum > security > impl > db > entity > BaseTurbineUserGroupRolePeer


1 package org.apache.fulcrum.security.impl.db.entity;
2
3 import java.math.BigDecimal JavaDoc;
4 import java.sql.Connection JavaDoc;
5 import java.sql.SQLException JavaDoc;
6 import java.util.ArrayList JavaDoc;
7 import java.util.Date JavaDoc;
8 import java.util.Iterator JavaDoc;
9 import java.util.LinkedList JavaDoc;
10 import java.util.List JavaDoc;
11
12 import org.apache.torque.NoRowsException;
13 import org.apache.torque.TooManyRowsException;
14 import org.apache.torque.Torque;
15 import org.apache.torque.TorqueException;
16 import org.apache.torque.map.MapBuilder;
17 import org.apache.torque.map.TableMap;
18 import org.apache.torque.om.DateKey;
19 import org.apache.torque.om.NumberKey;
20 import org.apache.torque.om.StringKey;
21 import org.apache.torque.om.ObjectKey;
22 import org.apache.torque.om.SimpleKey;
23 import org.apache.torque.util.BasePeer;
24 import org.apache.torque.util.Criteria;
25
26 import com.workingdogs.village.DataSetException;
27 import com.workingdogs.village.QueryDataSet;
28 import com.workingdogs.village.Record;
29
30 // Local classes
31
import org.apache.fulcrum.security.impl.db.entity.map.*;
32
33
34   
35   
36   
37 /**
38  */

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

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

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

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

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

197     public static ObjectKey doInsert(Criteria criteria, Connection JavaDoc con)
198         throws TorqueException
199     {
200                     
201         // 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(USER_ID);
229           criteria.addSelectColumn(GROUP_ID);
230           criteria.addSelectColumn(ROLE_ID);
231       }
232
233     /**
234      * Create a new object of type cls from a resultset row starting
235      * from a specified offset. This is done so that you can select
236      * other rows than just those needed for this object. You may
237      * for example want to create two objects from the same row.
238      *
239      * @throws TorqueException Any exceptions caught during processing will be
240      * rethrown wrapped into a TorqueException.
241      */

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

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

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

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

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

345     public static List JavaDoc doSelectVillageRecords(Criteria criteria, Connection JavaDoc con)
346         throws TorqueException
347     {
348         if (criteria.getSelectColumns().size() == 0)
349         {
350             addSelectColumns(criteria);
351         }
352
353                     
354         // Set the correct dbName if it has not been overridden
355
// criteria.getDbName will return the same object if not set to
356
// another value so == check is okay and faster
357
if (criteria.getDbName() == Torque.getDefaultDB())
358         {
359             criteria.setDbName(DATABASE_NAME);
360         }
361         // BasePeer returns a List of Value (Village) arrays. The array
362
// order follows the order columns were placed in the Select clause.
363
if (con == null)
364         {
365             return BasePeer.doSelect(criteria);
366         }
367         else
368         {
369             return BasePeer.doSelect(criteria, con);
370         }
371     }
372
373     /**
374      * The returned List will contain objects of the default type or
375      * objects that inherit from the default.
376      *
377      * @throws TorqueException Any exceptions caught during processing will be
378      * rethrown wrapped into a TorqueException.
379      */

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

404     public static Class JavaDoc getOMClass()
405         throws TorqueException
406     {
407         return CLASS_DEFAULT;
408     }
409
410     /**
411      * Method to do updates.
412      *
413      * @param criteria object containing data that is used to create the UPDATE
414      * statement.
415      * @throws TorqueException Any exceptions caught during processing will be
416      * rethrown wrapped into a TorqueException.
417      */

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

435     public static void doUpdate(Criteria criteria, Connection JavaDoc con)
436         throws TorqueException
437     {
438         Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
439                    selectCriteria.put(USER_ID, criteria.remove(USER_ID));
440                        selectCriteria.put(GROUP_ID, criteria.remove(GROUP_ID));
441                        selectCriteria.put(ROLE_ID, criteria.remove(ROLE_ID));
442       
443         // Set the correct dbName if it has not been overridden
444
// criteria.getDbName will return the same object if not set to
445
// another value so == check is okay and faster
446
if (criteria.getDbName() == Torque.getDefaultDB())
447         {
448             criteria.setDbName(DATABASE_NAME);
449         }
450         if (con == null)
451         {
452             BasePeer.doUpdate(selectCriteria, criteria);
453         }
454         else
455         {
456             BasePeer.doUpdate(selectCriteria, criteria, con);
457         }
458     }
459
460     /**
461      * Method to do deletes.
462      *
463      * @param criteria object containing data that is used DELETE from database.
464      * @throws TorqueException Any exceptions caught during processing will be
465      * rethrown wrapped into a TorqueException.
466      */

467      public static void doDelete(Criteria criteria) throws TorqueException
468      {
469          BaseTurbineUserGroupRolePeer
470             .doDelete(criteria, (Connection JavaDoc) null);
471      }
472
473     /**
474      * Method to do deletes. This method is to be used during a transaction,
475      * otherwise use the doDelete(Criteria) method. It will take care of
476      * the connection details internally.
477      *
478      * @param criteria object containing data that is used DELETE from database.
479      * @param con the connection to use
480      * @throws TorqueException Any exceptions caught during processing will be
481      * rethrown wrapped into a TorqueException.
482      */

483      public static void doDelete(Criteria criteria, Connection JavaDoc con)
484         throws TorqueException
485      {
486                     
487         // Set the correct dbName if it has not been overridden
488
// criteria.getDbName will return the same object if not set to
489
// another value so == check is okay and faster
490
if (criteria.getDbName() == Torque.getDefaultDB())
491         {
492             criteria.setDbName(DATABASE_NAME);
493         }
494         if (con == null)
495         {
496             BasePeer.doDelete(criteria);
497         }
498         else
499         {
500             BasePeer.doDelete(criteria, con);
501         }
502      }
503
504     /**
505      * Method to do selects
506      *
507      * @throws TorqueException Any exceptions caught during processing will be
508      * rethrown wrapped into a TorqueException.
509      */

510     public static List JavaDoc doSelect(TurbineUserGroupRole obj) throws TorqueException
511     {
512         return doSelect(buildCriteria(obj));
513     }
514
515     /**
516      * Method to do inserts
517      *
518      * @throws TorqueException Any exceptions caught during processing will be
519      * rethrown wrapped into a TorqueException.
520      */

521     public static void doInsert(TurbineUserGroupRole obj) throws TorqueException
522     {
523           doInsert(buildCriteria(obj));
524           obj.setNew(false);
525         obj.setModified(false);
526     }
527
528     /**
529      * @param obj the data object to update in the database.
530      * @throws TorqueException Any exceptions caught during processing will be
531      * rethrown wrapped into a TorqueException.
532      */

533     public static void doUpdate(TurbineUserGroupRole obj) throws TorqueException
534     {
535         doUpdate(buildCriteria(obj));
536         obj.setModified(false);
537     }
538
539     /**
540      * @param obj the data object to delete in the database.
541      * @throws TorqueException Any exceptions caught during processing will be
542      * rethrown wrapped into a TorqueException.
543      */

544     public static void doDelete(TurbineUserGroupRole obj) throws TorqueException
545     {
546         doDelete(buildCriteria(obj));
547     }
548
549     /**
550      * Method to do inserts. This method is to be used during a transaction,
551      * otherwise use the doInsert(TurbineUserGroupRole) method. It will take
552      * care of the connection details internally.
553      *
554      * @param obj the data object to insert into the database.
555      * @param con the connection to use
556      * @throws TorqueException Any exceptions caught during processing will be
557      * rethrown wrapped into a TorqueException.
558      */

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

577     public static void doUpdate(TurbineUserGroupRole obj, Connection JavaDoc con)
578         throws TorqueException
579     {
580         doUpdate(buildCriteria(obj), con);
581         obj.setModified(false);
582     }
583
584     /**
585      * Method to delete. This method is to be used during a transaction,
586      * otherwise use the doDelete(TurbineUserGroupRole) method. It will take
587      * care of the connection details internally.
588      *
589      * @param obj the data object to delete in the database.
590      * @param con the connection to use
591      * @throws TorqueException Any exceptions caught during processing will be
592      * rethrown wrapped into a TorqueException.
593      */

594     public static void doDelete(TurbineUserGroupRole obj, Connection JavaDoc con)
595         throws TorqueException
596     {
597         doDelete(buildCriteria(obj), con);
598     }
599
600     /**
601      * Method to do deletes.
602      *
603      * @param pk ObjectKey that is used DELETE from database.
604      * @throws TorqueException Any exceptions caught during processing will be
605      * rethrown wrapped into a TorqueException.
606      */

607     public static void doDelete(ObjectKey pk) throws TorqueException
608     {
609         BaseTurbineUserGroupRolePeer
610            .doDelete(pk, (Connection JavaDoc) null);
611     }
612
613     /**
614      * Method to delete. This method is to be used during a transaction,
615      * otherwise use the doDelete(ObjectKey) method. It will take
616      * care of the connection details internally.
617      *
618      * @param pk the primary key for the object to delete in the database.
619      * @param con the connection to use
620      * @throws TorqueException Any exceptions caught during processing will be
621      * rethrown wrapped into a TorqueException.
622      */

623     public static void doDelete(ObjectKey pk, Connection JavaDoc con)
624         throws TorqueException
625     {
626         doDelete(buildCriteria(pk), con);
627     }
628
629     /** Build a Criteria object from an ObjectKey */
630     public static Criteria buildCriteria( ObjectKey pk )
631     {
632         Criteria criteria = new Criteria();
633           SimpleKey[] keys = (SimpleKey[])pk.getValue();
634                     criteria.add(USER_ID, keys[0]);
635                       criteria.add(GROUP_ID, keys[1]);
636                       criteria.add(ROLE_ID, keys[2]);
637                     return criteria;
638      }
639
640     /** Build a Criteria object from the data object for this peer */
641     public static Criteria buildCriteria( TurbineUserGroupRole obj )
642     {
643         Criteria criteria = new Criteria(DATABASE_NAME);
644                   criteria.add(USER_ID, obj.getUserId());
645                   criteria.add(GROUP_ID, obj.getGroupId());
646                   criteria.add(ROLE_ID, obj.getRoleId());
647           return criteria;
648     }
649  
650     
651     
652     /**
653      * Retrieve a single object by pk
654      *
655      * @param pk the primary key
656      * @throws TorqueException Any exceptions caught during processing will be
657      * rethrown wrapped into a TorqueException.
658      * @throws NoRowsException Primary key was not found in database.
659      * @throws TooManyRowsException Primary key was not found in database.
660      */

661     public static TurbineUserGroupRole retrieveByPK(ObjectKey pk)
662         throws TorqueException, NoRowsException, TooManyRowsException
663     {
664         Connection JavaDoc db = null;
665         TurbineUserGroupRole retVal = null;
666         try
667         {
668             db = Torque.getConnection(DATABASE_NAME);
669             retVal = retrieveByPK(pk, db);
670         }
671         finally
672         {
673             Torque.closeConnection(db);
674         }
675         return(retVal);
676     }
677
678     /**
679      * Retrieve a single object by pk
680      *
681      * @param pk the primary key
682      * @param con the connection to use
683      * @throws TorqueException Any exceptions caught during processing will be
684      * rethrown wrapped into a TorqueException.
685      * @throws NoRowsException Primary key was not found in database.
686      * @throws TooManyRowsException Primary key was not found in database.
687      */

688     public static TurbineUserGroupRole retrieveByPK(ObjectKey pk, Connection JavaDoc con)
689         throws TorqueException, NoRowsException, TooManyRowsException
690     {
691         Criteria criteria = buildCriteria(pk);
692         List JavaDoc v = doSelect(criteria, con);
693         if (v.size() == 0)
694         {
695             throw new NoRowsException("Failed to select a row.");
696         }
697         else if (v.size() > 1)
698         {
699             throw new TooManyRowsException("Failed to select only one row.");
700         }
701         else
702         {
703             return (TurbineUserGroupRole)v.get(0);
704         }
705     }
706
707     /**
708      * Retrieve a multiple objects by pk
709      *
710      * @param pks List of primary keys
711      * @throws TorqueException Any exceptions caught during processing will be
712      * rethrown wrapped into a TorqueException.
713      */

714     public static List JavaDoc retrieveByPKs(List JavaDoc pks)
715         throws TorqueException
716     {
717         Connection JavaDoc db = null;
718         List JavaDoc retVal = null;
719         try
720         {
721            db = Torque.getConnection(DATABASE_NAME);
722            retVal = retrieveByPKs(pks, db);
723         }
724         finally
725         {
726             Torque.closeConnection(db);
727         }
728         return(retVal);
729     }
730
731     /**
732      * Retrieve a multiple objects by pk
733      *
734      * @param pks List of primary keys
735      * @param dbcon the connection to use
736      * @throws TorqueException Any exceptions caught during processing will be
737      * rethrown wrapped into a TorqueException.
738      */

739     public static List JavaDoc retrieveByPKs( List JavaDoc pks, Connection JavaDoc dbcon )
740         throws TorqueException
741     {
742         List JavaDoc objs = null;
743         if (pks == null || pks.size() == 0)
744         {
745             objs = new LinkedList JavaDoc();
746         }
747         else
748         {
749             Criteria criteria = new Criteria();
750               Iterator JavaDoc iter = pks.iterator();
751             while (iter.hasNext())
752             {
753                 ObjectKey pk = (ObjectKey)iter.next();
754                 SimpleKey[] keys = (SimpleKey[])pk.getValue();
755                             Criteria.Criterion c0 = criteria.getNewCriterion(
756                         USER_ID, keys[0], Criteria.EQUAL);
757                                     Criteria.Criterion c1 = criteria.getNewCriterion(
758                         GROUP_ID, keys[1], Criteria.EQUAL);
759                                     c0.and(c1);
760                               Criteria.Criterion c2 = criteria.getNewCriterion(
761                         ROLE_ID, keys[2], Criteria.EQUAL);
762                                     c1.and(c2);
763                           criteria.or(c0);
764             }
765           objs = doSelect(criteria, dbcon);
766         }
767         return objs;
768     }
769
770  
771     /**
772      * retrieve object using using pk values.
773      *
774        * @param user_id Integer
775        * @param group_id Integer
776        * @param role_id Integer
777        */

778     public static TurbineUserGroupRole retrieveByPK(
779        Integer JavaDoc user_id
780           , Integer JavaDoc group_id
781           , Integer JavaDoc role_id
782               ) throws TorqueException
783     {
784         Connection JavaDoc db = null;
785         TurbineUserGroupRole retVal = null;
786         try
787         {
788            db = Torque.getConnection(DATABASE_NAME);
789            retVal = retrieveByPK(
790          user_id
791           , group_id
792           , role_id
793                      , db);
794         }
795         finally
796         {
797             Torque.closeConnection(db);
798         }
799         return(retVal);
800     }
801
802       /**
803      * retrieve object using using pk values.
804      *
805        * @param user_id Integer
806        * @param group_id Integer
807        * @param role_id Integer
808        * @param Connection con
809      */

810     public static TurbineUserGroupRole retrieveByPK(
811        Integer JavaDoc user_id
812           , Integer JavaDoc group_id
813           , Integer JavaDoc role_id
814              ,Connection JavaDoc con) throws TorqueException
815     {
816
817         Criteria criteria = new Criteria(5);
818           criteria.add(USER_ID, user_id);
819           criteria.add(GROUP_ID, group_id);
820           criteria.add(ROLE_ID, role_id);
821           List JavaDoc v = doSelect(criteria, con);
822         if (v.size() != 1)
823         {
824             throw new TorqueException("Failed to select one and only one row.");
825         }
826         else
827         {
828             return (TurbineUserGroupRole) v.get(0);
829         }
830     }
831
832
833
834               
835                                               
836                 
837                 
838
839     /**
840      * selects a collection of TurbineUserGroupRole objects pre-filled with their
841      * TurbineUser objects.
842      *
843      * This method is protected by default in order to keep the public
844      * api reasonable. You can provide public methods for those you
845      * actually need in TurbineUserGroupRolePeer.
846      *
847      * @throws TorqueException Any exceptions caught during processing will be
848      * rethrown wrapped into a TorqueException.
849      */

850     protected static List JavaDoc doSelectJoinTurbineUser(Criteria c)
851         throws TorqueException
852     {
853         // Set the correct dbName if it has not been overridden
854
// c.getDbName will return the same object if not set to
855
// another value so == check is okay and faster
856
if (c.getDbName() == Torque.getDefaultDB())
857         {
858             c.setDbName(DATABASE_NAME);
859         }
860
861         TurbineUserGroupRolePeer.addSelectColumns(c);
862         int offset = numColumns + 1;
863         TurbineUserPeer.addSelectColumns(c);
864
865
866                         c.addJoin(TurbineUserGroupRolePeer.USER_ID,
867             TurbineUserPeer.USER_ID);
868         
869
870                                                               
871         List JavaDoc rows = BasePeer.doSelect(c);
872         List JavaDoc results = new ArrayList JavaDoc();
873
874         for (int i = 0; i < rows.size(); i++)
875         {
876             Record row = (Record) rows.get(i);
877
878                             Class JavaDoc omClass = TurbineUserGroupRolePeer.getOMClass();
879                     TurbineUserGroupRole obj1 = (TurbineUserGroupRole) TurbineUserGroupRolePeer
880                 .row2Object(row, 1, omClass);
881                      omClass = TurbineUserPeer.getOMClass();
882                     TurbineUser obj2 = (TurbineUser)TurbineUserPeer
883                 .row2Object(row, offset, omClass);
884
885             boolean newObject = true;
886             for (int j = 0; j < results.size(); j++)
887             {
888                 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j);
889                 TurbineUser temp_obj2 = (TurbineUser)temp_obj1.getTurbineUser();
890                 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
891                 {
892                     newObject = false;
893                     temp_obj2.addTurbineUserGroupRole(obj1);
894                     break;
895                 }
896             }
897             if (newObject)
898             {
899                 obj2.initTurbineUserGroupRoles();
900                 obj2.addTurbineUserGroupRole(obj1);
901             }
902             results.add(obj1);
903         }
904         return results;
905     }
906                                                             
907                 
908                 
909
910     /**
911      * selects a collection of TurbineUserGroupRole objects pre-filled with their
912      * TurbineGroup objects.
913      *
914      * This method is protected by default in order to keep the public
915      * api reasonable. You can provide public methods for those you
916      * actually need in TurbineUserGroupRolePeer.
917      *
918      * @throws TorqueException Any exceptions caught during processing will be
919      * rethrown wrapped into a TorqueException.
920      */

921     protected static List JavaDoc doSelectJoinTurbineGroup(Criteria c)
922         throws TorqueException
923     {
924         // Set the correct dbName if it has not been overridden
925
// c.getDbName will return the same object if not set to
926
// another value so == check is okay and faster
927
if (c.getDbName() == Torque.getDefaultDB())
928         {
929             c.setDbName(DATABASE_NAME);
930         }
931
932         TurbineUserGroupRolePeer.addSelectColumns(c);
933         int offset = numColumns + 1;
934         TurbineGroupPeer.addSelectColumns(c);
935
936
937                         c.addJoin(TurbineUserGroupRolePeer.GROUP_ID,
938             TurbineGroupPeer.GROUP_ID);
939         
940
941                                                               
942         List JavaDoc rows = BasePeer.doSelect(c);
943         List JavaDoc results = new ArrayList JavaDoc();
944
945         for (int i = 0; i < rows.size(); i++)
946         {
947             Record row = (Record) rows.get(i);
948
949                             Class JavaDoc omClass = TurbineUserGroupRolePeer.getOMClass();
950                     TurbineUserGroupRole obj1 = (TurbineUserGroupRole) TurbineUserGroupRolePeer
951                 .row2Object(row, 1, omClass);
952                      omClass = TurbineGroupPeer.getOMClass();
953                     TurbineGroup obj2 = (TurbineGroup)TurbineGroupPeer
954                 .row2Object(row, offset, omClass);
955
956             boolean newObject = true;
957             for (int j = 0; j < results.size(); j++)
958             {
959                 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j);
960                 TurbineGroup temp_obj2 = (TurbineGroup)temp_obj1.getTurbineGroup();
961                 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
962                 {
963                     newObject = false;
964                     temp_obj2.addTurbineUserGroupRole(obj1);
965                     break;
966                 }
967             }
968             if (newObject)
969             {
970                 obj2.initTurbineUserGroupRoles();
971                 obj2.addTurbineUserGroupRole(obj1);
972             }
973             results.add(obj1);
974         }
975         return results;
976     }
977                                                             
978                 
979                 
980
981     /**
982      * selects a collection of TurbineUserGroupRole objects pre-filled with their
983      * TurbineRole objects.
984      *
985      * This method is protected by default in order to keep the public
986      * api reasonable. You can provide public methods for those you
987      * actually need in TurbineUserGroupRolePeer.
988      *
989      * @throws TorqueException Any exceptions caught during processing will be
990      * rethrown wrapped into a TorqueException.
991      */

992     protected static List JavaDoc doSelectJoinTurbineRole(Criteria c)
993         throws TorqueException
994     {
995         // Set the correct dbName if it has not been overridden
996
// c.getDbName will return the same object if not set to
997
// another value so == check is okay and faster
998
if (c.getDbName() == Torque.getDefaultDB())
999         {
1000            c.setDbName(DATABASE_NAME);
1001        }
1002
1003        TurbineUserGroupRolePeer.addSelectColumns(c);
1004        int offset = numColumns + 1;
1005        TurbineRolePeer.addSelectColumns(c);
1006
1007
1008                        c.addJoin(TurbineUserGroupRolePeer.ROLE_ID,
1009            TurbineRolePeer.ROLE_ID);
1010        
1011
1012                                                              
1013        List JavaDoc rows = BasePeer.doSelect(c);
1014        List JavaDoc results = new ArrayList JavaDoc();
1015
1016        for (int i = 0; i < rows.size(); i++)
1017        {
1018            Record row = (Record) rows.get(i);
1019
1020                            Class JavaDoc omClass = TurbineUserGroupRolePeer.getOMClass();
1021                    TurbineUserGroupRole obj1 = (TurbineUserGroupRole) TurbineUserGroupRolePeer
1022                .row2Object(row, 1, omClass);
1023                     omClass = TurbineRolePeer.getOMClass();
1024                    TurbineRole obj2 = (TurbineRole)TurbineRolePeer
1025                .row2Object(row, offset, omClass);
1026
1027            boolean newObject = true;
1028            for (int j = 0; j < results.size(); j++)
1029            {
1030                TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j);
1031                TurbineRole temp_obj2 = (TurbineRole)temp_obj1.getTurbineRole();
1032                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1033                {
1034                    newObject = false;
1035                    temp_obj2.addTurbineUserGroupRole(obj1);
1036                    break;
1037                }
1038            }
1039            if (newObject)
1040            {
1041                obj2.initTurbineUserGroupRoles();
1042                obj2.addTurbineUserGroupRole(obj1);
1043            }
1044            results.add(obj1);
1045        }
1046        return results;
1047    }
1048                    
1049  
1050                                    
1051          
1052        
1053                                  
1054                
1055
1056    /**
1057     * selects a collection of TurbineUserGroupRole objects pre-filled with
1058     * all related objects.
1059     *
1060     * This method is protected by default in order to keep the public
1061     * api reasonable. You can provide public methods for those you
1062     * actually need in TurbineUserGroupRolePeer.
1063     *
1064     * @throws TorqueException Any exceptions caught during processing will be
1065     * rethrown wrapped into a TorqueException.
1066     */

1067    protected static List JavaDoc doSelectJoinAllExceptTurbineUser(Criteria c)
1068        throws TorqueException
1069    {
1070        // Set the correct dbName if it has not been overridden
1071
// c.getDbName will return the same object if not set to another value
1072
// so == check is okay and faster
1073
if (c.getDbName() == Torque.getDefaultDB())
1074        {
1075            c.setDbName(DATABASE_NAME);
1076        }
1077
1078        addSelectColumns(c);
1079        int offset2 = numColumns + 1;
1080                                    
1081                                                  
1082                    TurbineGroupPeer.addSelectColumns(c);
1083        int offset3 = offset2 + TurbineGroupPeer.numColumns;
1084                                                                
1085                    TurbineRolePeer.addSelectColumns(c);
1086        int offset4 = offset3 + TurbineRolePeer.numColumns;
1087                                                                                                          
1088        List JavaDoc rows = BasePeer.doSelect(c);
1089        List JavaDoc results = new ArrayList JavaDoc();
1090
1091        for (int i = 0; i < rows.size(); i++)
1092        {
1093            Record row = (Record)rows.get(i);
1094
1095                            Class JavaDoc omClass = TurbineUserGroupRolePeer.getOMClass();
1096                    TurbineUserGroupRole obj1 = (TurbineUserGroupRole)TurbineUserGroupRolePeer
1097                .row2Object(row, 1, omClass);
1098                                                
1099                                                                  
1100                                                        
1101                            
1102              
1103                           omClass = TurbineGroupPeer.getOMClass();
1104                          TurbineGroup obj2 = (TurbineGroup)TurbineGroupPeer
1105                .row2Object( row, offset2, omClass);
1106
1107               boolean newObject = true;
1108            for (int j = 0; j < results.size(); j++)
1109            {
1110                TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j);
1111                TurbineGroup temp_obj2 = (TurbineGroup)temp_obj1.getTurbineGroup();
1112                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1113                {
1114                    newObject = false;
1115                    temp_obj2.addTurbineUserGroupRole(obj1);
1116                    break;
1117                }
1118            }
1119            if (newObject)
1120            {
1121                obj2.initTurbineUserGroupRoles();
1122                obj2.addTurbineUserGroupRole(obj1);
1123            }
1124                                                                    
1125                                                        
1126                            
1127              
1128                           omClass = TurbineRolePeer.getOMClass();
1129                          TurbineRole obj3 = (TurbineRole)TurbineRolePeer
1130                .row2Object( row, offset3, omClass);
1131
1132               newObject = true;
1133            for (int j = 0; j < results.size(); j++)
1134            {
1135                TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j);
1136                TurbineRole temp_obj3 = (TurbineRole)temp_obj1.getTurbineRole();
1137                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1138                {
1139                    newObject = false;
1140                    temp_obj3.addTurbineUserGroupRole(obj1);
1141                    break;
1142                }
1143            }
1144            if (newObject)
1145            {
1146                obj3.initTurbineUserGroupRoles();
1147                obj3.addTurbineUserGroupRole(obj1);
1148            }
1149                                                results.add(obj1);
1150        }
1151        return results;
1152    }
1153        
1154        
1155                                  
1156                
1157
1158    /**
1159     * selects a collection of TurbineUserGroupRole objects pre-filled with
1160     * all related objects.
1161     *
1162     * This method is protected by default in order to keep the public
1163     * api reasonable. You can provide public methods for those you
1164     * actually need in TurbineUserGroupRolePeer.
1165     *
1166     * @throws TorqueException Any exceptions caught during processing will be
1167     * rethrown wrapped into a TorqueException.
1168     */

1169    protected static List JavaDoc doSelectJoinAllExceptTurbineGroup(Criteria c)
1170        throws TorqueException
1171    {
1172        // Set the correct dbName if it has not been overridden
1173
// c.getDbName will return the same object if not set to another value
1174
// so == check is okay and faster
1175
if (c.getDbName() == Torque.getDefaultDB())
1176        {
1177            c.setDbName(DATABASE_NAME);
1178        }
1179
1180        addSelectColumns(c);
1181        int offset2 = numColumns + 1;
1182                                    
1183                    TurbineUserPeer.addSelectColumns(c);
1184        int offset3 = offset2 + TurbineUserPeer.numColumns;
1185                                                                
1186                                                  
1187                    TurbineRolePeer.addSelectColumns(c);
1188        int offset4 = offset3 + TurbineRolePeer.numColumns;
1189                                                                                                          
1190        List JavaDoc rows = BasePeer.doSelect(c);
1191        List JavaDoc results = new ArrayList JavaDoc();
1192
1193        for (int i = 0; i < rows.size(); i++)
1194        {
1195            Record row = (Record)rows.get(i);
1196
1197                            Class JavaDoc omClass = TurbineUserGroupRolePeer.getOMClass();
1198                    TurbineUserGroupRole obj1 = (TurbineUserGroupRole)TurbineUserGroupRolePeer
1199                .row2Object(row, 1, omClass);
1200                                                
1201                                                        
1202                            
1203              
1204                           omClass = TurbineUserPeer.getOMClass();
1205                          TurbineUser obj2 = (TurbineUser)TurbineUserPeer
1206                .row2Object( row, offset2, omClass);
1207
1208               boolean newObject = true;
1209            for (int j = 0; j < results.size(); j++)
1210            {
1211                TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j);
1212                TurbineUser temp_obj2 = (TurbineUser)temp_obj1.getTurbineUser();
1213                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1214                {
1215                    newObject = false;
1216                    temp_obj2.addTurbineUserGroupRole(obj1);
1217                    break;
1218                }
1219            }
1220            if (newObject)
1221            {
1222                obj2.initTurbineUserGroupRoles();
1223                obj2.addTurbineUserGroupRole(obj1);
1224            }
1225                                                                    
1226                                                                  
1227                                                        
1228                            
1229              
1230                           omClass = TurbineRolePeer.getOMClass();
1231                          TurbineRole obj3 = (TurbineRole)TurbineRolePeer
1232                .row2Object( row, offset3, omClass);
1233
1234               newObject = true;
1235            for (int j = 0; j < results.size(); j++)
1236            {
1237                TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j);
1238                TurbineRole temp_obj3 = (TurbineRole)temp_obj1.getTurbineRole();
1239                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1240                {
1241                    newObject = false;
1242                    temp_obj3.addTurbineUserGroupRole(obj1);
1243                    break;
1244                }
1245            }
1246            if (newObject)
1247            {
1248                obj3.initTurbineUserGroupRoles();
1249                obj3.addTurbineUserGroupRole(obj1);
1250            }
1251                                                results.add(obj1);
1252        }
1253        return results;
1254    }
1255        
1256        
1257                                  
1258                
1259
1260    /**
1261     * selects a collection of TurbineUserGroupRole objects pre-filled with
1262     * all related objects.
1263     *
1264     * This method is protected by default in order to keep the public
1265     * api reasonable. You can provide public methods for those you
1266     * actually need in TurbineUserGroupRolePeer.
1267     *
1268     * @throws TorqueException Any exceptions caught during processing will be
1269     * rethrown wrapped into a TorqueException.
1270     */

1271    protected static List JavaDoc doSelectJoinAllExceptTurbineRole(Criteria c)
1272        throws TorqueException
1273    {
1274        // Set the correct dbName if it has not been overridden
1275
// c.getDbName will return the same object if not set to another value
1276
// so == check is okay and faster
1277
if (c.getDbName() == Torque.getDefaultDB())
1278        {
1279            c.setDbName(DATABASE_NAME);
1280        }
1281
1282        addSelectColumns(c);
1283        int offset2 = numColumns + 1;
1284                                    
1285                    TurbineUserPeer.addSelectColumns(c);
1286        int offset3 = offset2 + TurbineUserPeer.numColumns;
1287                                                                
1288                    TurbineGroupPeer.addSelectColumns(c);
1289        int offset4 = offset3 + TurbineGroupPeer.numColumns;
1290                                                                
1291                                                                                            
1292        List JavaDoc rows = BasePeer.doSelect(c);
1293        List JavaDoc results = new ArrayList JavaDoc();
1294
1295        for (int i = 0; i < rows.size(); i++)
1296        {
1297            Record row = (Record)rows.get(i);
1298
1299                            Class JavaDoc omClass = TurbineUserGroupRolePeer.getOMClass();
1300                    TurbineUserGroupRole obj1 = (TurbineUserGroupRole)TurbineUserGroupRolePeer
1301                .row2Object(row, 1, omClass);
1302                                                
1303                                                        
1304                            
1305              
1306                           omClass = TurbineUserPeer.getOMClass();
1307                          TurbineUser obj2 = (TurbineUser)TurbineUserPeer
1308                .row2Object( row, offset2, omClass);
1309
1310               boolean newObject = true;
1311            for (int j = 0; j < results.size(); j++)
1312            {
1313                TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j);
1314                TurbineUser temp_obj2 = (TurbineUser)temp_obj1.getTurbineUser();
1315                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1316                {
1317                    newObject = false;
1318                    temp_obj2.addTurbineUserGroupRole(obj1);
1319                    break;
1320                }
1321            }
1322            if (newObject)
1323            {
1324                obj2.initTurbineUserGroupRoles();
1325                obj2.addTurbineUserGroupRole(obj1);
1326            }
1327                                                                    
1328                                                        
1329                            
1330              
1331                           omClass = TurbineGroupPeer.getOMClass();
1332                          TurbineGroup obj3 = (TurbineGroup)TurbineGroupPeer
1333                .row2Object( row, offset3, omClass);
1334
1335               newObject = true;
1336            for (int j = 0; j < results.size(); j++)
1337            {
1338                TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j);
1339                TurbineGroup temp_obj3 = (TurbineGroup)temp_obj1.getTurbineGroup();
1340                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1341                {
1342                    newObject = false;
1343                    temp_obj3.addTurbineUserGroupRole(obj1);
1344                    break;
1345                }
1346            }
1347            if (newObject)
1348            {
1349                obj3.initTurbineUserGroupRoles();
1350                obj3.addTurbineUserGroupRole(obj1);
1351            }
1352                                                                    
1353                                              results.add(obj1);
1354        }
1355        return results;
1356    }
1357                    
1358  
1359      /**
1360     * Returns the TableMap related to this peer. This method is not
1361     * needed for general use but a specific application could have a need.
1362     *
1363     * @throws TorqueException Any exceptions caught during processing will be
1364     * rethrown wrapped into a TorqueException.
1365     */

1366    protected static TableMap getTableMap()
1367        throws TorqueException
1368    {
1369        return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME);
1370    }
1371   }
1372
Popular Tags