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.TorqueRuntimeException;
17 import org.apache.torque.map.MapBuilder;
18 import org.apache.torque.map.TableMap;
19 import org.apache.torque.om.DateKey;
20 import org.apache.torque.om.NumberKey;
21 import org.apache.torque.om.StringKey;
22 import org.apache.torque.om.ObjectKey;
23 import org.apache.torque.om.SimpleKey;
24 import org.apache.torque.util.BasePeer;
25 import org.apache.torque.util.Criteria;
26
27 import com.workingdogs.village.DataSetException;
28 import com.workingdogs.village.QueryDataSet;
29 import com.workingdogs.village.Record;
30
31
32 import org.apache.turbine.services.security.torque.om.map.*;
33
34
35
36
37 /***
38 * This class was autogenerated by Torque on:
39 *
40 * [Tue Nov 04 15:53:51 CET 2008]
41 *
42 */
43 public abstract class BaseTurbineRolePermissionPeer
44 extends BasePeer
45 {
46 /*** Serial version */
47 private static final long serialVersionUID = 1225810431540L;
48
49
50 /*** the default database name for this class */
51 public static final String DATABASE_NAME;
52
53 /*** the table name for this class */
54 public static final String TABLE_NAME;
55
56 /***
57 * @return the map builder for this peer
58 * @throws TorqueException Any exceptions caught during processing will be
59 * rethrown wrapped into a TorqueException.
60 * @deprecated Torque.getMapBuilder(TurbineRolePermissionMapBuilder.CLASS_NAME) instead
61 */
62 public static MapBuilder getMapBuilder()
63 throws TorqueException
64 {
65 return Torque.getMapBuilder(TurbineRolePermissionMapBuilder.CLASS_NAME);
66 }
67
68 /*** the column name for the ROLE_ID field */
69 public static final String ROLE_ID;
70 /*** the column name for the PERMISSION_ID field */
71 public static final String PERMISSION_ID;
72
73 static
74 {
75 DATABASE_NAME = "default";
76 TABLE_NAME = "TURBINE_ROLE_PERMISSION";
77
78 ROLE_ID = "TURBINE_ROLE_PERMISSION.ROLE_ID";
79 PERMISSION_ID = "TURBINE_ROLE_PERMISSION.PERMISSION_ID";
80 if (Torque.isInit())
81 {
82 try
83 {
84 Torque.getMapBuilder(TurbineRolePermissionMapBuilder.CLASS_NAME);
85 }
86 catch (TorqueException e)
87 {
88 log.error("Could not initialize Peer", e);
89 throw new TorqueRuntimeException(e);
90 }
91 }
92 else
93 {
94 Torque.registerMapBuilder(TurbineRolePermissionMapBuilder.CLASS_NAME);
95 }
96 }
97
98 /*** number of columns for this peer */
99 public static final int numColumns = 2;
100
101 /*** A class that can be returned by this peer. */
102 protected static final String CLASSNAME_DEFAULT =
103 "org.apache.turbine.services.security.torque.om.TurbineRolePermission";
104
105 /*** A class that can be returned by this peer. */
106 protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT);
107
108 /***
109 * Class object initialization method.
110 *
111 * @param className name of the class to initialize
112 * @return the initialized class
113 */
114 private static Class initClass(String className)
115 {
116 Class c = null;
117 try
118 {
119 c = Class.forName(className);
120 }
121 catch (Throwable t)
122 {
123 log.error("A FATAL ERROR has occurred which should not "
124 + "have happened under any circumstance. Please notify "
125 + "the Torque developers <torque-dev@db.apache.org> "
126 + "and give as many details as possible (including the error "
127 + "stack trace).", t);
128
129
130 if (t instanceof Error)
131 {
132 throw (Error) t.fillInStackTrace();
133 }
134 }
135 return c;
136 }
137
138 /***
139 * Get the list of objects for a ResultSet. Please not that your
140 * resultset MUST return columns in the right order. You can use
141 * getFieldNames() in BaseObject to get the correct sequence.
142 *
143 * @param results the ResultSet
144 * @return the list of objects
145 * @throws TorqueException Any exceptions caught during processing will be
146 * rethrown wrapped into a TorqueException.
147 */
148 public static List resultSet2Objects(java.sql.ResultSet results)
149 throws TorqueException
150 {
151 try
152 {
153 QueryDataSet qds = null;
154 List rows = null;
155 try
156 {
157 qds = new QueryDataSet(results);
158 rows = getSelectResults(qds);
159 }
160 finally
161 {
162 if (qds != null)
163 {
164 qds.close();
165 }
166 }
167
168 return populateObjects(rows);
169 }
170 catch (SQLException e)
171 {
172 throw new TorqueException(e);
173 }
174 catch (DataSetException e)
175 {
176 throw new TorqueException(e);
177 }
178 }
179
180
181
182 /***
183 * Method to do inserts.
184 *
185 * @param criteria object used to create the INSERT statement.
186 * @throws TorqueException Any exceptions caught during processing will be
187 * rethrown wrapped into a TorqueException.
188 */
189 public static ObjectKey doInsert(Criteria criteria)
190 throws TorqueException
191 {
192 return BaseTurbineRolePermissionPeer
193 .doInsert(criteria, (Connection) null);
194 }
195
196 /***
197 * Method to do inserts. This method is to be used during a transaction,
198 * otherwise use the doInsert(Criteria) method. It will take care of
199 * the connection details internally.
200 *
201 * @param criteria object used to create the INSERT statement.
202 * @param con the connection to use
203 * @throws TorqueException Any exceptions caught during processing will be
204 * rethrown wrapped into a TorqueException.
205 */
206 public static ObjectKey doInsert(Criteria criteria, Connection con)
207 throws TorqueException
208 {
209 correctBooleans(criteria);
210
211 setDbName(criteria);
212
213 if (con == null)
214 {
215 return BasePeer.doInsert(criteria);
216 }
217 else
218 {
219 return BasePeer.doInsert(criteria, con);
220 }
221 }
222
223 /***
224 * Add all the columns needed to create a new object.
225 *
226 * @param criteria object containing the columns to add.
227 * @throws TorqueException Any exceptions caught during processing will be
228 * rethrown wrapped into a TorqueException.
229 */
230 public static void addSelectColumns(Criteria criteria)
231 throws TorqueException
232 {
233 criteria.addSelectColumn(ROLE_ID);
234 criteria.addSelectColumn(PERMISSION_ID);
235 }
236
237 /***
238 * changes the boolean values in the criteria to the appropriate type,
239 * whenever a booleanchar or booleanint column is involved.
240 * This enables the user to create criteria using Boolean values
241 * for booleanchar or booleanint columns
242 * @param criteria the criteria in which the boolean values should be corrected
243 * @throws TorqueException if the database map for the criteria cannot be
244 obtained.
245 */
246 public static void correctBooleans(Criteria criteria) throws TorqueException
247 {
248 correctBooleans(criteria, getTableMap());
249 }
250
251 /***
252 * Create a new object of type cls from a resultset row starting
253 * from a specified offset. This is done so that you can select
254 * other rows than just those needed for this object. You may
255 * for example want to create two objects from the same row.
256 *
257 * @throws TorqueException Any exceptions caught during processing will be
258 * rethrown wrapped into a TorqueException.
259 */
260 public static TurbineRolePermission row2Object(Record row,
261 int offset,
262 Class cls)
263 throws TorqueException
264 {
265 try
266 {
267 TurbineRolePermission obj = (TurbineRolePermission) cls.newInstance();
268 TurbineRolePermissionPeer.populateObject(row, offset, obj);
269 obj.setModified(false);
270 obj.setNew(false);
271
272 return obj;
273 }
274 catch (InstantiationException e)
275 {
276 throw new TorqueException(e);
277 }
278 catch (IllegalAccessException e)
279 {
280 throw new TorqueException(e);
281 }
282 }
283
284 /***
285 * Populates an object from a resultset row starting
286 * from a specified offset. This is done so that you can select
287 * other rows than just those needed for this object. You may
288 * for example want to create two objects from the same row.
289 *
290 * @throws TorqueException Any exceptions caught during processing will be
291 * rethrown wrapped into a TorqueException.
292 */
293 public static void populateObject(Record row,
294 int offset,
295 TurbineRolePermission obj)
296 throws TorqueException
297 {
298 try
299 {
300 obj.setRoleId(row.getValue(offset + 0).asInt());
301 obj.setPermissionId(row.getValue(offset + 1).asInt());
302 }
303 catch (DataSetException e)
304 {
305 throw new TorqueException(e);
306 }
307 }
308
309 /***
310 * Method to do selects.
311 *
312 * @param criteria object used to create the SELECT statement.
313 * @return List of selected Objects
314 * @throws TorqueException Any exceptions caught during processing will be
315 * rethrown wrapped into a TorqueException.
316 */
317 public static List doSelect(Criteria criteria) throws TorqueException
318 {
319 return populateObjects(doSelectVillageRecords(criteria));
320 }
321
322 /***
323 * Method to do selects within a transaction.
324 *
325 * @param criteria object used to create the SELECT statement.
326 * @param con the connection to use
327 * @return List of selected Objects
328 * @throws TorqueException Any exceptions caught during processing will be
329 * rethrown wrapped into a TorqueException.
330 */
331 public static List doSelect(Criteria criteria, Connection con)
332 throws TorqueException
333 {
334 return populateObjects(doSelectVillageRecords(criteria, con));
335 }
336
337 /***
338 * Grabs the raw Village records to be formed into objects.
339 * This method handles connections internally. The Record objects
340 * returned by this method should be considered readonly. Do not
341 * alter the data and call save(), your results may vary, but are
342 * certainly likely to result in hard to track MT bugs.
343 *
344 * @throws TorqueException Any exceptions caught during processing will be
345 * rethrown wrapped into a TorqueException.
346 */
347 public static List doSelectVillageRecords(Criteria criteria)
348 throws TorqueException
349 {
350 return BaseTurbineRolePermissionPeer
351 .doSelectVillageRecords(criteria, (Connection) null);
352 }
353
354 /***
355 * Grabs the raw Village records to be formed into objects.
356 * This method should be used for transactions
357 *
358 * @param criteria object used to create the SELECT statement.
359 * @param con the connection to use
360 * @throws TorqueException Any exceptions caught during processing will be
361 * rethrown wrapped into a TorqueException.
362 */
363 public static List doSelectVillageRecords(Criteria criteria, Connection con)
364 throws TorqueException
365 {
366 if (criteria.getSelectColumns().size() == 0)
367 {
368 addSelectColumns(criteria);
369 }
370 correctBooleans(criteria);
371
372 setDbName(criteria);
373
374
375
376 if (con == null)
377 {
378 return BasePeer.doSelect(criteria);
379 }
380 else
381 {
382 return BasePeer.doSelect(criteria, con);
383 }
384 }
385
386 /***
387 * The returned List will contain objects of the default type or
388 * objects that inherit from the default.
389 *
390 * @throws TorqueException Any exceptions caught during processing will be
391 * rethrown wrapped into a TorqueException.
392 */
393 public static List populateObjects(List records)
394 throws TorqueException
395 {
396 List results = new ArrayList(records.size());
397
398
399 for (int i = 0; i < records.size(); i++)
400 {
401 Record row = (Record) records.get(i);
402 results.add(TurbineRolePermissionPeer.row2Object(row, 1,
403 TurbineRolePermissionPeer.getOMClass()));
404 }
405 return results;
406 }
407
408
409 /***
410 * The class that the Peer will make instances of.
411 * If the BO is abstract then you must implement this method
412 * in the BO.
413 *
414 * @throws TorqueException Any exceptions caught during processing will be
415 * rethrown wrapped into a TorqueException.
416 */
417 public static Class getOMClass()
418 throws TorqueException
419 {
420 return CLASS_DEFAULT;
421 }
422
423 /***
424 * Method to do updates.
425 *
426 * @param criteria object containing data that is used to create the UPDATE
427 * statement.
428 * @throws TorqueException Any exceptions caught during processing will be
429 * rethrown wrapped into a TorqueException.
430 */
431 public static void doUpdate(Criteria criteria) throws TorqueException
432 {
433 BaseTurbineRolePermissionPeer
434 .doUpdate(criteria, (Connection) null);
435 }
436
437 /***
438 * Method to do updates. This method is to be used during a transaction,
439 * otherwise use the doUpdate(Criteria) method. It will take care of
440 * the connection details internally.
441 *
442 * @param criteria object containing data that is used to create the UPDATE
443 * statement.
444 * @param con the connection to use
445 * @throws TorqueException Any exceptions caught during processing will be
446 * rethrown wrapped into a TorqueException.
447 */
448 public static void doUpdate(Criteria criteria, Connection con)
449 throws TorqueException
450 {
451 Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
452 correctBooleans(criteria);
453
454
455 selectCriteria.put(ROLE_ID, criteria.remove(ROLE_ID));
456
457 selectCriteria.put(PERMISSION_ID, criteria.remove(PERMISSION_ID));
458
459 setDbName(criteria);
460
461 if (con == null)
462 {
463 BasePeer.doUpdate(selectCriteria, criteria);
464 }
465 else
466 {
467 BasePeer.doUpdate(selectCriteria, criteria, con);
468 }
469 }
470
471 /***
472 * Method to do deletes.
473 *
474 * @param criteria object containing data that is used DELETE from database.
475 * @throws TorqueException Any exceptions caught during processing will be
476 * rethrown wrapped into a TorqueException.
477 */
478 public static void doDelete(Criteria criteria) throws TorqueException
479 {
480 TurbineRolePermissionPeer
481 .doDelete(criteria, (Connection) null);
482 }
483
484 /***
485 * Method to do deletes. This method is to be used during a transaction,
486 * otherwise use the doDelete(Criteria) method. It will take care of
487 * the connection details internally.
488 *
489 * @param criteria object containing data that is used DELETE from database.
490 * @param con the connection to use
491 * @throws TorqueException Any exceptions caught during processing will be
492 * rethrown wrapped into a TorqueException.
493 */
494 public static void doDelete(Criteria criteria, Connection con)
495 throws TorqueException
496 {
497 correctBooleans(criteria);
498
499 setDbName(criteria);
500
501 if (con == null)
502 {
503 BasePeer.doDelete(criteria, TABLE_NAME);
504 }
505 else
506 {
507 BasePeer.doDelete(criteria, TABLE_NAME, con);
508 }
509 }
510
511 /***
512 * Method to do selects
513 *
514 * @throws TorqueException Any exceptions caught during processing will be
515 * rethrown wrapped into a TorqueException.
516 */
517 public static List doSelect(TurbineRolePermission obj) throws TorqueException
518 {
519 return doSelect(buildSelectCriteria(obj));
520 }
521
522 /***
523 * Method to do inserts
524 *
525 * @throws TorqueException Any exceptions caught during processing will be
526 * rethrown wrapped into a TorqueException.
527 */
528 public static void doInsert(TurbineRolePermission obj) throws TorqueException
529 {
530 doInsert(buildCriteria(obj));
531 obj.setNew(false);
532 obj.setModified(false);
533 }
534
535 /***
536 * @param obj the data object to update in the database.
537 * @throws TorqueException Any exceptions caught during processing will be
538 * rethrown wrapped into a TorqueException.
539 */
540 public static void doUpdate(TurbineRolePermission obj) throws TorqueException
541 {
542 doUpdate(buildCriteria(obj));
543 obj.setModified(false);
544 }
545
546 /***
547 * @param obj the data object to delete in the database.
548 * @throws TorqueException Any exceptions caught during processing will be
549 * rethrown wrapped into a TorqueException.
550 */
551 public static void doDelete(TurbineRolePermission obj) throws TorqueException
552 {
553 doDelete(buildSelectCriteria(obj));
554 }
555
556 /***
557 * Method to do inserts. This method is to be used during a transaction,
558 * otherwise use the doInsert(TurbineRolePermission) method. It will take
559 * care of the connection details internally.
560 *
561 * @param obj the data object to insert into the database.
562 * @param con the connection to use
563 * @throws TorqueException Any exceptions caught during processing will be
564 * rethrown wrapped into a TorqueException.
565 */
566 public static void doInsert(TurbineRolePermission obj, Connection con)
567 throws TorqueException
568 {
569 doInsert(buildCriteria(obj), con);
570 obj.setNew(false);
571 obj.setModified(false);
572 }
573
574 /***
575 * Method to do update. This method is to be used during a transaction,
576 * otherwise use the doUpdate(TurbineRolePermission) method. It will take
577 * care of the connection details internally.
578 *
579 * @param obj the data object to update in the database.
580 * @param con the connection to use
581 * @throws TorqueException Any exceptions caught during processing will be
582 * rethrown wrapped into a TorqueException.
583 */
584 public static void doUpdate(TurbineRolePermission obj, Connection con)
585 throws TorqueException
586 {
587 doUpdate(buildCriteria(obj), con);
588 obj.setModified(false);
589 }
590
591 /***
592 * Method to delete. This method is to be used during a transaction,
593 * otherwise use the doDelete(TurbineRolePermission) method. It will take
594 * care of the connection details internally.
595 *
596 * @param obj the data object to delete in the database.
597 * @param con the connection to use
598 * @throws TorqueException Any exceptions caught during processing will be
599 * rethrown wrapped into a TorqueException.
600 */
601 public static void doDelete(TurbineRolePermission obj, Connection con)
602 throws TorqueException
603 {
604 doDelete(buildSelectCriteria(obj), con);
605 }
606
607 /***
608 * Method to do deletes.
609 *
610 * @param pk ObjectKey that is used DELETE from database.
611 * @throws TorqueException Any exceptions caught during processing will be
612 * rethrown wrapped into a TorqueException.
613 */
614 public static void doDelete(ObjectKey pk) throws TorqueException
615 {
616 BaseTurbineRolePermissionPeer
617 .doDelete(pk, (Connection) null);
618 }
619
620 /***
621 * Method to delete. This method is to be used during a transaction,
622 * otherwise use the doDelete(ObjectKey) method. It will take
623 * care of the connection details internally.
624 *
625 * @param pk the primary key for the object to delete in the database.
626 * @param con the connection to use
627 * @throws TorqueException Any exceptions caught during processing will be
628 * rethrown wrapped into a TorqueException.
629 */
630 public static void doDelete(ObjectKey pk, Connection con)
631 throws TorqueException
632 {
633 doDelete(buildCriteria(pk), con);
634 }
635
636 /*** Build a Criteria object from an ObjectKey */
637 public static Criteria buildCriteria( ObjectKey pk )
638 {
639 Criteria criteria = new Criteria();
640 SimpleKey[] keys = (SimpleKey[])pk.getValue();
641 criteria.add(ROLE_ID, keys[0]);
642 criteria.add(PERMISSION_ID, keys[1]);
643 return criteria;
644 }
645
646 /*** Build a Criteria object from the data object for this peer */
647 public static Criteria buildCriteria( TurbineRolePermission obj )
648 {
649 Criteria criteria = new Criteria(DATABASE_NAME);
650 criteria.add(ROLE_ID, obj.getRoleId());
651 criteria.add(PERMISSION_ID, obj.getPermissionId());
652 return criteria;
653 }
654
655 /*** Build a Criteria object from the data object for this peer, skipping all binary columns */
656 public static Criteria buildSelectCriteria( TurbineRolePermission obj )
657 {
658 Criteria criteria = new Criteria(DATABASE_NAME);
659 criteria.add(ROLE_ID, obj.getRoleId());
660 criteria.add(PERMISSION_ID, obj.getPermissionId());
661 return criteria;
662 }
663
664
665
666 /***
667 * Retrieve a single object by pk
668 *
669 * @param pk the primary key
670 * @throws TorqueException Any exceptions caught during processing will be
671 * rethrown wrapped into a TorqueException.
672 * @throws NoRowsException Primary key was not found in database.
673 * @throws TooManyRowsException Primary key was not found in database.
674 */
675 public static TurbineRolePermission retrieveByPK(ObjectKey pk)
676 throws TorqueException, NoRowsException, TooManyRowsException
677 {
678 Connection db = null;
679 TurbineRolePermission retVal = null;
680 try
681 {
682 db = Torque.getConnection(DATABASE_NAME);
683 retVal = retrieveByPK(pk, db);
684 }
685 finally
686 {
687 Torque.closeConnection(db);
688 }
689 return retVal;
690 }
691
692 /***
693 * Retrieve a single object by pk
694 *
695 * @param pk the primary key
696 * @param con the connection to use
697 * @throws TorqueException Any exceptions caught during processing will be
698 * rethrown wrapped into a TorqueException.
699 * @throws NoRowsException Primary key was not found in database.
700 * @throws TooManyRowsException Primary key was not found in database.
701 */
702 public static TurbineRolePermission retrieveByPK(ObjectKey pk, Connection con)
703 throws TorqueException, NoRowsException, TooManyRowsException
704 {
705 Criteria criteria = buildCriteria(pk);
706 List v = doSelect(criteria, con);
707 if (v.size() == 0)
708 {
709 throw new NoRowsException("Failed to select a row.");
710 }
711 else if (v.size() > 1)
712 {
713 throw new TooManyRowsException("Failed to select only one row.");
714 }
715 else
716 {
717 return (TurbineRolePermission)v.get(0);
718 }
719 }
720
721 /***
722 * Retrieve a multiple objects by pk
723 *
724 * @param pks List of primary keys
725 * @throws TorqueException Any exceptions caught during processing will be
726 * rethrown wrapped into a TorqueException.
727 */
728 public static List retrieveByPKs(List pks)
729 throws TorqueException
730 {
731 Connection db = null;
732 List retVal = null;
733 try
734 {
735 db = Torque.getConnection(DATABASE_NAME);
736 retVal = retrieveByPKs(pks, db);
737 }
738 finally
739 {
740 Torque.closeConnection(db);
741 }
742 return retVal;
743 }
744
745 /***
746 * Retrieve a multiple objects by pk
747 *
748 * @param pks List of primary keys
749 * @param dbcon the connection to use
750 * @throws TorqueException Any exceptions caught during processing will be
751 * rethrown wrapped into a TorqueException.
752 */
753 public static List retrieveByPKs( List pks, Connection dbcon )
754 throws TorqueException
755 {
756 List objs = null;
757 if (pks == null || pks.size() == 0)
758 {
759 objs = new LinkedList();
760 }
761 else
762 {
763 Criteria criteria = new Criteria();
764 Iterator iter = pks.iterator();
765 while (iter.hasNext())
766 {
767 ObjectKey pk = (ObjectKey) iter.next();
768 SimpleKey[] keys = (SimpleKey[])pk.getValue();
769 Criteria.Criterion c0 = criteria.getNewCriterion(
770 ROLE_ID, keys[0], Criteria.EQUAL);
771 Criteria.Criterion c1 = criteria.getNewCriterion(
772 PERMISSION_ID, keys[1], Criteria.EQUAL);
773 c0.and(c1);
774 criteria.or(c0);
775 }
776 objs = doSelect(criteria, dbcon);
777 }
778 return objs;
779 }
780
781
782 /***
783 * retrieve object using using pk values.
784 *
785 * @param roleId int
786 * @param permissionId int
787 */
788 public static TurbineRolePermission retrieveByPK(
789 int roleId
790 , int permissionId
791 ) throws TorqueException
792 {
793 Connection db = null;
794 TurbineRolePermission retVal = null;
795 try
796 {
797 db = Torque.getConnection(DATABASE_NAME);
798 retVal = retrieveByPK(
799 roleId
800 , permissionId
801 , db);
802 }
803 finally
804 {
805 Torque.closeConnection(db);
806 }
807 return retVal;
808 }
809
810 /***
811 * retrieve object using using pk values.
812 *
813 * @param roleId int
814 * @param permissionId int
815 * @param con Connection
816 */
817 public static TurbineRolePermission retrieveByPK(
818 int roleId
819 , int permissionId
820 ,Connection con) throws TorqueException
821 {
822
823 Criteria criteria = new Criteria(5);
824 criteria.add(ROLE_ID, roleId);
825 criteria.add(PERMISSION_ID, permissionId);
826 List v = doSelect(criteria, con);
827 if (v.size() == 1)
828 {
829 return (TurbineRolePermission) v.get(0);
830 }
831 else
832 {
833 throw new TorqueException("Failed to select one and only one row.");
834 }
835 }
836
837
838
839
840
841
842
843
844 /***
845 * selects a collection of TurbineRolePermission objects pre-filled with their
846 * TurbineRole objects.
847 *
848 * This method is protected by default in order to keep the public
849 * api reasonable. You can provide public methods for those you
850 * actually need in TurbineRolePermissionPeer.
851 *
852 * @throws TorqueException Any exceptions caught during processing will be
853 * rethrown wrapped into a TorqueException.
854 */
855 protected static List doSelectJoinTurbineRole(Criteria criteria)
856 throws TorqueException
857 {
858 return doSelectJoinTurbineRole(criteria, null);
859 }
860
861 /***
862 * selects a collection of TurbineRolePermission objects pre-filled with their
863 * TurbineRole objects.
864 *
865 * This method is protected by default in order to keep the public
866 * api reasonable. You can provide public methods for those you
867 * actually need in TurbineRolePermissionPeer.
868 *
869 * @throws TorqueException Any exceptions caught during processing will be
870 * rethrown wrapped into a TorqueException.
871 */
872 protected static List doSelectJoinTurbineRole(Criteria criteria, Connection conn)
873 throws TorqueException
874 {
875 setDbName(criteria);
876
877 TurbineRolePermissionPeer.addSelectColumns(criteria);
878 int offset = numColumns + 1;
879 TurbineRolePeer.addSelectColumns(criteria);
880
881 criteria.addJoin(TurbineRolePermissionPeer.ROLE_ID,
882 TurbineRolePeer.ROLE_ID);
883
884 correctBooleans(criteria);
885
886 List rows;
887 if (conn == null)
888 {
889 rows = BasePeer.doSelect(criteria);
890 }
891 else
892 {
893 rows = BasePeer.doSelect(criteria,conn);
894 }
895
896 List results = new ArrayList();
897
898 for (int i = 0; i < rows.size(); i++)
899 {
900 Record row = (Record) rows.get(i);
901
902 Class omClass = TurbineRolePermissionPeer.getOMClass();
903 TurbineRolePermission obj1 = (TurbineRolePermission) TurbineRolePermissionPeer
904 .row2Object(row, 1, omClass);
905 omClass = TurbineRolePeer.getOMClass();
906 TurbineRole obj2 = (TurbineRole) TurbineRolePeer
907 .row2Object(row, offset, omClass);
908
909 boolean newObject = true;
910 for (int j = 0; j < results.size(); j++)
911 {
912 TurbineRolePermission temp_obj1 = (TurbineRolePermission) results.get(j);
913 TurbineRole temp_obj2 = (TurbineRole) temp_obj1.getTurbineRole();
914 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
915 {
916 newObject = false;
917 temp_obj2.addTurbineRolePermission(obj1);
918 break;
919 }
920 }
921 if (newObject)
922 {
923 obj2.initTurbineRolePermissions();
924 obj2.addTurbineRolePermission(obj1);
925 }
926 results.add(obj1);
927 }
928 return results;
929 }
930
931
932
933
934 /***
935 * selects a collection of TurbineRolePermission objects pre-filled with their
936 * TurbinePermission objects.
937 *
938 * This method is protected by default in order to keep the public
939 * api reasonable. You can provide public methods for those you
940 * actually need in TurbineRolePermissionPeer.
941 *
942 * @throws TorqueException Any exceptions caught during processing will be
943 * rethrown wrapped into a TorqueException.
944 */
945 protected static List doSelectJoinTurbinePermission(Criteria criteria)
946 throws TorqueException
947 {
948 return doSelectJoinTurbinePermission(criteria, null);
949 }
950
951 /***
952 * selects a collection of TurbineRolePermission objects pre-filled with their
953 * TurbinePermission objects.
954 *
955 * This method is protected by default in order to keep the public
956 * api reasonable. You can provide public methods for those you
957 * actually need in TurbineRolePermissionPeer.
958 *
959 * @throws TorqueException Any exceptions caught during processing will be
960 * rethrown wrapped into a TorqueException.
961 */
962 protected static List doSelectJoinTurbinePermission(Criteria criteria, Connection conn)
963 throws TorqueException
964 {
965 setDbName(criteria);
966
967 TurbineRolePermissionPeer.addSelectColumns(criteria);
968 int offset = numColumns + 1;
969 TurbinePermissionPeer.addSelectColumns(criteria);
970
971 criteria.addJoin(TurbineRolePermissionPeer.PERMISSION_ID,
972 TurbinePermissionPeer.PERMISSION_ID);
973
974 correctBooleans(criteria);
975
976 List rows;
977 if (conn == null)
978 {
979 rows = BasePeer.doSelect(criteria);
980 }
981 else
982 {
983 rows = BasePeer.doSelect(criteria,conn);
984 }
985
986 List results = new ArrayList();
987
988 for (int i = 0; i < rows.size(); i++)
989 {
990 Record row = (Record) rows.get(i);
991
992 Class omClass = TurbineRolePermissionPeer.getOMClass();
993 TurbineRolePermission obj1 = (TurbineRolePermission) TurbineRolePermissionPeer
994 .row2Object(row, 1, omClass);
995 omClass = TurbinePermissionPeer.getOMClass();
996 TurbinePermission obj2 = (TurbinePermission) TurbinePermissionPeer
997 .row2Object(row, offset, omClass);
998
999 boolean newObject = true;
1000 for (int j = 0; j < results.size(); j++)
1001 {
1002 TurbineRolePermission temp_obj1 = (TurbineRolePermission) results.get(j);
1003 TurbinePermission temp_obj2 = (TurbinePermission) temp_obj1.getTurbinePermission();
1004 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1005 {
1006 newObject = false;
1007 temp_obj2.addTurbineRolePermission(obj1);
1008 break;
1009 }
1010 }
1011 if (newObject)
1012 {
1013 obj2.initTurbineRolePermissions();
1014 obj2.addTurbineRolePermission(obj1);
1015 }
1016 results.add(obj1);
1017 }
1018 return results;
1019 }
1020
1021
1022
1023
1024 /***
1025 * Returns the TableMap related to this peer.
1026 *
1027 * @throws TorqueException Any exceptions caught during processing will be
1028 * rethrown wrapped into a TorqueException.
1029 */
1030 public static TableMap getTableMap()
1031 throws TorqueException
1032 {
1033 return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME);
1034 }
1035
1036 private static void setDbName(Criteria crit)
1037 {
1038
1039
1040
1041 if (crit.getDbName() == Torque.getDefaultDB())
1042 {
1043 crit.setDbName(DATABASE_NAME);
1044 }
1045 }
1046
1047
1048 }