View Javadoc

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