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
31 import org.apache.turbine.services.security.torque.om.map.*;
32
33
34
35 /***
36 * This class was autogenerated by Torque on:
37 *
38 * [Mon May 28 10:17:20 EST 2007]
39 *
40 */
41 public abstract class BaseTurbineUserGroupRolePeer
42 extends BasePeer
43 {
44
45 /*** the default database name for this class */
46 public static final String DATABASE_NAME = "default";
47
48 /*** the table name for this class */
49 public static final String TABLE_NAME = "TURBINE_USER_GROUP_ROLE";
50
51 /***
52 * @return the map builder for this peer
53 * @throws TorqueException Any exceptions caught during processing will be
54 * rethrown wrapped into a TorqueException.
55 */
56 public static MapBuilder getMapBuilder()
57 throws TorqueException
58 {
59 return getMapBuilder(TurbineUserGroupRoleMapBuilder.CLASS_NAME);
60 }
61
62 /*** the column name for the USER_ID field */
63 public static final String USER_ID;
64 /*** the column name for the GROUP_ID field */
65 public static final String GROUP_ID;
66 /*** the column name for the ROLE_ID field */
67 public static final String ROLE_ID;
68
69 static
70 {
71 USER_ID = "TURBINE_USER_GROUP_ROLE.USER_ID";
72 GROUP_ID = "TURBINE_USER_GROUP_ROLE.GROUP_ID";
73 ROLE_ID = "TURBINE_USER_GROUP_ROLE.ROLE_ID";
74 if (Torque.isInit())
75 {
76 try
77 {
78 getMapBuilder(TurbineUserGroupRoleMapBuilder.CLASS_NAME);
79 }
80 catch (Exception e)
81 {
82 log.error("Could not initialize Peer", e);
83 throw new RuntimeException(e);
84 }
85 }
86 else
87 {
88 Torque.registerMapBuilder(TurbineUserGroupRoleMapBuilder.CLASS_NAME);
89 }
90 }
91
92 /*** number of columns for this peer */
93 public static final int numColumns = 3;
94
95 /*** A class that can be returned by this peer. */
96 protected static final String CLASSNAME_DEFAULT =
97 "org.apache.turbine.services.security.torque.om.TurbineUserGroupRole";
98
99 /*** A class that can be returned by this peer. */
100 protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT);
101
102 /***
103 * Class object initialization method.
104 *
105 * @param className name of the class to initialize
106 * @return the initialized class
107 */
108 private static Class initClass(String className)
109 {
110 Class c = null;
111 try
112 {
113 c = Class.forName(className);
114 }
115 catch (Throwable t)
116 {
117 log.error("A FATAL ERROR has occurred which should not "
118 + "have happened under any circumstance. Please notify "
119 + "the Torque developers <torque-dev@db.apache.org> "
120 + "and give as many details as possible (including the error "
121 + "stack trace).", t);
122
123
124 if (t instanceof Error)
125 {
126 throw (Error) t.fillInStackTrace();
127 }
128 }
129 return c;
130 }
131
132 /***
133 * Get the list of objects for a ResultSet. Please not that your
134 * resultset MUST return columns in the right order. You can use
135 * getFieldNames() in BaseObject to get the correct sequence.
136 *
137 * @param results the ResultSet
138 * @return the list of objects
139 * @throws TorqueException Any exceptions caught during processing will be
140 * rethrown wrapped into a TorqueException.
141 */
142 public static List resultSet2Objects(java.sql.ResultSet results)
143 throws TorqueException
144 {
145 try
146 {
147 QueryDataSet qds = null;
148 List rows = null;
149 try
150 {
151 qds = new QueryDataSet(results);
152 rows = getSelectResults(qds);
153 }
154 finally
155 {
156 if (qds != null)
157 {
158 qds.close();
159 }
160 }
161
162 return populateObjects(rows);
163 }
164 catch (SQLException e)
165 {
166 throw new TorqueException(e);
167 }
168 catch (DataSetException e)
169 {
170 throw new TorqueException(e);
171 }
172 }
173
174
175
176 /***
177 * Method to do inserts.
178 *
179 * @param criteria object used to create the INSERT statement.
180 * @throws TorqueException Any exceptions caught during processing will be
181 * rethrown wrapped into a TorqueException.
182 */
183 public static ObjectKey doInsert(Criteria criteria)
184 throws TorqueException
185 {
186 return BaseTurbineUserGroupRolePeer
187 .doInsert(criteria, (Connection) null);
188 }
189
190 /***
191 * Method to do inserts. This method is to be used during a transaction,
192 * otherwise use the doInsert(Criteria) method. It will take care of
193 * the connection details internally.
194 *
195 * @param criteria object used to create the INSERT statement.
196 * @param con the connection to use
197 * @throws TorqueException Any exceptions caught during processing will be
198 * rethrown wrapped into a TorqueException.
199 */
200 public static ObjectKey doInsert(Criteria criteria, Connection con)
201 throws TorqueException
202 {
203 correctBooleans(criteria);
204
205 setDbName(criteria);
206
207 if (con == null)
208 {
209 return BasePeer.doInsert(criteria);
210 }
211 else
212 {
213 return BasePeer.doInsert(criteria, con);
214 }
215 }
216
217 /***
218 * Add all the columns needed to create a new object.
219 *
220 * @param criteria object containing the columns to add.
221 * @throws TorqueException Any exceptions caught during processing will be
222 * rethrown wrapped into a TorqueException.
223 */
224 public static void addSelectColumns(Criteria criteria)
225 throws TorqueException
226 {
227 criteria.addSelectColumn(USER_ID);
228 criteria.addSelectColumn(GROUP_ID);
229 criteria.addSelectColumn(ROLE_ID);
230 }
231
232 /***
233 * changes the boolean values in the criteria to the appropriate type,
234 * whenever a booleanchar or booleanint column is involved.
235 * This enables the user to create criteria using Boolean values
236 * for booleanchar or booleanint columns
237 * @param criteria the criteria in which the boolean values should be corrected
238 */
239 public static void correctBooleans(Criteria criteria)
240 {
241 }
242
243 /***
244 * Create a new object of type cls from a resultset row starting
245 * from a specified offset. This is done so that you can select
246 * other rows than just those needed for this object. You may
247 * for example want to create two objects from the same row.
248 *
249 * @throws TorqueException Any exceptions caught during processing will be
250 * rethrown wrapped into a TorqueException.
251 */
252 public static TurbineUserGroupRole row2Object(Record row,
253 int offset,
254 Class cls)
255 throws TorqueException
256 {
257 try
258 {
259 TurbineUserGroupRole obj = (TurbineUserGroupRole) cls.newInstance();
260 TurbineUserGroupRolePeer.populateObject(row, offset, obj);
261 obj.setModified(false);
262 obj.setNew(false);
263
264 return obj;
265 }
266 catch (InstantiationException e)
267 {
268 throw new TorqueException(e);
269 }
270 catch (IllegalAccessException e)
271 {
272 throw new TorqueException(e);
273 }
274 }
275
276 /***
277 * Populates an object from a resultset row starting
278 * from a specified offset. This is done so that you can select
279 * other rows than just those needed for this object. You may
280 * for example want to create two objects from the same row.
281 *
282 * @throws TorqueException Any exceptions caught during processing will be
283 * rethrown wrapped into a TorqueException.
284 */
285 public static void populateObject(Record row,
286 int offset,
287 TurbineUserGroupRole obj)
288 throws TorqueException
289 {
290 try
291 {
292 obj.setUserId(row.getValue(offset + 0).asInt());
293 obj.setGroupId(row.getValue(offset + 1).asInt());
294 obj.setRoleId(row.getValue(offset + 2).asInt());
295 }
296 catch (DataSetException e)
297 {
298 throw new TorqueException(e);
299 }
300 }
301
302 /***
303 * Method to do selects.
304 *
305 * @param criteria object used to create the SELECT statement.
306 * @return List of selected Objects
307 * @throws TorqueException Any exceptions caught during processing will be
308 * rethrown wrapped into a TorqueException.
309 */
310 public static List doSelect(Criteria criteria) throws TorqueException
311 {
312 return populateObjects(doSelectVillageRecords(criteria));
313 }
314
315 /***
316 * Method to do selects within a transaction.
317 *
318 * @param criteria object used to create the SELECT statement.
319 * @param con the connection to use
320 * @return List of selected Objects
321 * @throws TorqueException Any exceptions caught during processing will be
322 * rethrown wrapped into a TorqueException.
323 */
324 public static List doSelect(Criteria criteria, Connection con)
325 throws TorqueException
326 {
327 return populateObjects(doSelectVillageRecords(criteria, con));
328 }
329
330 /***
331 * Grabs the raw Village records to be formed into objects.
332 * This method handles connections internally. The Record objects
333 * returned by this method should be considered readonly. Do not
334 * alter the data and call save(), your results may vary, but are
335 * certainly likely to result in hard to track MT bugs.
336 *
337 * @throws TorqueException Any exceptions caught during processing will be
338 * rethrown wrapped into a TorqueException.
339 */
340 public static List doSelectVillageRecords(Criteria criteria)
341 throws TorqueException
342 {
343 return BaseTurbineUserGroupRolePeer
344 .doSelectVillageRecords(criteria, (Connection) null);
345 }
346
347 /***
348 * Grabs the raw Village records to be formed into objects.
349 * This method should be used for transactions
350 *
351 * @param criteria object used to create the SELECT statement.
352 * @param con the connection to use
353 * @throws TorqueException Any exceptions caught during processing will be
354 * rethrown wrapped into a TorqueException.
355 */
356 public static List doSelectVillageRecords(Criteria criteria, Connection con)
357 throws TorqueException
358 {
359 if (criteria.getSelectColumns().size() == 0)
360 {
361 addSelectColumns(criteria);
362 }
363 correctBooleans(criteria);
364
365 setDbName(criteria);
366
367
368
369 if (con == null)
370 {
371 return BasePeer.doSelect(criteria);
372 }
373 else
374 {
375 return BasePeer.doSelect(criteria, con);
376 }
377 }
378
379 /***
380 * The returned List will contain objects of the default type or
381 * objects that inherit from the default.
382 *
383 * @throws TorqueException Any exceptions caught during processing will be
384 * rethrown wrapped into a TorqueException.
385 */
386 public static List populateObjects(List records)
387 throws TorqueException
388 {
389 List results = new ArrayList(records.size());
390
391
392 for (int i = 0; i < records.size(); i++)
393 {
394 Record row = (Record) records.get(i);
395 results.add(TurbineUserGroupRolePeer.row2Object(row, 1,
396 TurbineUserGroupRolePeer.getOMClass()));
397 }
398 return results;
399 }
400
401
402 /***
403 * The class that the Peer will make instances of.
404 * If the BO is abstract then you must implement this method
405 * in the BO.
406 *
407 * @throws TorqueException Any exceptions caught during processing will be
408 * rethrown wrapped into a TorqueException.
409 */
410 public static Class getOMClass()
411 throws TorqueException
412 {
413 return CLASS_DEFAULT;
414 }
415
416 /***
417 * Method to do updates.
418 *
419 * @param criteria object containing data that is used to create the UPDATE
420 * statement.
421 * @throws TorqueException Any exceptions caught during processing will be
422 * rethrown wrapped into a TorqueException.
423 */
424 public static void doUpdate(Criteria criteria) throws TorqueException
425 {
426 BaseTurbineUserGroupRolePeer
427 .doUpdate(criteria, (Connection) null);
428 }
429
430 /***
431 * Method to do updates. This method is to be used during a transaction,
432 * otherwise use the doUpdate(Criteria) method. It will take care of
433 * the connection details internally.
434 *
435 * @param criteria object containing data that is used to create the UPDATE
436 * statement.
437 * @param con the connection to use
438 * @throws TorqueException Any exceptions caught during processing will be
439 * rethrown wrapped into a TorqueException.
440 */
441 public static void doUpdate(Criteria criteria, Connection con)
442 throws TorqueException
443 {
444 Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
445 correctBooleans(criteria);
446
447
448 selectCriteria.put(USER_ID, criteria.remove(USER_ID));
449
450 selectCriteria.put(GROUP_ID, criteria.remove(GROUP_ID));
451
452 selectCriteria.put(ROLE_ID, criteria.remove(ROLE_ID));
453
454 setDbName(criteria);
455
456 if (con == null)
457 {
458 BasePeer.doUpdate(selectCriteria, criteria);
459 }
460 else
461 {
462 BasePeer.doUpdate(selectCriteria, criteria, con);
463 }
464 }
465
466 /***
467 * Method to do deletes.
468 *
469 * @param criteria object containing data that is used DELETE from database.
470 * @throws TorqueException Any exceptions caught during processing will be
471 * rethrown wrapped into a TorqueException.
472 */
473 public static void doDelete(Criteria criteria) throws TorqueException
474 {
475 TurbineUserGroupRolePeer
476 .doDelete(criteria, (Connection) null);
477 }
478
479 /***
480 * Method to do deletes. This method is to be used during a transaction,
481 * otherwise use the doDelete(Criteria) method. It will take care of
482 * the connection details internally.
483 *
484 * @param criteria object containing data that is used DELETE from database.
485 * @param con the connection to use
486 * @throws TorqueException Any exceptions caught during processing will be
487 * rethrown wrapped into a TorqueException.
488 */
489 public static void doDelete(Criteria criteria, Connection con)
490 throws TorqueException
491 {
492 correctBooleans(criteria);
493
494 setDbName(criteria);
495
496 if (con == null)
497 {
498 BasePeer.doDelete(criteria);
499 }
500 else
501 {
502 BasePeer.doDelete(criteria, con);
503 }
504 }
505
506 /***
507 * Method to do selects
508 *
509 * @throws TorqueException Any exceptions caught during processing will be
510 * rethrown wrapped into a TorqueException.
511 */
512 public static List doSelect(TurbineUserGroupRole obj) throws TorqueException
513 {
514 return doSelect(buildSelectCriteria(obj));
515 }
516
517 /***
518 * Method to do inserts
519 *
520 * @throws TorqueException Any exceptions caught during processing will be
521 * rethrown wrapped into a TorqueException.
522 */
523 public static void doInsert(TurbineUserGroupRole obj) throws TorqueException
524 {
525 doInsert(buildCriteria(obj));
526 obj.setNew(false);
527 obj.setModified(false);
528 }
529
530 /***
531 * @param obj the data object to update in the database.
532 * @throws TorqueException Any exceptions caught during processing will be
533 * rethrown wrapped into a TorqueException.
534 */
535 public static void doUpdate(TurbineUserGroupRole obj) throws TorqueException
536 {
537 doUpdate(buildCriteria(obj));
538 obj.setModified(false);
539 }
540
541 /***
542 * @param obj the data object to delete in the database.
543 * @throws TorqueException Any exceptions caught during processing will be
544 * rethrown wrapped into a TorqueException.
545 */
546 public static void doDelete(TurbineUserGroupRole obj) throws TorqueException
547 {
548 doDelete(buildSelectCriteria(obj));
549 }
550
551 /***
552 * Method to do inserts. This method is to be used during a transaction,
553 * otherwise use the doInsert(TurbineUserGroupRole) method. It will take
554 * care of the connection details internally.
555 *
556 * @param obj the data object to insert into the database.
557 * @param con the connection to use
558 * @throws TorqueException Any exceptions caught during processing will be
559 * rethrown wrapped into a TorqueException.
560 */
561 public static void doInsert(TurbineUserGroupRole obj, Connection con)
562 throws TorqueException
563 {
564 doInsert(buildCriteria(obj), con);
565 obj.setNew(false);
566 obj.setModified(false);
567 }
568
569 /***
570 * Method to do update. This method is to be used during a transaction,
571 * otherwise use the doUpdate(TurbineUserGroupRole) method. It will take
572 * care of the connection details internally.
573 *
574 * @param obj the data object to update in the database.
575 * @param con the connection to use
576 * @throws TorqueException Any exceptions caught during processing will be
577 * rethrown wrapped into a TorqueException.
578 */
579 public static void doUpdate(TurbineUserGroupRole obj, Connection con)
580 throws TorqueException
581 {
582 doUpdate(buildCriteria(obj), con);
583 obj.setModified(false);
584 }
585
586 /***
587 * Method to delete. This method is to be used during a transaction,
588 * otherwise use the doDelete(TurbineUserGroupRole) method. It will take
589 * care of the connection details internally.
590 *
591 * @param obj the data object to delete in the database.
592 * @param con the connection to use
593 * @throws TorqueException Any exceptions caught during processing will be
594 * rethrown wrapped into a TorqueException.
595 */
596 public static void doDelete(TurbineUserGroupRole obj, Connection con)
597 throws TorqueException
598 {
599 doDelete(buildSelectCriteria(obj), con);
600 }
601
602 /***
603 * Method to do deletes.
604 *
605 * @param pk ObjectKey that is used DELETE from database.
606 * @throws TorqueException Any exceptions caught during processing will be
607 * rethrown wrapped into a TorqueException.
608 */
609 public static void doDelete(ObjectKey pk) throws TorqueException
610 {
611 BaseTurbineUserGroupRolePeer
612 .doDelete(pk, (Connection) null);
613 }
614
615 /***
616 * Method to delete. This method is to be used during a transaction,
617 * otherwise use the doDelete(ObjectKey) method. It will take
618 * care of the connection details internally.
619 *
620 * @param pk the primary key for the object to delete in the database.
621 * @param con the connection to use
622 * @throws TorqueException Any exceptions caught during processing will be
623 * rethrown wrapped into a TorqueException.
624 */
625 public static void doDelete(ObjectKey pk, Connection con)
626 throws TorqueException
627 {
628 doDelete(buildCriteria(pk), con);
629 }
630
631 /*** Build a Criteria object from an ObjectKey */
632 public static Criteria buildCriteria( ObjectKey pk )
633 {
634 Criteria criteria = new Criteria();
635 SimpleKey[] keys = (SimpleKey[])pk.getValue();
636 criteria.add(USER_ID, keys[0]);
637 criteria.add(GROUP_ID, keys[1]);
638 criteria.add(ROLE_ID, keys[2]);
639 return criteria;
640 }
641
642 /*** Build a Criteria object from the data object for this peer */
643 public static Criteria buildCriteria( TurbineUserGroupRole obj )
644 {
645 Criteria criteria = new Criteria(DATABASE_NAME);
646 criteria.add(USER_ID, obj.getUserId());
647 criteria.add(GROUP_ID, obj.getGroupId());
648 criteria.add(ROLE_ID, obj.getRoleId());
649 return criteria;
650 }
651
652 /*** Build a Criteria object from the data object for this peer, skipping all binary columns */
653 public static Criteria buildSelectCriteria( TurbineUserGroupRole obj )
654 {
655 Criteria criteria = new Criteria(DATABASE_NAME);
656 criteria.add(USER_ID, obj.getUserId());
657 criteria.add(GROUP_ID, obj.getGroupId());
658 criteria.add(ROLE_ID, obj.getRoleId());
659 return criteria;
660 }
661
662
663
664 /***
665 * Retrieve a single object by pk
666 *
667 * @param pk the primary key
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 TurbineUserGroupRole retrieveByPK(ObjectKey pk)
674 throws TorqueException, NoRowsException, TooManyRowsException
675 {
676 Connection db = null;
677 TurbineUserGroupRole retVal = null;
678 try
679 {
680 db = Torque.getConnection(DATABASE_NAME);
681 retVal = retrieveByPK(pk, db);
682 }
683 finally
684 {
685 Torque.closeConnection(db);
686 }
687 return retVal;
688 }
689
690 /***
691 * Retrieve a single object by pk
692 *
693 * @param pk the primary key
694 * @param con the connection to use
695 * @throws TorqueException Any exceptions caught during processing will be
696 * rethrown wrapped into a TorqueException.
697 * @throws NoRowsException Primary key was not found in database.
698 * @throws TooManyRowsException Primary key was not found in database.
699 */
700 public static TurbineUserGroupRole retrieveByPK(ObjectKey pk, Connection con)
701 throws TorqueException, NoRowsException, TooManyRowsException
702 {
703 Criteria criteria = buildCriteria(pk);
704 List v = doSelect(criteria, con);
705 if (v.size() == 0)
706 {
707 throw new NoRowsException("Failed to select a row.");
708 }
709 else if (v.size() > 1)
710 {
711 throw new TooManyRowsException("Failed to select only one row.");
712 }
713 else
714 {
715 return (TurbineUserGroupRole)v.get(0);
716 }
717 }
718
719 /***
720 * Retrieve a multiple objects by pk
721 *
722 * @param pks List of primary keys
723 * @throws TorqueException Any exceptions caught during processing will be
724 * rethrown wrapped into a TorqueException.
725 */
726 public static List retrieveByPKs(List pks)
727 throws TorqueException
728 {
729 Connection db = null;
730 List retVal = null;
731 try
732 {
733 db = Torque.getConnection(DATABASE_NAME);
734 retVal = retrieveByPKs(pks, db);
735 }
736 finally
737 {
738 Torque.closeConnection(db);
739 }
740 return retVal;
741 }
742
743 /***
744 * Retrieve a multiple objects by pk
745 *
746 * @param pks List of primary keys
747 * @param dbcon the connection to use
748 * @throws TorqueException Any exceptions caught during processing will be
749 * rethrown wrapped into a TorqueException.
750 */
751 public static List retrieveByPKs( List pks, Connection dbcon )
752 throws TorqueException
753 {
754 List objs = null;
755 if (pks == null || pks.size() == 0)
756 {
757 objs = new LinkedList();
758 }
759 else
760 {
761 Criteria criteria = new Criteria();
762 Iterator iter = pks.iterator();
763 while (iter.hasNext())
764 {
765 ObjectKey pk = (ObjectKey)iter.next();
766 SimpleKey[] keys = (SimpleKey[])pk.getValue();
767 Criteria.Criterion c0 = criteria.getNewCriterion(
768 USER_ID, keys[0], Criteria.EQUAL);
769 Criteria.Criterion c1 = criteria.getNewCriterion(
770 GROUP_ID, keys[1], Criteria.EQUAL);
771 c0.and(c1);
772 Criteria.Criterion c2 = criteria.getNewCriterion(
773 ROLE_ID, keys[2], Criteria.EQUAL);
774 c1.and(c2);
775 criteria.or(c0);
776 }
777 objs = doSelect(criteria, dbcon);
778 }
779 return objs;
780 }
781
782
783 /***
784 * retrieve object using using pk values.
785 *
786 * @param user_id int
787 * @param group_id int
788 * @param role_id int
789 */
790 public static TurbineUserGroupRole retrieveByPK(
791 int user_id
792 , int group_id
793 , int role_id
794 ) throws TorqueException
795 {
796 Connection db = null;
797 TurbineUserGroupRole retVal = null;
798 try
799 {
800 db = Torque.getConnection(DATABASE_NAME);
801 retVal = retrieveByPK(
802 user_id
803 , group_id
804 , role_id
805 , db);
806 }
807 finally
808 {
809 Torque.closeConnection(db);
810 }
811 return retVal;
812 }
813
814 /***
815 * retrieve object using using pk values.
816 *
817 * @param user_id int
818 * @param group_id int
819 * @param role_id int
820 * @param con Connection
821 */
822 public static TurbineUserGroupRole retrieveByPK(
823 int user_id
824 , int group_id
825 , int role_id
826 ,Connection con) throws TorqueException
827 {
828
829 Criteria criteria = new Criteria(5);
830 criteria.add(USER_ID, user_id);
831 criteria.add(GROUP_ID, group_id);
832 criteria.add(ROLE_ID, role_id);
833 List v = doSelect(criteria, con);
834 if (v.size() == 1)
835 {
836 return (TurbineUserGroupRole) v.get(0);
837 }
838 else
839 {
840 throw new TorqueException("Failed to select one and only one row.");
841 }
842 }
843
844
845
846
847
848
849
850
851 /***
852 * selects a collection of TurbineUserGroupRole objects pre-filled with their
853 * TurbineUser objects.
854 *
855 * This method is protected by default in order to keep the public
856 * api reasonable. You can provide public methods for those you
857 * actually need in TurbineUserGroupRolePeer.
858 *
859 * @throws TorqueException Any exceptions caught during processing will be
860 * rethrown wrapped into a TorqueException.
861 */
862 protected static List doSelectJoinTurbineUser(Criteria criteria)
863 throws TorqueException
864 {
865 return doSelectJoinTurbineUser(criteria, null);
866 }
867
868 /***
869 * selects a collection of TurbineUserGroupRole objects pre-filled with their
870 * TurbineUser objects.
871 *
872 * This method is protected by default in order to keep the public
873 * api reasonable. You can provide public methods for those you
874 * actually need in TurbineUserGroupRolePeer.
875 *
876 * @throws TorqueException Any exceptions caught during processing will be
877 * rethrown wrapped into a TorqueException.
878 */
879 protected static List doSelectJoinTurbineUser(Criteria criteria, Connection conn)
880 throws TorqueException
881 {
882 setDbName(criteria);
883
884 TurbineUserGroupRolePeer.addSelectColumns(criteria);
885 int offset = numColumns + 1;
886 TurbineUserPeer.addSelectColumns(criteria);
887
888
889 criteria.addJoin(TurbineUserGroupRolePeer.USER_ID,
890 TurbineUserPeer.USER_ID);
891
892 correctBooleans(criteria);
893
894 List rows;
895 if (conn == null)
896 {
897 rows = BasePeer.doSelect(criteria);
898 }
899 else
900 {
901 rows = BasePeer.doSelect(criteria,conn);
902 }
903
904 List results = new ArrayList();
905
906 for (int i = 0; i < rows.size(); i++)
907 {
908 Record row = (Record) rows.get(i);
909
910 Class omClass = TurbineUserGroupRolePeer.getOMClass();
911 TurbineUserGroupRole obj1 = (TurbineUserGroupRole) TurbineUserGroupRolePeer
912 .row2Object(row, 1, omClass);
913 omClass = TurbineUserPeer.getOMClass();
914 TurbineUser obj2 = (TurbineUser)TurbineUserPeer
915 .row2Object(row, offset, omClass);
916
917 boolean newObject = true;
918 for (int j = 0; j < results.size(); j++)
919 {
920 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j);
921 TurbineUser temp_obj2 = (TurbineUser)temp_obj1.getTurbineUser();
922 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
923 {
924 newObject = false;
925 temp_obj2.addTurbineUserGroupRole(obj1);
926 break;
927 }
928 }
929 if (newObject)
930 {
931 obj2.initTurbineUserGroupRoles();
932 obj2.addTurbineUserGroupRole(obj1);
933 }
934 results.add(obj1);
935 }
936 return results;
937 }
938
939
940
941
942 /***
943 * selects a collection of TurbineUserGroupRole objects pre-filled with their
944 * TurbineGroup objects.
945 *
946 * This method is protected by default in order to keep the public
947 * api reasonable. You can provide public methods for those you
948 * actually need in TurbineUserGroupRolePeer.
949 *
950 * @throws TorqueException Any exceptions caught during processing will be
951 * rethrown wrapped into a TorqueException.
952 */
953 protected static List doSelectJoinTurbineGroup(Criteria criteria)
954 throws TorqueException
955 {
956 return doSelectJoinTurbineGroup(criteria, null);
957 }
958
959 /***
960 * selects a collection of TurbineUserGroupRole objects pre-filled with their
961 * TurbineGroup objects.
962 *
963 * This method is protected by default in order to keep the public
964 * api reasonable. You can provide public methods for those you
965 * actually need in TurbineUserGroupRolePeer.
966 *
967 * @throws TorqueException Any exceptions caught during processing will be
968 * rethrown wrapped into a TorqueException.
969 */
970 protected static List doSelectJoinTurbineGroup(Criteria criteria, Connection conn)
971 throws TorqueException
972 {
973 setDbName(criteria);
974
975 TurbineUserGroupRolePeer.addSelectColumns(criteria);
976 int offset = numColumns + 1;
977 TurbineGroupPeer.addSelectColumns(criteria);
978
979
980 criteria.addJoin(TurbineUserGroupRolePeer.GROUP_ID,
981 TurbineGroupPeer.GROUP_ID);
982
983 correctBooleans(criteria);
984
985 List rows;
986 if (conn == null)
987 {
988 rows = BasePeer.doSelect(criteria);
989 }
990 else
991 {
992 rows = BasePeer.doSelect(criteria,conn);
993 }
994
995 List results = new ArrayList();
996
997 for (int i = 0; i < rows.size(); i++)
998 {
999 Record row = (Record) rows.get(i);
1000
1001 Class omClass = TurbineUserGroupRolePeer.getOMClass();
1002 TurbineUserGroupRole obj1 = (TurbineUserGroupRole) TurbineUserGroupRolePeer
1003 .row2Object(row, 1, omClass);
1004 omClass = TurbineGroupPeer.getOMClass();
1005 TurbineGroup obj2 = (TurbineGroup)TurbineGroupPeer
1006 .row2Object(row, offset, omClass);
1007
1008 boolean newObject = true;
1009 for (int j = 0; j < results.size(); j++)
1010 {
1011 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j);
1012 TurbineGroup temp_obj2 = (TurbineGroup)temp_obj1.getTurbineGroup();
1013 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1014 {
1015 newObject = false;
1016 temp_obj2.addTurbineUserGroupRole(obj1);
1017 break;
1018 }
1019 }
1020 if (newObject)
1021 {
1022 obj2.initTurbineUserGroupRoles();
1023 obj2.addTurbineUserGroupRole(obj1);
1024 }
1025 results.add(obj1);
1026 }
1027 return results;
1028 }
1029
1030
1031
1032
1033 /***
1034 * selects a collection of TurbineUserGroupRole objects pre-filled with their
1035 * TurbineRole objects.
1036 *
1037 * This method is protected by default in order to keep the public
1038 * api reasonable. You can provide public methods for those you
1039 * actually need in TurbineUserGroupRolePeer.
1040 *
1041 * @throws TorqueException Any exceptions caught during processing will be
1042 * rethrown wrapped into a TorqueException.
1043 */
1044 protected static List doSelectJoinTurbineRole(Criteria criteria)
1045 throws TorqueException
1046 {
1047 return doSelectJoinTurbineRole(criteria, null);
1048 }
1049
1050 /***
1051 * selects a collection of TurbineUserGroupRole objects pre-filled with their
1052 * TurbineRole objects.
1053 *
1054 * This method is protected by default in order to keep the public
1055 * api reasonable. You can provide public methods for those you
1056 * actually need in TurbineUserGroupRolePeer.
1057 *
1058 * @throws TorqueException Any exceptions caught during processing will be
1059 * rethrown wrapped into a TorqueException.
1060 */
1061 protected static List doSelectJoinTurbineRole(Criteria criteria, Connection conn)
1062 throws TorqueException
1063 {
1064 setDbName(criteria);
1065
1066 TurbineUserGroupRolePeer.addSelectColumns(criteria);
1067 int offset = numColumns + 1;
1068 TurbineRolePeer.addSelectColumns(criteria);
1069
1070
1071 criteria.addJoin(TurbineUserGroupRolePeer.ROLE_ID,
1072 TurbineRolePeer.ROLE_ID);
1073
1074 correctBooleans(criteria);
1075
1076 List rows;
1077 if (conn == null)
1078 {
1079 rows = BasePeer.doSelect(criteria);
1080 }
1081 else
1082 {
1083 rows = BasePeer.doSelect(criteria,conn);
1084 }
1085
1086 List results = new ArrayList();
1087
1088 for (int i = 0; i < rows.size(); i++)
1089 {
1090 Record row = (Record) rows.get(i);
1091
1092 Class omClass = TurbineUserGroupRolePeer.getOMClass();
1093 TurbineUserGroupRole obj1 = (TurbineUserGroupRole) TurbineUserGroupRolePeer
1094 .row2Object(row, 1, omClass);
1095 omClass = TurbineRolePeer.getOMClass();
1096 TurbineRole obj2 = (TurbineRole)TurbineRolePeer
1097 .row2Object(row, offset, omClass);
1098
1099 boolean newObject = true;
1100 for (int j = 0; j < results.size(); j++)
1101 {
1102 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j);
1103 TurbineRole temp_obj2 = (TurbineRole)temp_obj1.getTurbineRole();
1104 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1105 {
1106 newObject = false;
1107 temp_obj2.addTurbineUserGroupRole(obj1);
1108 break;
1109 }
1110 }
1111 if (newObject)
1112 {
1113 obj2.initTurbineUserGroupRoles();
1114 obj2.addTurbineUserGroupRole(obj1);
1115 }
1116 results.add(obj1);
1117 }
1118 return results;
1119 }
1120
1121
1122
1123
1124
1125
1126
1127 /***
1128 * selects a collection of TurbineUserGroupRole objects pre-filled with
1129 * all related objects.
1130 *
1131 * This method is protected by default in order to keep the public
1132 * api reasonable. You can provide public methods for those you
1133 * actually need in TurbineUserGroupRolePeer.
1134 *
1135 * @throws TorqueException Any exceptions caught during processing will be
1136 * rethrown wrapped into a TorqueException.
1137 */
1138 protected static List doSelectJoinAllExceptTurbineUser(Criteria criteria)
1139 throws TorqueException
1140 {
1141 return doSelectJoinAllExceptTurbineUser(criteria, null);
1142 }
1143
1144 /***
1145 * selects a collection of TurbineUserGroupRole objects pre-filled with
1146 * all related objects.
1147 *
1148 * This method is protected by default in order to keep the public
1149 * api reasonable. You can provide public methods for those you
1150 * actually need in TurbineUserGroupRolePeer.
1151 *
1152 * @throws TorqueException Any exceptions caught during processing will be
1153 * rethrown wrapped into a TorqueException.
1154 */
1155 protected static List doSelectJoinAllExceptTurbineUser(Criteria criteria, Connection conn)
1156 throws TorqueException
1157 {
1158 setDbName(criteria);
1159
1160 addSelectColumns(criteria);
1161 int offset2 = numColumns + 1;
1162
1163
1164 TurbineGroupPeer.addSelectColumns(criteria);
1165 criteria.addJoin(TurbineUserGroupRolePeer.GROUP_ID, TurbineGroupPeer.GROUP_ID);
1166 int offset3 = offset2 + TurbineGroupPeer.numColumns;
1167
1168 TurbineRolePeer.addSelectColumns(criteria);
1169 criteria.addJoin(TurbineUserGroupRolePeer.ROLE_ID, TurbineRolePeer.ROLE_ID);
1170
1171 correctBooleans(criteria);
1172
1173 List rows;
1174 if (conn == null)
1175 {
1176 rows = BasePeer.doSelect(criteria);
1177 }
1178 else
1179 {
1180 rows = BasePeer.doSelect(criteria,conn);
1181 }
1182
1183 List results = new ArrayList();
1184
1185 for (int i = 0; i < rows.size(); i++)
1186 {
1187 Record row = (Record)rows.get(i);
1188
1189 Class omClass = TurbineUserGroupRolePeer.getOMClass();
1190 TurbineUserGroupRole obj1 = (TurbineUserGroupRole)TurbineUserGroupRolePeer
1191 .row2Object(row, 1, omClass);
1192
1193
1194
1195
1196
1197 omClass = TurbineGroupPeer.getOMClass();
1198 TurbineGroup obj2 = (TurbineGroup)TurbineGroupPeer
1199 .row2Object( row, offset2, omClass);
1200
1201 boolean newObject = true;
1202 for (int j = 0; j < results.size(); j++)
1203 {
1204 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j);
1205 TurbineGroup temp_obj2 = (TurbineGroup)temp_obj1.getTurbineGroup();
1206 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1207 {
1208 newObject = false;
1209 temp_obj2.addTurbineUserGroupRole(obj1);
1210 break;
1211 }
1212 }
1213 if (newObject)
1214 {
1215 obj2.initTurbineUserGroupRoles();
1216 obj2.addTurbineUserGroupRole(obj1);
1217 }
1218
1219
1220
1221
1222 omClass = TurbineRolePeer.getOMClass();
1223 TurbineRole obj3 = (TurbineRole)TurbineRolePeer
1224 .row2Object( row, offset3, omClass);
1225
1226 newObject = true;
1227 for (int j = 0; j < results.size(); j++)
1228 {
1229 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j);
1230 TurbineRole temp_obj3 = (TurbineRole)temp_obj1.getTurbineRole();
1231 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1232 {
1233 newObject = false;
1234 temp_obj3.addTurbineUserGroupRole(obj1);
1235 break;
1236 }
1237 }
1238 if (newObject)
1239 {
1240 obj3.initTurbineUserGroupRoles();
1241 obj3.addTurbineUserGroupRole(obj1);
1242 }
1243 results.add(obj1);
1244 }
1245 return results;
1246 }
1247
1248
1249
1250
1251 /***
1252 * selects a collection of TurbineUserGroupRole objects pre-filled with
1253 * all related objects.
1254 *
1255 * This method is protected by default in order to keep the public
1256 * api reasonable. You can provide public methods for those you
1257 * actually need in TurbineUserGroupRolePeer.
1258 *
1259 * @throws TorqueException Any exceptions caught during processing will be
1260 * rethrown wrapped into a TorqueException.
1261 */
1262 protected static List doSelectJoinAllExceptTurbineGroup(Criteria criteria)
1263 throws TorqueException
1264 {
1265 return doSelectJoinAllExceptTurbineGroup(criteria, null);
1266 }
1267
1268 /***
1269 * selects a collection of TurbineUserGroupRole objects pre-filled with
1270 * all related objects.
1271 *
1272 * This method is protected by default in order to keep the public
1273 * api reasonable. You can provide public methods for those you
1274 * actually need in TurbineUserGroupRolePeer.
1275 *
1276 * @throws TorqueException Any exceptions caught during processing will be
1277 * rethrown wrapped into a TorqueException.
1278 */
1279 protected static List doSelectJoinAllExceptTurbineGroup(Criteria criteria, Connection conn)
1280 throws TorqueException
1281 {
1282 setDbName(criteria);
1283
1284 addSelectColumns(criteria);
1285 int offset2 = numColumns + 1;
1286
1287 TurbineUserPeer.addSelectColumns(criteria);
1288 criteria.addJoin(TurbineUserGroupRolePeer.USER_ID, TurbineUserPeer.USER_ID);
1289 int offset3 = offset2 + TurbineUserPeer.numColumns;
1290
1291
1292 TurbineRolePeer.addSelectColumns(criteria);
1293 criteria.addJoin(TurbineUserGroupRolePeer.ROLE_ID, TurbineRolePeer.ROLE_ID);
1294
1295 correctBooleans(criteria);
1296
1297 List rows;
1298 if (conn == null)
1299 {
1300 rows = BasePeer.doSelect(criteria);
1301 }
1302 else
1303 {
1304 rows = BasePeer.doSelect(criteria,conn);
1305 }
1306
1307 List results = new ArrayList();
1308
1309 for (int i = 0; i < rows.size(); i++)
1310 {
1311 Record row = (Record)rows.get(i);
1312
1313 Class omClass = TurbineUserGroupRolePeer.getOMClass();
1314 TurbineUserGroupRole obj1 = (TurbineUserGroupRole)TurbineUserGroupRolePeer
1315 .row2Object(row, 1, omClass);
1316
1317
1318
1319
1320 omClass = TurbineUserPeer.getOMClass();
1321 TurbineUser obj2 = (TurbineUser)TurbineUserPeer
1322 .row2Object( row, offset2, omClass);
1323
1324 boolean newObject = true;
1325 for (int j = 0; j < results.size(); j++)
1326 {
1327 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j);
1328 TurbineUser temp_obj2 = (TurbineUser)temp_obj1.getTurbineUser();
1329 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1330 {
1331 newObject = false;
1332 temp_obj2.addTurbineUserGroupRole(obj1);
1333 break;
1334 }
1335 }
1336 if (newObject)
1337 {
1338 obj2.initTurbineUserGroupRoles();
1339 obj2.addTurbineUserGroupRole(obj1);
1340 }
1341
1342
1343
1344
1345
1346 omClass = TurbineRolePeer.getOMClass();
1347 TurbineRole obj3 = (TurbineRole)TurbineRolePeer
1348 .row2Object( row, offset3, omClass);
1349
1350 newObject = true;
1351 for (int j = 0; j < results.size(); j++)
1352 {
1353 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j);
1354 TurbineRole temp_obj3 = (TurbineRole)temp_obj1.getTurbineRole();
1355 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1356 {
1357 newObject = false;
1358 temp_obj3.addTurbineUserGroupRole(obj1);
1359 break;
1360 }
1361 }
1362 if (newObject)
1363 {
1364 obj3.initTurbineUserGroupRoles();
1365 obj3.addTurbineUserGroupRole(obj1);
1366 }
1367 results.add(obj1);
1368 }
1369 return results;
1370 }
1371
1372
1373
1374
1375 /***
1376 * selects a collection of TurbineUserGroupRole objects pre-filled with
1377 * all related objects.
1378 *
1379 * This method is protected by default in order to keep the public
1380 * api reasonable. You can provide public methods for those you
1381 * actually need in TurbineUserGroupRolePeer.
1382 *
1383 * @throws TorqueException Any exceptions caught during processing will be
1384 * rethrown wrapped into a TorqueException.
1385 */
1386 protected static List doSelectJoinAllExceptTurbineRole(Criteria criteria)
1387 throws TorqueException
1388 {
1389 return doSelectJoinAllExceptTurbineRole(criteria, null);
1390 }
1391
1392 /***
1393 * selects a collection of TurbineUserGroupRole objects pre-filled with
1394 * all related objects.
1395 *
1396 * This method is protected by default in order to keep the public
1397 * api reasonable. You can provide public methods for those you
1398 * actually need in TurbineUserGroupRolePeer.
1399 *
1400 * @throws TorqueException Any exceptions caught during processing will be
1401 * rethrown wrapped into a TorqueException.
1402 */
1403 protected static List doSelectJoinAllExceptTurbineRole(Criteria criteria, Connection conn)
1404 throws TorqueException
1405 {
1406 setDbName(criteria);
1407
1408 addSelectColumns(criteria);
1409 int offset2 = numColumns + 1;
1410
1411 TurbineUserPeer.addSelectColumns(criteria);
1412 criteria.addJoin(TurbineUserGroupRolePeer.USER_ID, TurbineUserPeer.USER_ID);
1413 int offset3 = offset2 + TurbineUserPeer.numColumns;
1414
1415 TurbineGroupPeer.addSelectColumns(criteria);
1416 criteria.addJoin(TurbineUserGroupRolePeer.GROUP_ID, TurbineGroupPeer.GROUP_ID);
1417
1418
1419 correctBooleans(criteria);
1420
1421 List rows;
1422 if (conn == null)
1423 {
1424 rows = BasePeer.doSelect(criteria);
1425 }
1426 else
1427 {
1428 rows = BasePeer.doSelect(criteria,conn);
1429 }
1430
1431 List results = new ArrayList();
1432
1433 for (int i = 0; i < rows.size(); i++)
1434 {
1435 Record row = (Record)rows.get(i);
1436
1437 Class omClass = TurbineUserGroupRolePeer.getOMClass();
1438 TurbineUserGroupRole obj1 = (TurbineUserGroupRole)TurbineUserGroupRolePeer
1439 .row2Object(row, 1, omClass);
1440
1441
1442
1443
1444 omClass = TurbineUserPeer.getOMClass();
1445 TurbineUser obj2 = (TurbineUser)TurbineUserPeer
1446 .row2Object( row, offset2, omClass);
1447
1448 boolean newObject = true;
1449 for (int j = 0; j < results.size(); j++)
1450 {
1451 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j);
1452 TurbineUser temp_obj2 = (TurbineUser)temp_obj1.getTurbineUser();
1453 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1454 {
1455 newObject = false;
1456 temp_obj2.addTurbineUserGroupRole(obj1);
1457 break;
1458 }
1459 }
1460 if (newObject)
1461 {
1462 obj2.initTurbineUserGroupRoles();
1463 obj2.addTurbineUserGroupRole(obj1);
1464 }
1465
1466
1467
1468
1469 omClass = TurbineGroupPeer.getOMClass();
1470 TurbineGroup obj3 = (TurbineGroup)TurbineGroupPeer
1471 .row2Object( row, offset3, omClass);
1472
1473 newObject = true;
1474 for (int j = 0; j < results.size(); j++)
1475 {
1476 TurbineUserGroupRole temp_obj1 = (TurbineUserGroupRole)results.get(j);
1477 TurbineGroup temp_obj3 = (TurbineGroup)temp_obj1.getTurbineGroup();
1478 if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1479 {
1480 newObject = false;
1481 temp_obj3.addTurbineUserGroupRole(obj1);
1482 break;
1483 }
1484 }
1485 if (newObject)
1486 {
1487 obj3.initTurbineUserGroupRoles();
1488 obj3.addTurbineUserGroupRole(obj1);
1489 }
1490
1491 results.add(obj1);
1492 }
1493 return results;
1494 }
1495
1496
1497 /***
1498 * Returns the TableMap related to this peer. This method is not
1499 * needed for general use but a specific application could have a need.
1500 *
1501 * @throws TorqueException Any exceptions caught during processing will be
1502 * rethrown wrapped into a TorqueException.
1503 */
1504 protected static TableMap getTableMap()
1505 throws TorqueException
1506 {
1507 return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME);
1508 }
1509
1510 private static void setDbName(Criteria crit)
1511 {
1512
1513
1514
1515 if (crit.getDbName() == Torque.getDefaultDB())
1516 {
1517 crit.setDbName(DATABASE_NAME);
1518 }
1519 }
1520 }