View Javadoc

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