KickJava   Java API By Example, From Geeks To Geeks.

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


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 public abstract class BaseGlobalParameterPeer
38     extends BasePeer
39 {
40
41     /** the default database name for this class */
42     public static final String JavaDoc DATABASE_NAME = "scarab";
43
44      /** the table name for this class */
45     public static final String JavaDoc TABLE_NAME = "SCARAB_GLOBAL_PARAMETER";
46
47     /**
48      * @return the map builder for this peer
49      * @throws TorqueException Any exceptions caught during processing will be
50      * rethrown wrapped into a TorqueException.
51      */

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

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

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

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

198     public static ObjectKey doInsert(Criteria criteria, Connection JavaDoc con)
199         throws TorqueException
200     {
201                           
202         setDbName(criteria);
203
204         if (con == null)
205         {
206             return BasePeer.doInsert(criteria);
207         }
208         else
209         {
210             return BasePeer.doInsert(criteria, con);
211         }
212     }
213
214     /**
215      * Add all the columns needed to create a new object.
216      *
217      * @param criteria object containing the columns to add.
218      * @throws TorqueException Any exceptions caught during processing will be
219      * rethrown wrapped into a TorqueException.
220      */

221     public static void addSelectColumns(Criteria criteria)
222             throws TorqueException
223     {
224           criteria.addSelectColumn(PARAMETER_ID);
225           criteria.addSelectColumn(NAME);
226           criteria.addSelectColumn(VALUE);
227           criteria.addSelectColumn(MODULE_ID);
228       }
229
230     /**
231      * Create a new object of type cls 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 GlobalParameter row2Object(Record row,
240                                              int offset,
241                                              Class JavaDoc cls)
242         throws TorqueException
243     {
244         try
245         {
246             GlobalParameter obj = (GlobalParameter) cls.newInstance();
247             GlobalParameterPeer.populateObject(row, offset, obj);
248                   obj.setModified(false);
249               obj.setNew(false);
250
251             return obj;
252         }
253         catch (InstantiationException JavaDoc e)
254         {
255             throw new TorqueException(e);
256         }
257         catch (IllegalAccessException JavaDoc e)
258         {
259             throw new TorqueException(e);
260         }
261     }
262
263     /**
264      * Populates an object from a resultset row starting
265      * from a specified offset. This is done so that you can select
266      * other rows than just those needed for this object. You may
267      * for example want to create two objects from the same row.
268      *
269      * @throws TorqueException Any exceptions caught during processing will be
270      * rethrown wrapped into a TorqueException.
271      */

272     public static void populateObject(Record row,
273                                       int offset,
274                                       GlobalParameter obj)
275         throws TorqueException
276     {
277         try
278         {
279                 obj.setParameterId(row.getValue(offset + 0).asIntegerObj());
280                   obj.setName(row.getValue(offset + 1).asString());
281                   obj.setValue(row.getValue(offset + 2).asString());
282                   obj.setModuleId(row.getValue(offset + 3).asIntegerObj());
283               }
284         catch (DataSetException e)
285         {
286             throw new TorqueException(e);
287         }
288     }
289
290     /**
291      * Method to do selects.
292      *
293      * @param criteria object used to create the SELECT statement.
294      * @return List of selected Objects
295      * @throws TorqueException Any exceptions caught during processing will be
296      * rethrown wrapped into a TorqueException.
297      */

298     public static List JavaDoc doSelect(Criteria criteria) throws TorqueException
299     {
300         return populateObjects(doSelectVillageRecords(criteria));
301     }
302
303     /**
304      * Method to do selects within a transaction.
305      *
306      * @param criteria object used to create the SELECT statement.
307      * @param con the connection to use
308      * @return List of selected Objects
309      * @throws TorqueException Any exceptions caught during processing will be
310      * rethrown wrapped into a TorqueException.
311      */

312     public static List JavaDoc doSelect(Criteria criteria, Connection JavaDoc con)
313         throws TorqueException
314     {
315         return populateObjects(doSelectVillageRecords(criteria, con));
316     }
317
318     /**
319      * Grabs the raw Village records to be formed into objects.
320      * This method handles connections internally. The Record objects
321      * returned by this method should be considered readonly. Do not
322      * alter the data and call save(), your results may vary, but are
323      * certainly likely to result in hard to track MT bugs.
324      *
325      * @throws TorqueException Any exceptions caught during processing will be
326      * rethrown wrapped into a TorqueException.
327      */

328     public static List JavaDoc doSelectVillageRecords(Criteria criteria)
329         throws TorqueException
330     {
331         return BaseGlobalParameterPeer
332             .doSelectVillageRecords(criteria, (Connection JavaDoc) null);
333     }
334
335     /**
336      * Grabs the raw Village records to be formed into objects.
337      * This method should be used for transactions
338      *
339      * @param criteria object used to create the SELECT statement.
340      * @param con the connection to use
341      * @throws TorqueException Any exceptions caught during processing will be
342      * rethrown wrapped into a TorqueException.
343      */

344     public static List JavaDoc doSelectVillageRecords(Criteria criteria, Connection JavaDoc con)
345         throws TorqueException
346     {
347         if (criteria.getSelectColumns().size() == 0)
348         {
349             addSelectColumns(criteria);
350         }
351
352                           
353         setDbName(criteria);
354
355         // BasePeer returns a List of Value (Village) arrays. The array
356
// order follows the order columns were placed in the Select clause.
357
if (con == null)
358         {
359             return BasePeer.doSelect(criteria);
360         }
361         else
362         {
363             return BasePeer.doSelect(criteria, con);
364         }
365     }
366
367     /**
368      * The returned List will contain objects of the default type or
369      * objects that inherit from the default.
370      *
371      * @throws TorqueException Any exceptions caught during processing will be
372      * rethrown wrapped into a TorqueException.
373      */

374     public static List JavaDoc populateObjects(List JavaDoc records)
375         throws TorqueException
376     {
377         List JavaDoc results = new ArrayList JavaDoc(records.size());
378
379         // populate the object(s)
380
for (int i = 0; i < records.size(); i++)
381         {
382             Record row = (Record) records.get(i);
383               results.add(GlobalParameterPeer.row2Object(row, 1,
384                 GlobalParameterPeer.getOMClass()));
385           }
386         return results;
387     }
388  
389
390     /**
391      * The class that the Peer will make instances of.
392      * If the BO is abstract then you must implement this method
393      * in the BO.
394      *
395      * @throws TorqueException Any exceptions caught during processing will be
396      * rethrown wrapped into a TorqueException.
397      */

398     public static Class JavaDoc getOMClass()
399         throws TorqueException
400     {
401         return CLASS_DEFAULT;
402     }
403
404     /**
405      * Method to do updates.
406      *
407      * @param criteria object containing data that is used to create the UPDATE
408      * statement.
409      * @throws TorqueException Any exceptions caught during processing will be
410      * rethrown wrapped into a TorqueException.
411      */

412     public static void doUpdate(Criteria criteria) throws TorqueException
413     {
414          BaseGlobalParameterPeer
415             .doUpdate(criteria, (Connection JavaDoc) null);
416     }
417
418     /**
419      * Method to do updates. This method is to be used during a transaction,
420      * otherwise use the doUpdate(Criteria) method. It will take care of
421      * the connection details internally.
422      *
423      * @param criteria object containing data that is used to create the UPDATE
424      * statement.
425      * @param con the connection to use
426      * @throws TorqueException Any exceptions caught during processing will be
427      * rethrown wrapped into a TorqueException.
428      */

429     public static void doUpdate(Criteria criteria, Connection JavaDoc con)
430         throws TorqueException
431     {
432         Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
433                    selectCriteria.put(PARAMETER_ID, criteria.remove(PARAMETER_ID));
434                                     
435         setDbName(criteria);
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          GlobalParameterPeer
457             .doDelete(criteria, (Connection JavaDoc) 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 JavaDoc con)
471         throws TorqueException
472      {
473                           
474         setDbName(criteria);
475
476         if (con == null)
477         {
478             BasePeer.doDelete(criteria);
479         }
480         else
481         {
482             BasePeer.doDelete(criteria, con);
483         }
484      }
485
486     /**
487      * Method to do selects
488      *
489      * @throws TorqueException Any exceptions caught during processing will be
490      * rethrown wrapped into a TorqueException.
491      */

492     public static List JavaDoc doSelect(GlobalParameter obj) throws TorqueException
493     {
494         return doSelect(buildSelectCriteria(obj));
495     }
496
497     /**
498      * Method to do inserts
499      *
500      * @throws TorqueException Any exceptions caught during processing will be
501      * rethrown wrapped into a TorqueException.
502      */

503     public static void doInsert(GlobalParameter obj) throws TorqueException
504     {
505           obj.setPrimaryKey(doInsert(buildCriteria(obj)));
506           obj.setNew(false);
507         obj.setModified(false);
508     }
509
510     /**
511      * @param obj the data object to update in the database.
512      * @throws TorqueException Any exceptions caught during processing will be
513      * rethrown wrapped into a TorqueException.
514      */

515     public static void doUpdate(GlobalParameter obj) throws TorqueException
516     {
517         doUpdate(buildCriteria(obj));
518         obj.setModified(false);
519     }
520
521     /**
522      * @param obj the data object to delete in the database.
523      * @throws TorqueException Any exceptions caught during processing will be
524      * rethrown wrapped into a TorqueException.
525      */

526     public static void doDelete(GlobalParameter obj) throws TorqueException
527     {
528         doDelete(buildSelectCriteria(obj));
529     }
530
531     /**
532      * Method to do inserts. This method is to be used during a transaction,
533      * otherwise use the doInsert(GlobalParameter) method. It will take
534      * care of the connection details internally.
535      *
536      * @param obj the data object to insert into the database.
537      * @param con the connection to use
538      * @throws TorqueException Any exceptions caught during processing will be
539      * rethrown wrapped into a TorqueException.
540      */

541     public static void doInsert(GlobalParameter obj, Connection JavaDoc con)
542         throws TorqueException
543     {
544           obj.setPrimaryKey(doInsert(buildCriteria(obj), con));
545           obj.setNew(false);
546         obj.setModified(false);
547     }
548
549     /**
550      * Method to do update. This method is to be used during a transaction,
551      * otherwise use the doUpdate(GlobalParameter) method. It will take
552      * care of the connection details internally.
553      *
554      * @param obj the data object to update in the database.
555      * @param con the connection to use
556      * @throws TorqueException Any exceptions caught during processing will be
557      * rethrown wrapped into a TorqueException.
558      */

559     public static void doUpdate(GlobalParameter obj, Connection JavaDoc con)
560         throws TorqueException
561     {
562         doUpdate(buildCriteria(obj), con);
563         obj.setModified(false);
564     }
565
566     /**
567      * Method to delete. This method is to be used during a transaction,
568      * otherwise use the doDelete(GlobalParameter) method. It will take
569      * care of the connection details internally.
570      *
571      * @param obj the data object to delete in the database.
572      * @param con the connection to use
573      * @throws TorqueException Any exceptions caught during processing will be
574      * rethrown wrapped into a TorqueException.
575      */

576     public static void doDelete(GlobalParameter obj, Connection JavaDoc con)
577         throws TorqueException
578     {
579         doDelete(buildSelectCriteria(obj), con);
580     }
581
582     /**
583      * Method to do deletes.
584      *
585      * @param pk ObjectKey that is used DELETE from database.
586      * @throws TorqueException Any exceptions caught during processing will be
587      * rethrown wrapped into a TorqueException.
588      */

589     public static void doDelete(ObjectKey pk) throws TorqueException
590     {
591         BaseGlobalParameterPeer
592            .doDelete(pk, (Connection JavaDoc) null);
593     }
594
595     /**
596      * Method to delete. This method is to be used during a transaction,
597      * otherwise use the doDelete(ObjectKey) method. It will take
598      * care of the connection details internally.
599      *
600      * @param pk the primary key for the object to delete in the database.
601      * @param con the connection to use
602      * @throws TorqueException Any exceptions caught during processing will be
603      * rethrown wrapped into a TorqueException.
604      */

605     public static void doDelete(ObjectKey pk, Connection JavaDoc con)
606         throws TorqueException
607     {
608         doDelete(buildCriteria(pk), con);
609     }
610
611     /** Build a Criteria object from an ObjectKey */
612     public static Criteria buildCriteria( ObjectKey pk )
613     {
614         Criteria criteria = new Criteria();
615               criteria.add(PARAMETER_ID, pk);
616           return criteria;
617      }
618
619     /** Build a Criteria object from the data object for this peer */
620     public static Criteria buildCriteria( GlobalParameter obj )
621     {
622         Criteria criteria = new Criteria(DATABASE_NAME);
623               if (!obj.isNew())
624             criteria.add(PARAMETER_ID, obj.getParameterId());
625               criteria.add(NAME, obj.getName());
626               criteria.add(VALUE, obj.getValue());
627               criteria.add(MODULE_ID, obj.getModuleId());
628           return criteria;
629     }
630
631     /** Build a Criteria object from the data object for this peer, skipping all binary columns */
632     public static Criteria buildSelectCriteria( GlobalParameter obj )
633     {
634         Criteria criteria = new Criteria(DATABASE_NAME);
635               if (!obj.isNew())
636                     criteria.add(PARAMETER_ID, obj.getParameterId());
637                           criteria.add(NAME, obj.getName());
638                           criteria.add(VALUE, obj.getValue());
639                           criteria.add(MODULE_ID, obj.getModuleId());
640               return criteria;
641     }
642  
643     
644         /**
645      * Retrieve a single object by pk
646      *
647      * @param pk the primary key
648      * @throws TorqueException Any exceptions caught during processing will be
649      * rethrown wrapped into a TorqueException.
650      * @throws NoRowsException Primary key was not found in database.
651      * @throws TooManyRowsException Primary key was not found in database.
652      */

653     public static GlobalParameter retrieveByPK(Integer JavaDoc pk)
654         throws TorqueException, NoRowsException, TooManyRowsException
655     {
656         return retrieveByPK(SimpleKey.keyFor(pk));
657     }
658
659     /**
660      * Retrieve a single object by pk
661      *
662      * @param pk the primary key
663      * @param con the connection to use
664      * @throws TorqueException Any exceptions caught during processing will be
665      * rethrown wrapped into a TorqueException.
666      * @throws NoRowsException Primary key was not found in database.
667      * @throws TooManyRowsException Primary key was not found in database.
668      */

669     public static GlobalParameter retrieveByPK(Integer JavaDoc pk, Connection JavaDoc con)
670         throws TorqueException, NoRowsException, TooManyRowsException
671     {
672         return retrieveByPK(SimpleKey.keyFor(pk), con);
673     }
674   
675     /**
676      * Retrieve a single object by pk
677      *
678      * @param pk the primary key
679      * @throws TorqueException Any exceptions caught during processing will be
680      * rethrown wrapped into a TorqueException.
681      * @throws NoRowsException Primary key was not found in database.
682      * @throws TooManyRowsException Primary key was not found in database.
683      */

684     public static GlobalParameter retrieveByPK(ObjectKey pk)
685         throws TorqueException, NoRowsException, TooManyRowsException
686     {
687         Connection JavaDoc db = null;
688         GlobalParameter retVal = null;
689         try
690         {
691             db = Torque.getConnection(DATABASE_NAME);
692             retVal = retrieveByPK(pk, db);
693         }
694         finally
695         {
696             Torque.closeConnection(db);
697         }
698         return(retVal);
699     }
700
701     /**
702      * Retrieve a single object by pk
703      *
704      * @param pk the primary key
705      * @param con the connection to use
706      * @throws TorqueException Any exceptions caught during processing will be
707      * rethrown wrapped into a TorqueException.
708      * @throws NoRowsException Primary key was not found in database.
709      * @throws TooManyRowsException Primary key was not found in database.
710      */

711     public static GlobalParameter retrieveByPK(ObjectKey pk, Connection JavaDoc con)
712         throws TorqueException, NoRowsException, TooManyRowsException
713     {
714         Criteria criteria = buildCriteria(pk);
715         List JavaDoc v = doSelect(criteria, con);
716         if (v.size() == 0)
717         {
718             throw new NoRowsException("Failed to select a row.");
719         }
720         else if (v.size() > 1)
721         {
722             throw new TooManyRowsException("Failed to select only one row.");
723         }
724         else
725         {
726             return (GlobalParameter)v.get(0);
727         }
728     }
729
730     /**
731      * Retrieve a multiple objects by pk
732      *
733      * @param pks List of primary keys
734      * @throws TorqueException Any exceptions caught during processing will be
735      * rethrown wrapped into a TorqueException.
736      */

737     public static List JavaDoc retrieveByPKs(List JavaDoc pks)
738         throws TorqueException
739     {
740         Connection JavaDoc db = null;
741         List JavaDoc retVal = null;
742         try
743         {
744            db = Torque.getConnection(DATABASE_NAME);
745            retVal = retrieveByPKs(pks, db);
746         }
747         finally
748         {
749             Torque.closeConnection(db);
750         }
751         return(retVal);
752     }
753
754     /**
755      * Retrieve a multiple objects by pk
756      *
757      * @param pks List of primary keys
758      * @param dbcon the connection to use
759      * @throws TorqueException Any exceptions caught during processing will be
760      * rethrown wrapped into a TorqueException.
761      */

762     public static List JavaDoc retrieveByPKs( List JavaDoc pks, Connection JavaDoc dbcon )
763         throws TorqueException
764     {
765         List JavaDoc objs = null;
766         if (pks == null || pks.size() == 0)
767         {
768             objs = new LinkedList JavaDoc();
769         }
770         else
771         {
772             Criteria criteria = new Criteria();
773               criteria.addIn( PARAMETER_ID, pks );
774           objs = doSelect(criteria, dbcon);
775         }
776         return objs;
777     }
778
779  
780
781
782
783           
784                                               
785                         
786                 
787
788     /**
789      * selects a collection of GlobalParameter objects pre-filled with their
790      * ScarabModule objects.
791      *
792      * This method is protected by default in order to keep the public
793      * api reasonable. You can provide public methods for those you
794      * actually need in GlobalParameterPeer.
795      *
796      * @throws TorqueException Any exceptions caught during processing will be
797      * rethrown wrapped into a TorqueException.
798      */

799     protected static List JavaDoc doSelectJoinScarabModule(Criteria criteria)
800         throws TorqueException
801     {
802         setDbName(criteria);
803
804         GlobalParameterPeer.addSelectColumns(criteria);
805         int offset = numColumns + 1;
806         ScarabModulePeer.addSelectColumns(criteria);
807
808
809                         criteria.addJoin(GlobalParameterPeer.MODULE_ID,
810             ScarabModulePeer.MODULE_ID);
811         
812
813                                                                                 
814         List JavaDoc rows = BasePeer.doSelect(criteria);
815         List JavaDoc results = new ArrayList JavaDoc();
816
817         for (int i = 0; i < rows.size(); i++)
818         {
819             Record row = (Record) rows.get(i);
820
821                             Class JavaDoc omClass = GlobalParameterPeer.getOMClass();
822                     GlobalParameter obj1 = (GlobalParameter) GlobalParameterPeer
823                 .row2Object(row, 1, omClass);
824                      omClass = ScarabModulePeer.getOMClass(row, offset);
825                     ScarabModule obj2 = (ScarabModule)ScarabModulePeer
826                 .row2Object(row, offset, omClass);
827
828             boolean newObject = true;
829             for (int j = 0; j < results.size(); j++)
830             {
831                 GlobalParameter temp_obj1 = (GlobalParameter)results.get(j);
832                 ScarabModule temp_obj2 = (ScarabModule)temp_obj1.getModule();
833                 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
834                 {
835                     newObject = false;
836                               temp_obj2.addGlobalParameter(obj1);
837                               break;
838                 }
839             }
840                       if (newObject)
841             {
842                 obj2.initGlobalParameters();
843                 obj2.addGlobalParameter(obj1);
844             }
845                       results.add(obj1);
846         }
847         return results;
848     }
849                     
850   
851     
852   
853       /**
854      * Returns the TableMap related to this peer. This method is not
855      * needed for general use but a specific application could have a need.
856      *
857      * @throws TorqueException Any exceptions caught during processing will be
858      * rethrown wrapped into a TorqueException.
859      */

860     protected static TableMap getTableMap()
861         throws TorqueException
862     {
863         return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME);
864     }
865    
866     private static void setDbName(Criteria crit)
867     {
868         // Set the correct dbName if it has not been overridden
869
// crit.getDbName will return the same object if not set to
870
// another value so == check is okay and faster
871
if (crit.getDbName() == Torque.getDefaultDB())
872         {
873             crit.setDbName(DATABASE_NAME);
874         }
875     }
876 }
877
Popular Tags