KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > tigris > scarab > om > BaseRQueryUserPeer


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

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

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

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

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

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

203     public static ObjectKey doInsert(Criteria criteria, Connection JavaDoc con)
204         throws TorqueException
205     {
206                           // check for conversion from boolean to int
207
if (criteria.containsKey(IS_SUBSCRIBED))
208         {
209             Object JavaDoc possibleBoolean = criteria.get(IS_SUBSCRIBED);
210             if (possibleBoolean instanceof Boolean JavaDoc)
211             {
212                 criteria.add(IS_SUBSCRIBED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
213             }
214          }
215                         // check for conversion from boolean to int
216
if (criteria.containsKey(ISDEFAULT))
217         {
218             Object JavaDoc possibleBoolean = criteria.get(ISDEFAULT);
219             if (possibleBoolean instanceof Boolean JavaDoc)
220             {
221                 criteria.add(ISDEFAULT, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
222             }
223          }
224       
225         setDbName(criteria);
226
227         if (con == null)
228         {
229             return BasePeer.doInsert(criteria);
230         }
231         else
232         {
233             return BasePeer.doInsert(criteria, con);
234         }
235     }
236
237     /**
238      * Add all the columns needed to create a new object.
239      *
240      * @param criteria object containing the columns to add.
241      * @throws TorqueException Any exceptions caught during processing will be
242      * rethrown wrapped into a TorqueException.
243      */

244     public static void addSelectColumns(Criteria criteria)
245             throws TorqueException
246     {
247           criteria.addSelectColumn(QUERY_ID);
248           criteria.addSelectColumn(USER_ID);
249           criteria.addSelectColumn(IS_SUBSCRIBED);
250           criteria.addSelectColumn(SUBSCRIPTION_FREQUENCY_ID);
251           criteria.addSelectColumn(ISDEFAULT);
252       }
253
254     /**
255      * Create a new object of type cls from a resultset row starting
256      * from a specified offset. This is done so that you can select
257      * other rows than just those needed for this object. You may
258      * for example want to create two objects from the same row.
259      *
260      * @throws TorqueException Any exceptions caught during processing will be
261      * rethrown wrapped into a TorqueException.
262      */

263     public static RQueryUser row2Object(Record row,
264                                              int offset,
265                                              Class JavaDoc cls)
266         throws TorqueException
267     {
268         try
269         {
270             RQueryUser obj = (RQueryUser) cls.newInstance();
271             RQueryUserPeer.populateObject(row, offset, obj);
272                   obj.setModified(false);
273               obj.setNew(false);
274
275             return obj;
276         }
277         catch (InstantiationException JavaDoc e)
278         {
279             throw new TorqueException(e);
280         }
281         catch (IllegalAccessException JavaDoc e)
282         {
283             throw new TorqueException(e);
284         }
285     }
286
287     /**
288      * Populates an object from a resultset row starting
289      * from a specified offset. This is done so that you can select
290      * other rows than just those needed for this object. You may
291      * for example want to create two objects from the same row.
292      *
293      * @throws TorqueException Any exceptions caught during processing will be
294      * rethrown wrapped into a TorqueException.
295      */

296     public static void populateObject(Record row,
297                                       int offset,
298                                       RQueryUser obj)
299         throws TorqueException
300     {
301         try
302         {
303                 obj.setQueryId(row.getValue(offset + 0).asLongObj());
304                   obj.setUserId(row.getValue(offset + 1).asIntegerObj());
305                   obj.setIsSubscribed(row.getValue(offset + 2).asBoolean());
306                   obj.setSubscriptionFrequency(row.getValue(offset + 3).asIntegerObj());
307                   obj.setIsdefault(row.getValue(offset + 4).asBoolean());
308               }
309         catch (DataSetException e)
310         {
311             throw new TorqueException(e);
312         }
313     }
314
315     /**
316      * Method to do selects.
317      *
318      * @param criteria object used to create the SELECT statement.
319      * @return List of selected Objects
320      * @throws TorqueException Any exceptions caught during processing will be
321      * rethrown wrapped into a TorqueException.
322      */

323     public static List JavaDoc doSelect(Criteria criteria) throws TorqueException
324     {
325         return populateObjects(doSelectVillageRecords(criteria));
326     }
327
328     /**
329      * Method to do selects within a transaction.
330      *
331      * @param criteria object used to create the SELECT statement.
332      * @param con the connection to use
333      * @return List of selected Objects
334      * @throws TorqueException Any exceptions caught during processing will be
335      * rethrown wrapped into a TorqueException.
336      */

337     public static List JavaDoc doSelect(Criteria criteria, Connection JavaDoc con)
338         throws TorqueException
339     {
340         return populateObjects(doSelectVillageRecords(criteria, con));
341     }
342
343     /**
344      * Grabs the raw Village records to be formed into objects.
345      * This method handles connections internally. The Record objects
346      * returned by this method should be considered readonly. Do not
347      * alter the data and call save(), your results may vary, but are
348      * certainly likely to result in hard to track MT bugs.
349      *
350      * @throws TorqueException Any exceptions caught during processing will be
351      * rethrown wrapped into a TorqueException.
352      */

353     public static List JavaDoc doSelectVillageRecords(Criteria criteria)
354         throws TorqueException
355     {
356         return BaseRQueryUserPeer
357             .doSelectVillageRecords(criteria, (Connection JavaDoc) null);
358     }
359
360     /**
361      * Grabs the raw Village records to be formed into objects.
362      * This method should be used for transactions
363      *
364      * @param criteria object used to create the SELECT statement.
365      * @param con the connection to use
366      * @throws TorqueException Any exceptions caught during processing will be
367      * rethrown wrapped into a TorqueException.
368      */

369     public static List JavaDoc doSelectVillageRecords(Criteria criteria, Connection JavaDoc con)
370         throws TorqueException
371     {
372         if (criteria.getSelectColumns().size() == 0)
373         {
374             addSelectColumns(criteria);
375         }
376
377                           // check for conversion from boolean to int
378
if (criteria.containsKey(IS_SUBSCRIBED))
379         {
380             Object JavaDoc possibleBoolean = criteria.get(IS_SUBSCRIBED);
381             if (possibleBoolean instanceof Boolean JavaDoc)
382             {
383                 criteria.add(IS_SUBSCRIBED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
384             }
385          }
386                         // check for conversion from boolean to int
387
if (criteria.containsKey(ISDEFAULT))
388         {
389             Object JavaDoc possibleBoolean = criteria.get(ISDEFAULT);
390             if (possibleBoolean instanceof Boolean JavaDoc)
391             {
392                 criteria.add(ISDEFAULT, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
393             }
394          }
395       
396         setDbName(criteria);
397
398         // BasePeer returns a List of Value (Village) arrays. The array
399
// order follows the order columns were placed in the Select clause.
400
if (con == null)
401         {
402             return BasePeer.doSelect(criteria);
403         }
404         else
405         {
406             return BasePeer.doSelect(criteria, con);
407         }
408     }
409
410     /**
411      * The returned List will contain objects of the default type or
412      * objects that inherit from the default.
413      *
414      * @throws TorqueException Any exceptions caught during processing will be
415      * rethrown wrapped into a TorqueException.
416      */

417     public static List JavaDoc populateObjects(List JavaDoc records)
418         throws TorqueException
419     {
420         List JavaDoc results = new ArrayList JavaDoc(records.size());
421
422         // populate the object(s)
423
for (int i = 0; i < records.size(); i++)
424         {
425             Record row = (Record) records.get(i);
426               results.add(RQueryUserPeer.row2Object(row, 1,
427                 RQueryUserPeer.getOMClass()));
428           }
429         return results;
430     }
431  
432
433     /**
434      * The class that the Peer will make instances of.
435      * If the BO is abstract then you must implement this method
436      * in the BO.
437      *
438      * @throws TorqueException Any exceptions caught during processing will be
439      * rethrown wrapped into a TorqueException.
440      */

441     public static Class JavaDoc getOMClass()
442         throws TorqueException
443     {
444         return CLASS_DEFAULT;
445     }
446
447     /**
448      * Method to do updates.
449      *
450      * @param criteria object containing data that is used to create the UPDATE
451      * statement.
452      * @throws TorqueException Any exceptions caught during processing will be
453      * rethrown wrapped into a TorqueException.
454      */

455     public static void doUpdate(Criteria criteria) throws TorqueException
456     {
457          BaseRQueryUserPeer
458             .doUpdate(criteria, (Connection JavaDoc) null);
459     }
460
461     /**
462      * Method to do updates. This method is to be used during a transaction,
463      * otherwise use the doUpdate(Criteria) method. It will take care of
464      * the connection details internally.
465      *
466      * @param criteria object containing data that is used to create the UPDATE
467      * statement.
468      * @param con the connection to use
469      * @throws TorqueException Any exceptions caught during processing will be
470      * rethrown wrapped into a TorqueException.
471      */

472     public static void doUpdate(Criteria criteria, Connection JavaDoc con)
473         throws TorqueException
474     {
475         Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
476                    selectCriteria.put(QUERY_ID, criteria.remove(QUERY_ID));
477                        selectCriteria.put(USER_ID, criteria.remove(USER_ID));
478                   // check for conversion from boolean to int
479
if (criteria.containsKey(IS_SUBSCRIBED))
480         {
481             Object JavaDoc possibleBoolean = criteria.get(IS_SUBSCRIBED);
482             if (possibleBoolean instanceof Boolean JavaDoc)
483             {
484                 criteria.add(IS_SUBSCRIBED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
485             }
486          }
487                                 // check for conversion from boolean to int
488
if (criteria.containsKey(ISDEFAULT))
489         {
490             Object JavaDoc possibleBoolean = criteria.get(ISDEFAULT);
491             if (possibleBoolean instanceof Boolean JavaDoc)
492             {
493                 criteria.add(ISDEFAULT, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
494             }
495          }
496           
497         setDbName(criteria);
498
499         if (con == null)
500         {
501             BasePeer.doUpdate(selectCriteria, criteria);
502         }
503         else
504         {
505             BasePeer.doUpdate(selectCriteria, criteria, con);
506         }
507     }
508
509     /**
510      * Method to do deletes.
511      *
512      * @param criteria object containing data that is used DELETE from database.
513      * @throws TorqueException Any exceptions caught during processing will be
514      * rethrown wrapped into a TorqueException.
515      */

516      public static void doDelete(Criteria criteria) throws TorqueException
517      {
518          RQueryUserPeer
519             .doDelete(criteria, (Connection JavaDoc) null);
520      }
521
522     /**
523      * Method to do deletes. This method is to be used during a transaction,
524      * otherwise use the doDelete(Criteria) method. It will take care of
525      * the connection details internally.
526      *
527      * @param criteria object containing data that is used DELETE from database.
528      * @param con the connection to use
529      * @throws TorqueException Any exceptions caught during processing will be
530      * rethrown wrapped into a TorqueException.
531      */

532      public static void doDelete(Criteria criteria, Connection JavaDoc con)
533         throws TorqueException
534      {
535                           // check for conversion from boolean to int
536
if (criteria.containsKey(IS_SUBSCRIBED))
537         {
538             Object JavaDoc possibleBoolean = criteria.get(IS_SUBSCRIBED);
539             if (possibleBoolean instanceof Boolean JavaDoc)
540             {
541                 criteria.add(IS_SUBSCRIBED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
542             }
543          }
544                         // check for conversion from boolean to int
545
if (criteria.containsKey(ISDEFAULT))
546         {
547             Object JavaDoc possibleBoolean = criteria.get(ISDEFAULT);
548             if (possibleBoolean instanceof Boolean JavaDoc)
549             {
550                 criteria.add(ISDEFAULT, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
551             }
552          }
553       
554         setDbName(criteria);
555
556         if (con == null)
557         {
558             BasePeer.doDelete(criteria);
559         }
560         else
561         {
562             BasePeer.doDelete(criteria, con);
563         }
564      }
565
566     /**
567      * Method to do selects
568      *
569      * @throws TorqueException Any exceptions caught during processing will be
570      * rethrown wrapped into a TorqueException.
571      */

572     public static List JavaDoc doSelect(RQueryUser obj) throws TorqueException
573     {
574         return doSelect(buildSelectCriteria(obj));
575     }
576
577     /**
578      * Method to do inserts
579      *
580      * @throws TorqueException Any exceptions caught during processing will be
581      * rethrown wrapped into a TorqueException.
582      */

583     public static void doInsert(RQueryUser obj) throws TorqueException
584     {
585           doInsert(buildCriteria(obj));
586           obj.setNew(false);
587         obj.setModified(false);
588     }
589
590     /**
591      * @param obj the data object to update in the database.
592      * @throws TorqueException Any exceptions caught during processing will be
593      * rethrown wrapped into a TorqueException.
594      */

595     public static void doUpdate(RQueryUser obj) throws TorqueException
596     {
597         doUpdate(buildCriteria(obj));
598         obj.setModified(false);
599     }
600
601     /**
602      * @param obj the data object to delete in the database.
603      * @throws TorqueException Any exceptions caught during processing will be
604      * rethrown wrapped into a TorqueException.
605      */

606     public static void doDelete(RQueryUser obj) throws TorqueException
607     {
608         doDelete(buildSelectCriteria(obj));
609     }
610
611     /**
612      * Method to do inserts. This method is to be used during a transaction,
613      * otherwise use the doInsert(RQueryUser) method. It will take
614      * care of the connection details internally.
615      *
616      * @param obj the data object to insert into the database.
617      * @param con the connection to use
618      * @throws TorqueException Any exceptions caught during processing will be
619      * rethrown wrapped into a TorqueException.
620      */

621     public static void doInsert(RQueryUser obj, Connection JavaDoc con)
622         throws TorqueException
623     {
624           doInsert(buildCriteria(obj), con);
625           obj.setNew(false);
626         obj.setModified(false);
627     }
628
629     /**
630      * Method to do update. This method is to be used during a transaction,
631      * otherwise use the doUpdate(RQueryUser) method. It will take
632      * care of the connection details internally.
633      *
634      * @param obj the data object to update in the database.
635      * @param con the connection to use
636      * @throws TorqueException Any exceptions caught during processing will be
637      * rethrown wrapped into a TorqueException.
638      */

639     public static void doUpdate(RQueryUser obj, Connection JavaDoc con)
640         throws TorqueException
641     {
642         doUpdate(buildCriteria(obj), con);
643         obj.setModified(false);
644     }
645
646     /**
647      * Method to delete. This method is to be used during a transaction,
648      * otherwise use the doDelete(RQueryUser) method. It will take
649      * care of the connection details internally.
650      *
651      * @param obj the data object to delete in the database.
652      * @param con the connection to use
653      * @throws TorqueException Any exceptions caught during processing will be
654      * rethrown wrapped into a TorqueException.
655      */

656     public static void doDelete(RQueryUser obj, Connection JavaDoc con)
657         throws TorqueException
658     {
659         doDelete(buildSelectCriteria(obj), con);
660     }
661
662     /**
663      * Method to do deletes.
664      *
665      * @param pk ObjectKey that is used DELETE from database.
666      * @throws TorqueException Any exceptions caught during processing will be
667      * rethrown wrapped into a TorqueException.
668      */

669     public static void doDelete(ObjectKey pk) throws TorqueException
670     {
671         BaseRQueryUserPeer
672            .doDelete(pk, (Connection JavaDoc) null);
673     }
674
675     /**
676      * Method to delete. This method is to be used during a transaction,
677      * otherwise use the doDelete(ObjectKey) method. It will take
678      * care of the connection details internally.
679      *
680      * @param pk the primary key for the object to delete in the database.
681      * @param con the connection to use
682      * @throws TorqueException Any exceptions caught during processing will be
683      * rethrown wrapped into a TorqueException.
684      */

685     public static void doDelete(ObjectKey pk, Connection JavaDoc con)
686         throws TorqueException
687     {
688         doDelete(buildCriteria(pk), con);
689     }
690
691     /** Build a Criteria object from an ObjectKey */
692     public static Criteria buildCriteria( ObjectKey pk )
693     {
694         Criteria criteria = new Criteria();
695           SimpleKey[] keys = (SimpleKey[])pk.getValue();
696                     criteria.add(QUERY_ID, keys[0]);
697                       criteria.add(USER_ID, keys[1]);
698                     return criteria;
699      }
700
701     /** Build a Criteria object from the data object for this peer */
702     public static Criteria buildCriteria( RQueryUser obj )
703     {
704         Criteria criteria = new Criteria(DATABASE_NAME);
705               criteria.add(QUERY_ID, obj.getQueryId());
706               criteria.add(USER_ID, obj.getUserId());
707               criteria.add(IS_SUBSCRIBED, obj.getIsSubscribed());
708               criteria.add(SUBSCRIPTION_FREQUENCY_ID, obj.getSubscriptionFrequency());
709               criteria.add(ISDEFAULT, obj.getIsdefault());
710           return criteria;
711     }
712
713     /** Build a Criteria object from the data object for this peer, skipping all binary columns */
714     public static Criteria buildSelectCriteria( RQueryUser obj )
715     {
716         Criteria criteria = new Criteria(DATABASE_NAME);
717                       criteria.add(QUERY_ID, obj.getQueryId());
718                           criteria.add(USER_ID, obj.getUserId());
719                           criteria.add(IS_SUBSCRIBED, obj.getIsSubscribed());
720                           criteria.add(SUBSCRIPTION_FREQUENCY_ID, obj.getSubscriptionFrequency());
721                           criteria.add(ISDEFAULT, obj.getIsdefault());
722               return criteria;
723     }
724  
725     
726     
727     /**
728      * Retrieve a single object by pk
729      *
730      * @param pk the primary key
731      * @throws TorqueException Any exceptions caught during processing will be
732      * rethrown wrapped into a TorqueException.
733      * @throws NoRowsException Primary key was not found in database.
734      * @throws TooManyRowsException Primary key was not found in database.
735      */

736     public static RQueryUser retrieveByPK(ObjectKey pk)
737         throws TorqueException, NoRowsException, TooManyRowsException
738     {
739         Connection JavaDoc db = null;
740         RQueryUser retVal = null;
741         try
742         {
743             db = Torque.getConnection(DATABASE_NAME);
744             retVal = retrieveByPK(pk, db);
745         }
746         finally
747         {
748             Torque.closeConnection(db);
749         }
750         return(retVal);
751     }
752
753     /**
754      * Retrieve a single object by pk
755      *
756      * @param pk the primary key
757      * @param con the connection to use
758      * @throws TorqueException Any exceptions caught during processing will be
759      * rethrown wrapped into a TorqueException.
760      * @throws NoRowsException Primary key was not found in database.
761      * @throws TooManyRowsException Primary key was not found in database.
762      */

763     public static RQueryUser retrieveByPK(ObjectKey pk, Connection JavaDoc con)
764         throws TorqueException, NoRowsException, TooManyRowsException
765     {
766         Criteria criteria = buildCriteria(pk);
767         List JavaDoc v = doSelect(criteria, con);
768         if (v.size() == 0)
769         {
770             throw new NoRowsException("Failed to select a row.");
771         }
772         else if (v.size() > 1)
773         {
774             throw new TooManyRowsException("Failed to select only one row.");
775         }
776         else
777         {
778             return (RQueryUser)v.get(0);
779         }
780     }
781
782     /**
783      * Retrieve a multiple objects by pk
784      *
785      * @param pks List of primary keys
786      * @throws TorqueException Any exceptions caught during processing will be
787      * rethrown wrapped into a TorqueException.
788      */

789     public static List JavaDoc retrieveByPKs(List JavaDoc pks)
790         throws TorqueException
791     {
792         Connection JavaDoc db = null;
793         List JavaDoc retVal = null;
794         try
795         {
796            db = Torque.getConnection(DATABASE_NAME);
797            retVal = retrieveByPKs(pks, db);
798         }
799         finally
800         {
801             Torque.closeConnection(db);
802         }
803         return(retVal);
804     }
805
806     /**
807      * Retrieve a multiple objects by pk
808      *
809      * @param pks List of primary keys
810      * @param dbcon the connection to use
811      * @throws TorqueException Any exceptions caught during processing will be
812      * rethrown wrapped into a TorqueException.
813      */

814     public static List JavaDoc retrieveByPKs( List JavaDoc pks, Connection JavaDoc dbcon )
815         throws TorqueException
816     {
817         List JavaDoc objs = null;
818         if (pks == null || pks.size() == 0)
819         {
820             objs = new LinkedList JavaDoc();
821         }
822         else
823         {
824             Criteria criteria = new Criteria();
825               Iterator JavaDoc iter = pks.iterator();
826             while (iter.hasNext())
827             {
828                 ObjectKey pk = (ObjectKey)iter.next();
829                 SimpleKey[] keys = (SimpleKey[])pk.getValue();
830                             Criteria.Criterion c0 = criteria.getNewCriterion(
831                         QUERY_ID, keys[0], Criteria.EQUAL);
832                                     Criteria.Criterion c1 = criteria.getNewCriterion(
833                         USER_ID, keys[1], Criteria.EQUAL);
834                                     c0.and(c1);
835                           criteria.or(c0);
836             }
837           objs = doSelect(criteria, dbcon);
838         }
839         return objs;
840     }
841
842  
843     /**
844      * retrieve object using using pk values.
845      *
846        * @param query_id Long
847        * @param user_id Integer
848        */

849     public static RQueryUser retrieveByPK(
850        Long JavaDoc query_id
851           , Integer JavaDoc user_id
852               ) throws TorqueException
853     {
854         Connection JavaDoc db = null;
855         RQueryUser retVal = null;
856         try
857         {
858            db = Torque.getConnection(DATABASE_NAME);
859            retVal = retrieveByPK(
860          query_id
861           , user_id
862                      , db);
863         }
864         finally
865         {
866             Torque.closeConnection(db);
867         }
868         return(retVal);
869     }
870
871       /**
872      * retrieve object using using pk values.
873      *
874        * @param query_id Long
875        * @param user_id Integer
876        * @param con Connection
877      */

878     public static RQueryUser retrieveByPK(
879        Long JavaDoc query_id
880           , Integer JavaDoc user_id
881              ,Connection JavaDoc con) throws TorqueException
882     {
883
884         Criteria criteria = new Criteria(5);
885           criteria.add(QUERY_ID, query_id);
886           criteria.add(USER_ID, user_id);
887           List JavaDoc v = doSelect(criteria, con);
888         if (v.size() != 1)
889         {
890             throw new TorqueException("Failed to select one and only one row.");
891         }
892         else
893         {
894             return (RQueryUser) v.get(0);
895         }
896     }
897
898
899
900               
901                                               
902                 
903                 
904
905     /**
906      * selects a collection of RQueryUser objects pre-filled with their
907      * Query objects.
908      *
909      * This method is protected by default in order to keep the public
910      * api reasonable. You can provide public methods for those you
911      * actually need in RQueryUserPeer.
912      *
913      * @throws TorqueException Any exceptions caught during processing will be
914      * rethrown wrapped into a TorqueException.
915      */

916     protected static List JavaDoc doSelectJoinQuery(Criteria criteria)
917         throws TorqueException
918     {
919         setDbName(criteria);
920
921         RQueryUserPeer.addSelectColumns(criteria);
922         int offset = numColumns + 1;
923         QueryPeer.addSelectColumns(criteria);
924
925
926                         criteria.addJoin(RQueryUserPeer.QUERY_ID,
927             QueryPeer.QUERY_ID);
928         
929
930                                                               // check for conversion from boolean to int
931
if (criteria.containsKey(IS_SUBSCRIBED))
932         {
933             Object JavaDoc possibleBoolean = criteria.get(IS_SUBSCRIBED);
934             if (possibleBoolean instanceof Boolean JavaDoc)
935             {
936                 criteria.add(IS_SUBSCRIBED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
937             }
938          }
939                                                       // check for conversion from boolean to int
940
if (criteria.containsKey(ISDEFAULT))
941         {
942             Object JavaDoc possibleBoolean = criteria.get(ISDEFAULT);
943             if (possibleBoolean instanceof Boolean JavaDoc)
944             {
945                 criteria.add(ISDEFAULT, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
946             }
947          }
948                   
949         List JavaDoc rows = BasePeer.doSelect(criteria);
950         List JavaDoc results = new ArrayList JavaDoc();
951
952         for (int i = 0; i < rows.size(); i++)
953         {
954             Record row = (Record) rows.get(i);
955
956                             Class JavaDoc omClass = RQueryUserPeer.getOMClass();
957                     RQueryUser obj1 = (RQueryUser) RQueryUserPeer
958                 .row2Object(row, 1, omClass);
959                      omClass = QueryPeer.getOMClass();
960                     Query obj2 = (Query)QueryPeer
961                 .row2Object(row, offset, omClass);
962
963             boolean newObject = true;
964             for (int j = 0; j < results.size(); j++)
965             {
966                 RQueryUser temp_obj1 = (RQueryUser)results.get(j);
967                 Query temp_obj2 = (Query)temp_obj1.getQuery();
968                 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
969                 {
970                     newObject = false;
971                               temp_obj2.addRQueryUser(obj1);
972                               break;
973                 }
974             }
975                       if (newObject)
976             {
977                 obj2.initRQueryUsers();
978                 obj2.addRQueryUser(obj1);
979             }
980                       results.add(obj1);
981         }
982         return results;
983     }
984                                                             
985                         
986                 
987
988     /**
989      * selects a collection of RQueryUser objects pre-filled with their
990      * ScarabUserImpl objects.
991      *
992      * This method is protected by default in order to keep the public
993      * api reasonable. You can provide public methods for those you
994      * actually need in RQueryUserPeer.
995      *
996      * @throws TorqueException Any exceptions caught during processing will be
997      * rethrown wrapped into a TorqueException.
998      */

999     protected static List JavaDoc doSelectJoinScarabUserImpl(Criteria criteria)
1000        throws TorqueException
1001    {
1002        setDbName(criteria);
1003
1004        RQueryUserPeer.addSelectColumns(criteria);
1005        int offset = numColumns + 1;
1006        ScarabUserImplPeer.addSelectColumns(criteria);
1007
1008
1009                        criteria.addJoin(RQueryUserPeer.USER_ID,
1010            ScarabUserImplPeer.USER_ID);
1011        
1012
1013                                                              // check for conversion from boolean to int
1014
if (criteria.containsKey(IS_SUBSCRIBED))
1015        {
1016            Object JavaDoc possibleBoolean = criteria.get(IS_SUBSCRIBED);
1017            if (possibleBoolean instanceof Boolean JavaDoc)
1018            {
1019                criteria.add(IS_SUBSCRIBED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1020            }
1021         }
1022                                                      // check for conversion from boolean to int
1023
if (criteria.containsKey(ISDEFAULT))
1024        {
1025            Object JavaDoc possibleBoolean = criteria.get(ISDEFAULT);
1026            if (possibleBoolean instanceof Boolean JavaDoc)
1027            {
1028                criteria.add(ISDEFAULT, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1029            }
1030         }
1031                  
1032        List JavaDoc rows = BasePeer.doSelect(criteria);
1033        List JavaDoc results = new ArrayList JavaDoc();
1034
1035        for (int i = 0; i < rows.size(); i++)
1036        {
1037            Record row = (Record) rows.get(i);
1038
1039                            Class JavaDoc omClass = RQueryUserPeer.getOMClass();
1040                    RQueryUser obj1 = (RQueryUser) RQueryUserPeer
1041                .row2Object(row, 1, omClass);
1042                     omClass = ScarabUserImplPeer.getOMClass();
1043                    ScarabUserImpl obj2 = (ScarabUserImpl)ScarabUserImplPeer
1044                .row2Object(row, offset, omClass);
1045
1046            boolean newObject = true;
1047            for (int j = 0; j < results.size(); j++)
1048            {
1049                RQueryUser temp_obj1 = (RQueryUser)results.get(j);
1050                ScarabUserImpl temp_obj2 = (ScarabUserImpl)temp_obj1.getScarabUser();
1051                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1052                {
1053                    newObject = false;
1054                              temp_obj2.addRQueryUser(obj1);
1055                              break;
1056                }
1057            }
1058                      if (newObject)
1059            {
1060                obj2.initRQueryUsers();
1061                obj2.addRQueryUser(obj1);
1062            }
1063                      results.add(obj1);
1064        }
1065        return results;
1066    }
1067                                                            
1068                
1069                
1070
1071    /**
1072     * selects a collection of RQueryUser objects pre-filled with their
1073     * Frequency objects.
1074     *
1075     * This method is protected by default in order to keep the public
1076     * api reasonable. You can provide public methods for those you
1077     * actually need in RQueryUserPeer.
1078     *
1079     * @throws TorqueException Any exceptions caught during processing will be
1080     * rethrown wrapped into a TorqueException.
1081     */

1082    protected static List JavaDoc doSelectJoinFrequency(Criteria criteria)
1083        throws TorqueException
1084    {
1085        setDbName(criteria);
1086
1087        RQueryUserPeer.addSelectColumns(criteria);
1088        int offset = numColumns + 1;
1089        FrequencyPeer.addSelectColumns(criteria);
1090
1091
1092                        criteria.addJoin(RQueryUserPeer.SUBSCRIPTION_FREQUENCY_ID,
1093            FrequencyPeer.FREQUENCY_ID);
1094        
1095
1096                                                              // check for conversion from boolean to int
1097
if (criteria.containsKey(IS_SUBSCRIBED))
1098        {
1099            Object JavaDoc possibleBoolean = criteria.get(IS_SUBSCRIBED);
1100            if (possibleBoolean instanceof Boolean JavaDoc)
1101            {
1102                criteria.add(IS_SUBSCRIBED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1103            }
1104         }
1105                                                      // check for conversion from boolean to int
1106
if (criteria.containsKey(ISDEFAULT))
1107        {
1108            Object JavaDoc possibleBoolean = criteria.get(ISDEFAULT);
1109            if (possibleBoolean instanceof Boolean JavaDoc)
1110            {
1111                criteria.add(ISDEFAULT, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1112            }
1113         }
1114                  
1115        List JavaDoc rows = BasePeer.doSelect(criteria);
1116        List JavaDoc results = new ArrayList JavaDoc();
1117
1118        for (int i = 0; i < rows.size(); i++)
1119        {
1120            Record row = (Record) rows.get(i);
1121
1122                            Class JavaDoc omClass = RQueryUserPeer.getOMClass();
1123                    RQueryUser obj1 = (RQueryUser) RQueryUserPeer
1124                .row2Object(row, 1, omClass);
1125                     omClass = FrequencyPeer.getOMClass();
1126                    Frequency obj2 = (Frequency)FrequencyPeer
1127                .row2Object(row, offset, omClass);
1128
1129            boolean newObject = true;
1130            for (int j = 0; j < results.size(); j++)
1131            {
1132                RQueryUser temp_obj1 = (RQueryUser)results.get(j);
1133                Frequency temp_obj2 = (Frequency)temp_obj1.getFrequency();
1134                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1135                {
1136                    newObject = false;
1137                              temp_obj2.addRQueryUser(obj1);
1138                              break;
1139                }
1140            }
1141                      if (newObject)
1142            {
1143                obj2.initRQueryUsers();
1144                obj2.addRQueryUser(obj1);
1145            }
1146                      results.add(obj1);
1147        }
1148        return results;
1149    }
1150                    
1151  
1152                                    
1153          
1154        
1155                                  
1156                
1157
1158    /**
1159     * selects a collection of RQueryUser objects pre-filled with
1160     * all related objects.
1161     *
1162     * This method is protected by default in order to keep the public
1163     * api reasonable. You can provide public methods for those you
1164     * actually need in RQueryUserPeer.
1165     *
1166     * @throws TorqueException Any exceptions caught during processing will be
1167     * rethrown wrapped into a TorqueException.
1168     */

1169    protected static List JavaDoc doSelectJoinAllExceptQuery(Criteria criteria)
1170        throws TorqueException
1171    {
1172        setDbName(criteria);
1173
1174        addSelectColumns(criteria);
1175        int offset2 = numColumns + 1;
1176                                    
1177                                                  
1178                    ScarabUserImplPeer.addSelectColumns(criteria);
1179        int offset3 = offset2 + ScarabUserImplPeer.numColumns;
1180                                                                
1181                    FrequencyPeer.addSelectColumns(criteria);
1182        int offset4 = offset3 + FrequencyPeer.numColumns;
1183                                                                                                          // check for conversion from boolean to int
1184
if (criteria.containsKey(IS_SUBSCRIBED))
1185        {
1186            Object JavaDoc possibleBoolean = criteria.get(IS_SUBSCRIBED);
1187            if (possibleBoolean instanceof Boolean JavaDoc)
1188            {
1189                criteria.add(IS_SUBSCRIBED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1190            }
1191         }
1192                                                      // check for conversion from boolean to int
1193
if (criteria.containsKey(ISDEFAULT))
1194        {
1195            Object JavaDoc possibleBoolean = criteria.get(ISDEFAULT);
1196            if (possibleBoolean instanceof Boolean JavaDoc)
1197            {
1198                criteria.add(ISDEFAULT, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1199            }
1200         }
1201                  
1202        List JavaDoc rows = BasePeer.doSelect(criteria);
1203        List JavaDoc results = new ArrayList JavaDoc();
1204
1205        for (int i = 0; i < rows.size(); i++)
1206        {
1207            Record row = (Record)rows.get(i);
1208
1209                            Class JavaDoc omClass = RQueryUserPeer.getOMClass();
1210                    RQueryUser obj1 = (RQueryUser)RQueryUserPeer
1211                .row2Object(row, 1, omClass);
1212                                                
1213                                                                              
1214                                                        
1215                            
1216              
1217                           omClass = ScarabUserImplPeer.getOMClass();
1218                          ScarabUserImpl obj2 = (ScarabUserImpl)ScarabUserImplPeer
1219                .row2Object( row, offset2, omClass);
1220
1221               boolean newObject = true;
1222            for (int j = 0; j < results.size(); j++)
1223            {
1224                RQueryUser temp_obj1 = (RQueryUser)results.get(j);
1225                ScarabUserImpl temp_obj2 = (ScarabUserImpl)temp_obj1.getScarabUser();
1226                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1227                {
1228                    newObject = false;
1229                                    temp_obj2.addRQueryUser(obj1);
1230                                    break;
1231                }
1232            }
1233                            if (newObject)
1234            {
1235                obj2.initRQueryUsers();
1236                obj2.addRQueryUser(obj1);
1237            }
1238                                                                                    
1239                                                        
1240                            
1241              
1242                           omClass = FrequencyPeer.getOMClass();
1243                          Frequency obj3 = (Frequency)FrequencyPeer
1244                .row2Object( row, offset3, omClass);
1245
1246               newObject = true;
1247            for (int j = 0; j < results.size(); j++)
1248            {
1249                RQueryUser temp_obj1 = (RQueryUser)results.get(j);
1250                Frequency temp_obj3 = (Frequency)temp_obj1.getFrequency();
1251                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1252                {
1253                    newObject = false;
1254                                    temp_obj3.addRQueryUser(obj1);
1255                                    break;
1256                }
1257            }
1258                            if (newObject)
1259            {
1260                obj3.initRQueryUsers();
1261                obj3.addRQueryUser(obj1);
1262            }
1263                                                                results.add(obj1);
1264        }
1265        return results;
1266    }
1267        
1268        
1269                                  
1270                
1271
1272    /**
1273     * selects a collection of RQueryUser objects pre-filled with
1274     * all related objects.
1275     *
1276     * This method is protected by default in order to keep the public
1277     * api reasonable. You can provide public methods for those you
1278     * actually need in RQueryUserPeer.
1279     *
1280     * @throws TorqueException Any exceptions caught during processing will be
1281     * rethrown wrapped into a TorqueException.
1282     */

1283    protected static List JavaDoc doSelectJoinAllExceptScarabUserImpl(Criteria criteria)
1284        throws TorqueException
1285    {
1286        setDbName(criteria);
1287
1288        addSelectColumns(criteria);
1289        int offset2 = numColumns + 1;
1290                                    
1291                    QueryPeer.addSelectColumns(criteria);
1292        int offset3 = offset2 + QueryPeer.numColumns;
1293                                                                
1294                                                  
1295                    FrequencyPeer.addSelectColumns(criteria);
1296        int offset4 = offset3 + FrequencyPeer.numColumns;
1297                                                                                                          // check for conversion from boolean to int
1298
if (criteria.containsKey(IS_SUBSCRIBED))
1299        {
1300            Object JavaDoc possibleBoolean = criteria.get(IS_SUBSCRIBED);
1301            if (possibleBoolean instanceof Boolean JavaDoc)
1302            {
1303                criteria.add(IS_SUBSCRIBED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1304            }
1305         }
1306                                                      // check for conversion from boolean to int
1307
if (criteria.containsKey(ISDEFAULT))
1308        {
1309            Object JavaDoc possibleBoolean = criteria.get(ISDEFAULT);
1310            if (possibleBoolean instanceof Boolean JavaDoc)
1311            {
1312                criteria.add(ISDEFAULT, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1313            }
1314         }
1315                  
1316        List JavaDoc rows = BasePeer.doSelect(criteria);
1317        List JavaDoc results = new ArrayList JavaDoc();
1318
1319        for (int i = 0; i < rows.size(); i++)
1320        {
1321            Record row = (Record)rows.get(i);
1322
1323                            Class JavaDoc omClass = RQueryUserPeer.getOMClass();
1324                    RQueryUser obj1 = (RQueryUser)RQueryUserPeer
1325                .row2Object(row, 1, omClass);
1326                                                
1327                                                        
1328                            
1329              
1330                           omClass = QueryPeer.getOMClass();
1331                          Query obj2 = (Query)QueryPeer
1332                .row2Object( row, offset2, omClass);
1333
1334               boolean newObject = true;
1335            for (int j = 0; j < results.size(); j++)
1336            {
1337                RQueryUser temp_obj1 = (RQueryUser)results.get(j);
1338                Query temp_obj2 = (Query)temp_obj1.getQuery();
1339                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1340                {
1341                    newObject = false;
1342                                    temp_obj2.addRQueryUser(obj1);
1343                                    break;
1344                }
1345            }
1346                            if (newObject)
1347            {
1348                obj2.initRQueryUsers();
1349                obj2.addRQueryUser(obj1);
1350            }
1351                                                                                                
1352                                                                  
1353                                                        
1354                            
1355              
1356                           omClass = FrequencyPeer.getOMClass();
1357                          Frequency obj3 = (Frequency)FrequencyPeer
1358                .row2Object( row, offset3, omClass);
1359
1360               newObject = true;
1361            for (int j = 0; j < results.size(); j++)
1362            {
1363                RQueryUser temp_obj1 = (RQueryUser)results.get(j);
1364                Frequency temp_obj3 = (Frequency)temp_obj1.getFrequency();
1365                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1366                {
1367                    newObject = false;
1368                                    temp_obj3.addRQueryUser(obj1);
1369                                    break;
1370                }
1371            }
1372                            if (newObject)
1373            {
1374                obj3.initRQueryUsers();
1375                obj3.addRQueryUser(obj1);
1376            }
1377                                                                results.add(obj1);
1378        }
1379        return results;
1380    }
1381        
1382        
1383                                  
1384                
1385
1386    /**
1387     * selects a collection of RQueryUser objects pre-filled with
1388     * all related objects.
1389     *
1390     * This method is protected by default in order to keep the public
1391     * api reasonable. You can provide public methods for those you
1392     * actually need in RQueryUserPeer.
1393     *
1394     * @throws TorqueException Any exceptions caught during processing will be
1395     * rethrown wrapped into a TorqueException.
1396     */

1397    protected static List JavaDoc doSelectJoinAllExceptFrequency(Criteria criteria)
1398        throws TorqueException
1399    {
1400        setDbName(criteria);
1401
1402        addSelectColumns(criteria);
1403        int offset2 = numColumns + 1;
1404                                    
1405                    QueryPeer.addSelectColumns(criteria);
1406        int offset3 = offset2 + QueryPeer.numColumns;
1407                                                                
1408                    ScarabUserImplPeer.addSelectColumns(criteria);
1409        int offset4 = offset3 + ScarabUserImplPeer.numColumns;
1410                                                                
1411                                                                                            // check for conversion from boolean to int
1412
if (criteria.containsKey(IS_SUBSCRIBED))
1413        {
1414            Object JavaDoc possibleBoolean = criteria.get(IS_SUBSCRIBED);
1415            if (possibleBoolean instanceof Boolean JavaDoc)
1416            {
1417                criteria.add(IS_SUBSCRIBED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1418            }
1419         }
1420                                                      // check for conversion from boolean to int
1421
if (criteria.containsKey(ISDEFAULT))
1422        {
1423            Object JavaDoc possibleBoolean = criteria.get(ISDEFAULT);
1424            if (possibleBoolean instanceof Boolean JavaDoc)
1425            {
1426                criteria.add(ISDEFAULT, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1427            }
1428         }
1429                  
1430        List JavaDoc rows = BasePeer.doSelect(criteria);
1431        List JavaDoc results = new ArrayList JavaDoc();
1432
1433        for (int i = 0; i < rows.size(); i++)
1434        {
1435            Record row = (Record)rows.get(i);
1436
1437                            Class JavaDoc omClass = RQueryUserPeer.getOMClass();
1438                    RQueryUser obj1 = (RQueryUser)RQueryUserPeer
1439                .row2Object(row, 1, omClass);
1440                                                
1441                                                        
1442                            
1443              
1444                           omClass = QueryPeer.getOMClass();
1445                          Query obj2 = (Query)QueryPeer
1446                .row2Object( row, offset2, omClass);
1447
1448               boolean newObject = true;
1449            for (int j = 0; j < results.size(); j++)
1450            {
1451                RQueryUser temp_obj1 = (RQueryUser)results.get(j);
1452                Query temp_obj2 = (Query)temp_obj1.getQuery();
1453                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1454                {
1455                    newObject = false;
1456                                    temp_obj2.addRQueryUser(obj1);
1457                                    break;
1458                }
1459            }
1460                            if (newObject)
1461            {
1462                obj2.initRQueryUsers();
1463                obj2.addRQueryUser(obj1);
1464            }
1465                                                                                                
1466                                                        
1467                            
1468              
1469                           omClass = ScarabUserImplPeer.getOMClass();
1470                          ScarabUserImpl obj3 = (ScarabUserImpl)ScarabUserImplPeer
1471                .row2Object( row, offset3, omClass);
1472
1473               newObject = true;
1474            for (int j = 0; j < results.size(); j++)
1475            {
1476                RQueryUser temp_obj1 = (RQueryUser)results.get(j);
1477                ScarabUserImpl temp_obj3 = (ScarabUserImpl)temp_obj1.getScarabUser();
1478                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1479                {
1480                    newObject = false;
1481                                    temp_obj3.addRQueryUser(obj1);
1482                                    break;
1483                }
1484            }
1485                            if (newObject)
1486            {
1487                obj3.initRQueryUsers();
1488                obj3.addRQueryUser(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        // Set the correct dbName if it has not been overridden
1513
// crit.getDbName will return the same object if not set to
1514
// another value so == check is okay and faster
1515
if (crit.getDbName() == Torque.getDefaultDB())
1516        {
1517            crit.setDbName(DATABASE_NAME);
1518        }
1519    }
1520}
1521
Popular Tags