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