001: package org.tigris.scarab.om;
002:
003: import java.math.BigDecimal;
004: import java.sql.Connection;
005: import java.sql.SQLException;
006: import java.util.ArrayList;
007: import java.util.Date;
008: import java.util.Iterator;
009: import java.util.LinkedList;
010: import java.util.List;
011:
012: import org.apache.torque.NoRowsException;
013: import org.apache.torque.TooManyRowsException;
014: import org.apache.torque.Torque;
015: import org.apache.torque.TorqueException;
016: import org.apache.torque.map.MapBuilder;
017: import org.apache.torque.map.TableMap;
018: import org.apache.torque.om.DateKey;
019: import org.apache.torque.om.NumberKey;
020: import org.apache.torque.om.StringKey;
021: import org.apache.torque.om.ObjectKey;
022: import org.apache.torque.om.SimpleKey;
023: import org.apache.torque.util.BasePeer;
024: import org.apache.torque.util.Criteria;
025:
026: import com.workingdogs.village.DataSetException;
027: import com.workingdogs.village.QueryDataSet;
028: import com.workingdogs.village.Record;
029:
030: // Local classes
031: import org.tigris.scarab.om.map.*;
032:
033: /**
034: */
035: public abstract class BasePendingGroupUserRolePeer extends BasePeer {
036:
037: /** the default database name for this class */
038: public static final String DATABASE_NAME = "scarab";
039:
040: /** the table name for this class */
041: public static final String TABLE_NAME = "SCARAB_PENDING_GROUP_USER_ROLE";
042:
043: /**
044: * @return the map builder for this peer
045: * @throws TorqueException Any exceptions caught during processing will be
046: * rethrown wrapped into a TorqueException.
047: */
048: public static MapBuilder getMapBuilder() throws TorqueException {
049: return getMapBuilder(PendingGroupUserRoleMapBuilder.CLASS_NAME);
050: }
051:
052: /** the column name for the USER_ID field */
053: public static final String USER_ID;
054: /** the column name for the GROUP_ID field */
055: public static final String GROUP_ID;
056: /** the column name for the ROLE_NAME field */
057: public static final String ROLE_NAME;
058:
059: static {
060: USER_ID = "SCARAB_PENDING_GROUP_USER_ROLE.USER_ID";
061: GROUP_ID = "SCARAB_PENDING_GROUP_USER_ROLE.GROUP_ID";
062: ROLE_NAME = "SCARAB_PENDING_GROUP_USER_ROLE.ROLE_NAME";
063: if (Torque.isInit()) {
064: try {
065: getMapBuilder(PendingGroupUserRoleMapBuilder.CLASS_NAME);
066: } catch (Exception e) {
067: log.error("Could not initialize Peer", e);
068: throw new RuntimeException(e);
069: }
070: } else {
071: Torque
072: .registerMapBuilder(PendingGroupUserRoleMapBuilder.CLASS_NAME);
073: }
074: }
075:
076: /** number of columns for this peer */
077: public static final int numColumns = 3;
078:
079: /** A class that can be returned by this peer. */
080: protected static final String CLASSNAME_DEFAULT = "org.tigris.scarab.om.PendingGroupUserRole";
081:
082: /** A class that can be returned by this peer. */
083: protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT);
084:
085: /**
086: * Class object initialization method.
087: *
088: * @param className name of the class to initialize
089: * @return the initialized class
090: */
091: private static Class initClass(String className) {
092: Class c = null;
093: try {
094: c = Class.forName(className);
095: } catch (Throwable t) {
096: log
097: .error(
098: "A FATAL ERROR has occurred which should not "
099: + "have happened under any circumstance. Please notify "
100: + "the Torque developers <torque-dev@db.apache.org> "
101: + "and give as many details as possible (including the error "
102: + "stack trace).", t);
103:
104: // Error objects should always be propogated.
105: if (t instanceof Error) {
106: throw (Error) t.fillInStackTrace();
107: }
108: }
109: return c;
110: }
111:
112: /**
113: * Get the list of objects for a ResultSet. Please not that your
114: * resultset MUST return columns in the right order. You can use
115: * getFieldNames() in BaseObject to get the correct sequence.
116: *
117: * @param results the ResultSet
118: * @return the list of objects
119: * @throws TorqueException Any exceptions caught during processing will be
120: * rethrown wrapped into a TorqueException.
121: */
122: public static List resultSet2Objects(java.sql.ResultSet results)
123: throws TorqueException {
124: try {
125: QueryDataSet qds = null;
126: List rows = null;
127: try {
128: qds = new QueryDataSet(results);
129: rows = getSelectResults(qds);
130: } finally {
131: if (qds != null) {
132: qds.close();
133: }
134: }
135:
136: return populateObjects(rows);
137: } catch (SQLException e) {
138: throw new TorqueException(e);
139: } catch (DataSetException e) {
140: throw new TorqueException(e);
141: }
142: }
143:
144: /**
145: * Method to do inserts.
146: *
147: * @param criteria object used to create the INSERT statement.
148: * @throws TorqueException Any exceptions caught during processing will be
149: * rethrown wrapped into a TorqueException.
150: */
151: public static ObjectKey doInsert(Criteria criteria)
152: throws TorqueException {
153: return BasePendingGroupUserRolePeer.doInsert(criteria,
154: (Connection) null);
155: }
156:
157: /**
158: * Method to do inserts. This method is to be used during a transaction,
159: * otherwise use the doInsert(Criteria) method. It will take care of
160: * the connection details internally.
161: *
162: * @param criteria object used to create the INSERT statement.
163: * @param con the connection to use
164: * @throws TorqueException Any exceptions caught during processing will be
165: * rethrown wrapped into a TorqueException.
166: */
167: public static ObjectKey doInsert(Criteria criteria, Connection con)
168: throws TorqueException {
169: correctBooleans(criteria);
170:
171: setDbName(criteria);
172:
173: if (con == null) {
174: return BasePeer.doInsert(criteria);
175: } else {
176: return BasePeer.doInsert(criteria, con);
177: }
178: }
179:
180: /**
181: * Add all the columns needed to create a new object.
182: *
183: * @param criteria object containing the columns to add.
184: * @throws TorqueException Any exceptions caught during processing will be
185: * rethrown wrapped into a TorqueException.
186: */
187: public static void addSelectColumns(Criteria criteria)
188: throws TorqueException {
189: criteria.addSelectColumn(USER_ID);
190: criteria.addSelectColumn(GROUP_ID);
191: criteria.addSelectColumn(ROLE_NAME);
192: }
193:
194: /**
195: * changes the boolean values in the criteria to the appropriate type,
196: * whenever a booleanchar or booleanint column is involved.
197: * This enables the user to create criteria using Boolean values
198: * for booleanchar or booleanint columns
199: * @param criteria the criteria in which the boolean values should be corrected
200: */
201: public static void correctBooleans(Criteria criteria) {
202: }
203:
204: /**
205: * Create a new object of type cls from a resultset row starting
206: * from a specified offset. This is done so that you can select
207: * other rows than just those needed for this object. You may
208: * for example want to create two objects from the same row.
209: *
210: * @throws TorqueException Any exceptions caught during processing will be
211: * rethrown wrapped into a TorqueException.
212: */
213: public static PendingGroupUserRole row2Object(Record row,
214: int offset, Class cls) throws TorqueException {
215: try {
216: PendingGroupUserRole obj = (PendingGroupUserRole) cls
217: .newInstance();
218: PendingGroupUserRolePeer.populateObject(row, offset, obj);
219: obj.setModified(false);
220: obj.setNew(false);
221:
222: return obj;
223: } catch (InstantiationException e) {
224: throw new TorqueException(e);
225: } catch (IllegalAccessException e) {
226: throw new TorqueException(e);
227: }
228: }
229:
230: /**
231: * Populates an object from a resultset row starting
232: * from a specified offset. This is done so that you can select
233: * other rows than just those needed for this object. You may
234: * for example want to create two objects from the same row.
235: *
236: * @throws TorqueException Any exceptions caught during processing will be
237: * rethrown wrapped into a TorqueException.
238: */
239: public static void populateObject(Record row, int offset,
240: PendingGroupUserRole obj) throws TorqueException {
241: try {
242: obj.setUserId(row.getValue(offset + 0).asIntegerObj());
243: obj.setGroupId(row.getValue(offset + 1).asIntegerObj());
244: obj.setRoleName(row.getValue(offset + 2).asString());
245: } catch (DataSetException e) {
246: throw new TorqueException(e);
247: }
248: }
249:
250: /**
251: * Method to do selects.
252: *
253: * @param criteria object used to create the SELECT statement.
254: * @return List of selected Objects
255: * @throws TorqueException Any exceptions caught during processing will be
256: * rethrown wrapped into a TorqueException.
257: */
258: public static List doSelect(Criteria criteria)
259: throws TorqueException {
260: return populateObjects(doSelectVillageRecords(criteria));
261: }
262:
263: /**
264: * Method to do selects within a transaction.
265: *
266: * @param criteria object used to create the SELECT statement.
267: * @param con the connection to use
268: * @return List of selected Objects
269: * @throws TorqueException Any exceptions caught during processing will be
270: * rethrown wrapped into a TorqueException.
271: */
272: public static List doSelect(Criteria criteria, Connection con)
273: throws TorqueException {
274: return populateObjects(doSelectVillageRecords(criteria, con));
275: }
276:
277: /**
278: * Grabs the raw Village records to be formed into objects.
279: * This method handles connections internally. The Record objects
280: * returned by this method should be considered readonly. Do not
281: * alter the data and call save(), your results may vary, but are
282: * certainly likely to result in hard to track MT bugs.
283: *
284: * @throws TorqueException Any exceptions caught during processing will be
285: * rethrown wrapped into a TorqueException.
286: */
287: public static List doSelectVillageRecords(Criteria criteria)
288: throws TorqueException {
289: return BasePendingGroupUserRolePeer.doSelectVillageRecords(
290: criteria, (Connection) null);
291: }
292:
293: /**
294: * Grabs the raw Village records to be formed into objects.
295: * This method should be used for transactions
296: *
297: * @param criteria object used to create the SELECT statement.
298: * @param con the connection to use
299: * @throws TorqueException Any exceptions caught during processing will be
300: * rethrown wrapped into a TorqueException.
301: */
302: public static List doSelectVillageRecords(Criteria criteria,
303: Connection con) throws TorqueException {
304: if (criteria.getSelectColumns().size() == 0) {
305: addSelectColumns(criteria);
306: }
307: correctBooleans(criteria);
308:
309: setDbName(criteria);
310:
311: // BasePeer returns a List of Value (Village) arrays. The array
312: // order follows the order columns were placed in the Select clause.
313: if (con == null) {
314: return BasePeer.doSelect(criteria);
315: } else {
316: return BasePeer.doSelect(criteria, con);
317: }
318: }
319:
320: /**
321: * The returned List will contain objects of the default type or
322: * objects that inherit from the default.
323: *
324: * @throws TorqueException Any exceptions caught during processing will be
325: * rethrown wrapped into a TorqueException.
326: */
327: public static List populateObjects(List records)
328: throws TorqueException {
329: List results = new ArrayList(records.size());
330:
331: // populate the object(s)
332: for (int i = 0; i < records.size(); i++) {
333: Record row = (Record) records.get(i);
334: results.add(PendingGroupUserRolePeer.row2Object(row, 1,
335: PendingGroupUserRolePeer.getOMClass()));
336: }
337: return results;
338: }
339:
340: /**
341: * The class that the Peer will make instances of.
342: * If the BO is abstract then you must implement this method
343: * in the BO.
344: *
345: * @throws TorqueException Any exceptions caught during processing will be
346: * rethrown wrapped into a TorqueException.
347: */
348: public static Class getOMClass() throws TorqueException {
349: return CLASS_DEFAULT;
350: }
351:
352: /**
353: * Method to do updates.
354: *
355: * @param criteria object containing data that is used to create the UPDATE
356: * statement.
357: * @throws TorqueException Any exceptions caught during processing will be
358: * rethrown wrapped into a TorqueException.
359: */
360: public static void doUpdate(Criteria criteria)
361: throws TorqueException {
362: BasePendingGroupUserRolePeer.doUpdate(criteria,
363: (Connection) null);
364: }
365:
366: /**
367: * Method to do updates. This method is to be used during a transaction,
368: * otherwise use the doUpdate(Criteria) method. It will take care of
369: * the connection details internally.
370: *
371: * @param criteria object containing data that is used to create the UPDATE
372: * statement.
373: * @param con the connection to use
374: * @throws TorqueException Any exceptions caught during processing will be
375: * rethrown wrapped into a TorqueException.
376: */
377: public static void doUpdate(Criteria criteria, Connection con)
378: throws TorqueException {
379: Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
380: correctBooleans(criteria);
381:
382: selectCriteria.put(USER_ID, criteria.remove(USER_ID));
383:
384: selectCriteria.put(GROUP_ID, criteria.remove(GROUP_ID));
385:
386: selectCriteria.put(ROLE_NAME, criteria.remove(ROLE_NAME));
387:
388: setDbName(criteria);
389:
390: if (con == null) {
391: BasePeer.doUpdate(selectCriteria, criteria);
392: } else {
393: BasePeer.doUpdate(selectCriteria, criteria, con);
394: }
395: }
396:
397: /**
398: * Method to do deletes.
399: *
400: * @param criteria object containing data that is used DELETE from database.
401: * @throws TorqueException Any exceptions caught during processing will be
402: * rethrown wrapped into a TorqueException.
403: */
404: public static void doDelete(Criteria criteria)
405: throws TorqueException {
406: PendingGroupUserRolePeer.doDelete(criteria, (Connection) null);
407: }
408:
409: /**
410: * Method to do deletes. This method is to be used during a transaction,
411: * otherwise use the doDelete(Criteria) method. It will take care of
412: * the connection details internally.
413: *
414: * @param criteria object containing data that is used DELETE from database.
415: * @param con the connection to use
416: * @throws TorqueException Any exceptions caught during processing will be
417: * rethrown wrapped into a TorqueException.
418: */
419: public static void doDelete(Criteria criteria, Connection con)
420: throws TorqueException {
421: correctBooleans(criteria);
422:
423: setDbName(criteria);
424:
425: if (con == null) {
426: BasePeer.doDelete(criteria);
427: } else {
428: BasePeer.doDelete(criteria, con);
429: }
430: }
431:
432: /**
433: * Method to do selects
434: *
435: * @throws TorqueException Any exceptions caught during processing will be
436: * rethrown wrapped into a TorqueException.
437: */
438: public static List doSelect(PendingGroupUserRole obj)
439: throws TorqueException {
440: return doSelect(buildSelectCriteria(obj));
441: }
442:
443: /**
444: * Method to do inserts
445: *
446: * @throws TorqueException Any exceptions caught during processing will be
447: * rethrown wrapped into a TorqueException.
448: */
449: public static void doInsert(PendingGroupUserRole obj)
450: throws TorqueException {
451: doInsert(buildCriteria(obj));
452: obj.setNew(false);
453: obj.setModified(false);
454: }
455:
456: /**
457: * @param obj the data object to update in the database.
458: * @throws TorqueException Any exceptions caught during processing will be
459: * rethrown wrapped into a TorqueException.
460: */
461: public static void doUpdate(PendingGroupUserRole obj)
462: throws TorqueException {
463: doUpdate(buildCriteria(obj));
464: obj.setModified(false);
465: }
466:
467: /**
468: * @param obj the data object to delete in the database.
469: * @throws TorqueException Any exceptions caught during processing will be
470: * rethrown wrapped into a TorqueException.
471: */
472: public static void doDelete(PendingGroupUserRole obj)
473: throws TorqueException {
474: doDelete(buildSelectCriteria(obj));
475: }
476:
477: /**
478: * Method to do inserts. This method is to be used during a transaction,
479: * otherwise use the doInsert(PendingGroupUserRole) method. It will take
480: * care of the connection details internally.
481: *
482: * @param obj the data object to insert into the database.
483: * @param con the connection to use
484: * @throws TorqueException Any exceptions caught during processing will be
485: * rethrown wrapped into a TorqueException.
486: */
487: public static void doInsert(PendingGroupUserRole obj, Connection con)
488: throws TorqueException {
489: doInsert(buildCriteria(obj), con);
490: obj.setNew(false);
491: obj.setModified(false);
492: }
493:
494: /**
495: * Method to do update. This method is to be used during a transaction,
496: * otherwise use the doUpdate(PendingGroupUserRole) method. It will take
497: * care of the connection details internally.
498: *
499: * @param obj the data object to update in the database.
500: * @param con the connection to use
501: * @throws TorqueException Any exceptions caught during processing will be
502: * rethrown wrapped into a TorqueException.
503: */
504: public static void doUpdate(PendingGroupUserRole obj, Connection con)
505: throws TorqueException {
506: doUpdate(buildCriteria(obj), con);
507: obj.setModified(false);
508: }
509:
510: /**
511: * Method to delete. This method is to be used during a transaction,
512: * otherwise use the doDelete(PendingGroupUserRole) method. It will take
513: * care of the connection details internally.
514: *
515: * @param obj the data object to delete in the database.
516: * @param con the connection to use
517: * @throws TorqueException Any exceptions caught during processing will be
518: * rethrown wrapped into a TorqueException.
519: */
520: public static void doDelete(PendingGroupUserRole obj, Connection con)
521: throws TorqueException {
522: doDelete(buildSelectCriteria(obj), con);
523: }
524:
525: /**
526: * Method to do deletes.
527: *
528: * @param pk ObjectKey that is used DELETE from database.
529: * @throws TorqueException Any exceptions caught during processing will be
530: * rethrown wrapped into a TorqueException.
531: */
532: public static void doDelete(ObjectKey pk) throws TorqueException {
533: BasePendingGroupUserRolePeer.doDelete(pk, (Connection) null);
534: }
535:
536: /**
537: * Method to delete. This method is to be used during a transaction,
538: * otherwise use the doDelete(ObjectKey) method. It will take
539: * care of the connection details internally.
540: *
541: * @param pk the primary key for the object to delete in 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 doDelete(ObjectKey pk, Connection con)
547: throws TorqueException {
548: doDelete(buildCriteria(pk), con);
549: }
550:
551: /** Build a Criteria object from an ObjectKey */
552: public static Criteria buildCriteria(ObjectKey pk) {
553: Criteria criteria = new Criteria();
554: SimpleKey[] keys = (SimpleKey[]) pk.getValue();
555: criteria.add(USER_ID, keys[0]);
556: criteria.add(GROUP_ID, keys[1]);
557: criteria.add(ROLE_NAME, keys[2]);
558: return criteria;
559: }
560:
561: /** Build a Criteria object from the data object for this peer */
562: public static Criteria buildCriteria(PendingGroupUserRole obj) {
563: Criteria criteria = new Criteria(DATABASE_NAME);
564: criteria.add(USER_ID, obj.getUserId());
565: criteria.add(GROUP_ID, obj.getGroupId());
566: criteria.add(ROLE_NAME, obj.getRoleName());
567: return criteria;
568: }
569:
570: /** Build a Criteria object from the data object for this peer, skipping all binary columns */
571: public static Criteria buildSelectCriteria(PendingGroupUserRole obj) {
572: Criteria criteria = new Criteria(DATABASE_NAME);
573: criteria.add(USER_ID, obj.getUserId());
574: criteria.add(GROUP_ID, obj.getGroupId());
575: criteria.add(ROLE_NAME, obj.getRoleName());
576: return criteria;
577: }
578:
579: /**
580: * Retrieve a single object by pk
581: *
582: * @param pk the primary key
583: * @throws TorqueException Any exceptions caught during processing will be
584: * rethrown wrapped into a TorqueException.
585: * @throws NoRowsException Primary key was not found in database.
586: * @throws TooManyRowsException Primary key was not found in database.
587: */
588: public static PendingGroupUserRole retrieveByPK(ObjectKey pk)
589: throws TorqueException, NoRowsException,
590: TooManyRowsException {
591: Connection db = null;
592: PendingGroupUserRole retVal = null;
593: try {
594: db = Torque.getConnection(DATABASE_NAME);
595: retVal = retrieveByPK(pk, db);
596: } finally {
597: Torque.closeConnection(db);
598: }
599: return retVal;
600: }
601:
602: /**
603: * Retrieve a single object by pk
604: *
605: * @param pk the primary key
606: * @param con the connection to use
607: * @throws TorqueException Any exceptions caught during processing will be
608: * rethrown wrapped into a TorqueException.
609: * @throws NoRowsException Primary key was not found in database.
610: * @throws TooManyRowsException Primary key was not found in database.
611: */
612: public static PendingGroupUserRole retrieveByPK(ObjectKey pk,
613: Connection con) throws TorqueException, NoRowsException,
614: TooManyRowsException {
615: Criteria criteria = buildCriteria(pk);
616: List v = doSelect(criteria, con);
617: if (v.size() == 0) {
618: throw new NoRowsException("Failed to select a row.");
619: } else if (v.size() > 1) {
620: throw new TooManyRowsException(
621: "Failed to select only one row.");
622: } else {
623: return (PendingGroupUserRole) v.get(0);
624: }
625: }
626:
627: /**
628: * Retrieve a multiple objects by pk
629: *
630: * @param pks List of primary keys
631: * @throws TorqueException Any exceptions caught during processing will be
632: * rethrown wrapped into a TorqueException.
633: */
634: public static List retrieveByPKs(List pks) throws TorqueException {
635: Connection db = null;
636: List retVal = null;
637: try {
638: db = Torque.getConnection(DATABASE_NAME);
639: retVal = retrieveByPKs(pks, db);
640: } finally {
641: Torque.closeConnection(db);
642: }
643: return retVal;
644: }
645:
646: /**
647: * Retrieve a multiple objects by pk
648: *
649: * @param pks List of primary keys
650: * @param dbcon the connection to use
651: * @throws TorqueException Any exceptions caught during processing will be
652: * rethrown wrapped into a TorqueException.
653: */
654: public static List retrieveByPKs(List pks, Connection dbcon)
655: throws TorqueException {
656: List objs = null;
657: if (pks == null || pks.size() == 0) {
658: objs = new LinkedList();
659: } else {
660: Criteria criteria = new Criteria();
661: Iterator iter = pks.iterator();
662: while (iter.hasNext()) {
663: ObjectKey pk = (ObjectKey) iter.next();
664: SimpleKey[] keys = (SimpleKey[]) pk.getValue();
665: Criteria.Criterion c0 = criteria.getNewCriterion(
666: USER_ID, keys[0], Criteria.EQUAL);
667: Criteria.Criterion c1 = criteria.getNewCriterion(
668: GROUP_ID, keys[1], Criteria.EQUAL);
669: c0.and(c1);
670: Criteria.Criterion c2 = criteria.getNewCriterion(
671: ROLE_NAME, keys[2], Criteria.EQUAL);
672: c1.and(c2);
673: criteria.or(c0);
674: }
675: objs = doSelect(criteria, dbcon);
676: }
677: return objs;
678: }
679:
680: /**
681: * retrieve object using using pk values.
682: *
683: * @param user_id Integer
684: * @param group_id Integer
685: * @param role_name String
686: */
687: public static PendingGroupUserRole retrieveByPK(Integer user_id,
688: Integer group_id, String role_name) throws TorqueException {
689: Connection db = null;
690: PendingGroupUserRole retVal = null;
691: try {
692: db = Torque.getConnection(DATABASE_NAME);
693: retVal = retrieveByPK(user_id, group_id, role_name, db);
694: } finally {
695: Torque.closeConnection(db);
696: }
697: return retVal;
698: }
699:
700: /**
701: * retrieve object using using pk values.
702: *
703: * @param user_id Integer
704: * @param group_id Integer
705: * @param role_name String
706: * @param con Connection
707: */
708: public static PendingGroupUserRole retrieveByPK(Integer user_id,
709: Integer group_id, String role_name, Connection con)
710: throws TorqueException {
711:
712: Criteria criteria = new Criteria(5);
713: criteria.add(USER_ID, user_id);
714: criteria.add(GROUP_ID, group_id);
715: criteria.add(ROLE_NAME, role_name);
716: List v = doSelect(criteria, con);
717: if (v.size() == 1) {
718: return (PendingGroupUserRole) v.get(0);
719: } else {
720: throw new TorqueException(
721: "Failed to select one and only one row.");
722: }
723: }
724:
725: /**
726: * selects a collection of PendingGroupUserRole objects pre-filled with their
727: * ScarabUserImpl objects.
728: *
729: * This method is protected by default in order to keep the public
730: * api reasonable. You can provide public methods for those you
731: * actually need in PendingGroupUserRolePeer.
732: *
733: * @throws TorqueException Any exceptions caught during processing will be
734: * rethrown wrapped into a TorqueException.
735: */
736: protected static List doSelectJoinScarabUserImpl(Criteria criteria)
737: throws TorqueException {
738: return doSelectJoinScarabUserImpl(criteria, null);
739: }
740:
741: /**
742: * selects a collection of PendingGroupUserRole objects pre-filled with their
743: * ScarabUserImpl objects.
744: *
745: * This method is protected by default in order to keep the public
746: * api reasonable. You can provide public methods for those you
747: * actually need in PendingGroupUserRolePeer.
748: *
749: * @throws TorqueException Any exceptions caught during processing will be
750: * rethrown wrapped into a TorqueException.
751: */
752: protected static List doSelectJoinScarabUserImpl(Criteria criteria,
753: Connection conn) throws TorqueException {
754: setDbName(criteria);
755:
756: PendingGroupUserRolePeer.addSelectColumns(criteria);
757: int offset = numColumns + 1;
758: ScarabUserImplPeer.addSelectColumns(criteria);
759:
760: criteria.addJoin(PendingGroupUserRolePeer.USER_ID,
761: ScarabUserImplPeer.USER_ID);
762:
763: correctBooleans(criteria);
764:
765: List rows;
766: if (conn == null) {
767: rows = BasePeer.doSelect(criteria);
768: } else {
769: rows = BasePeer.doSelect(criteria, conn);
770: }
771:
772: List results = new ArrayList();
773:
774: for (int i = 0; i < rows.size(); i++) {
775: Record row = (Record) rows.get(i);
776:
777: Class omClass = PendingGroupUserRolePeer.getOMClass();
778: PendingGroupUserRole obj1 = (PendingGroupUserRole) PendingGroupUserRolePeer
779: .row2Object(row, 1, omClass);
780: omClass = ScarabUserImplPeer.getOMClass();
781: ScarabUserImpl obj2 = (ScarabUserImpl) ScarabUserImplPeer
782: .row2Object(row, offset, omClass);
783:
784: boolean newObject = true;
785: for (int j = 0; j < results.size(); j++) {
786: PendingGroupUserRole temp_obj1 = (PendingGroupUserRole) results
787: .get(j);
788: ScarabUserImpl temp_obj2 = (ScarabUserImpl) temp_obj1
789: .getScarabUser();
790: if (temp_obj2.getPrimaryKey().equals(
791: obj2.getPrimaryKey())) {
792: newObject = false;
793: temp_obj2.addPendingGroupUserRole(obj1);
794: break;
795: }
796: }
797: if (newObject) {
798: obj2.initPendingGroupUserRoles();
799: obj2.addPendingGroupUserRole(obj1);
800: }
801: results.add(obj1);
802: }
803: return results;
804: }
805:
806: /**
807: * selects a collection of PendingGroupUserRole objects pre-filled with their
808: * ScarabModule objects.
809: *
810: * This method is protected by default in order to keep the public
811: * api reasonable. You can provide public methods for those you
812: * actually need in PendingGroupUserRolePeer.
813: *
814: * @throws TorqueException Any exceptions caught during processing will be
815: * rethrown wrapped into a TorqueException.
816: */
817: protected static List doSelectJoinScarabModule(Criteria criteria)
818: throws TorqueException {
819: return doSelectJoinScarabModule(criteria, null);
820: }
821:
822: /**
823: * selects a collection of PendingGroupUserRole objects pre-filled with their
824: * ScarabModule objects.
825: *
826: * This method is protected by default in order to keep the public
827: * api reasonable. You can provide public methods for those you
828: * actually need in PendingGroupUserRolePeer.
829: *
830: * @throws TorqueException Any exceptions caught during processing will be
831: * rethrown wrapped into a TorqueException.
832: */
833: protected static List doSelectJoinScarabModule(Criteria criteria,
834: Connection conn) throws TorqueException {
835: setDbName(criteria);
836:
837: PendingGroupUserRolePeer.addSelectColumns(criteria);
838: int offset = numColumns + 1;
839: ScarabModulePeer.addSelectColumns(criteria);
840:
841: criteria.addJoin(PendingGroupUserRolePeer.GROUP_ID,
842: ScarabModulePeer.MODULE_ID);
843:
844: correctBooleans(criteria);
845:
846: List rows;
847: if (conn == null) {
848: rows = BasePeer.doSelect(criteria);
849: } else {
850: rows = BasePeer.doSelect(criteria, conn);
851: }
852:
853: List results = new ArrayList();
854:
855: for (int i = 0; i < rows.size(); i++) {
856: Record row = (Record) rows.get(i);
857:
858: Class omClass = PendingGroupUserRolePeer.getOMClass();
859: PendingGroupUserRole obj1 = (PendingGroupUserRole) PendingGroupUserRolePeer
860: .row2Object(row, 1, omClass);
861: omClass = ScarabModulePeer.getOMClass(row, offset);
862: ScarabModule obj2 = (ScarabModule) ScarabModulePeer
863: .row2Object(row, offset, omClass);
864:
865: boolean newObject = true;
866: for (int j = 0; j < results.size(); j++) {
867: PendingGroupUserRole temp_obj1 = (PendingGroupUserRole) results
868: .get(j);
869: ScarabModule temp_obj2 = (ScarabModule) temp_obj1
870: .getModule();
871: if (temp_obj2.getPrimaryKey().equals(
872: obj2.getPrimaryKey())) {
873: newObject = false;
874: temp_obj2.addPendingGroupUserRole(obj1);
875: break;
876: }
877: }
878: if (newObject) {
879: obj2.initPendingGroupUserRoles();
880: obj2.addPendingGroupUserRole(obj1);
881: }
882: results.add(obj1);
883: }
884: return results;
885: }
886:
887: /**
888: * Returns the TableMap related to this peer. This method is not
889: * needed for general use but a specific application could have a need.
890: *
891: * @throws TorqueException Any exceptions caught during processing will be
892: * rethrown wrapped into a TorqueException.
893: */
894: protected static TableMap getTableMap() throws TorqueException {
895: return Torque.getDatabaseMap(DATABASE_NAME)
896: .getTable(TABLE_NAME);
897: }
898:
899: private static void setDbName(Criteria crit) {
900: // Set the correct dbName if it has not been overridden
901: // crit.getDbName will return the same object if not set to
902: // another value so == check is okay and faster
903: if (crit.getDbName() == Torque.getDefaultDB()) {
904: crit.setDbName(DATABASE_NAME);
905: }
906: }
907: }
|