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