KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

55     public static MapBuilder getMapBuilder()
56         throws TorqueException
57     {
58         return getMapBuilder(AttachmentMapBuilder.CLASS_NAME);
59     }
60
61       /** the column name for the ATTACHMENT_ID field */
62     public static final String JavaDoc ATTACHMENT_ID;
63       /** the column name for the ISSUE_ID field */
64     public static final String JavaDoc ISSUE_ID;
65       /** the column name for the ATTACHMENT_TYPE_ID field */
66     public static final String JavaDoc ATTACHMENT_TYPE_ID;
67       /** the column name for the ATTACHMENT_NAME field */
68     public static final String JavaDoc ATTACHMENT_NAME;
69       /** the column name for the ATTACHMENT_DATA field */
70     public static final String JavaDoc ATTACHMENT_DATA;
71       /** the column name for the ATTACHMENT_FILE_PATH field */
72     public static final String JavaDoc ATTACHMENT_FILE_PATH;
73       /** the column name for the ATTACHMENT_MIME_TYPE field */
74     public static final String JavaDoc ATTACHMENT_MIME_TYPE;
75       /** the column name for the MODIFIED_BY field */
76     public static final String JavaDoc MODIFIED_BY;
77       /** the column name for the CREATED_BY field */
78     public static final String JavaDoc CREATED_BY;
79       /** the column name for the MODIFIED_DATE field */
80     public static final String JavaDoc MODIFIED_DATE;
81       /** the column name for the CREATED_DATE field */
82     public static final String JavaDoc CREATED_DATE;
83       /** the column name for the DELETED field */
84     public static final String JavaDoc DELETED;
85   
86     static
87     {
88           ATTACHMENT_ID = "SCARAB_ATTACHMENT.ATTACHMENT_ID";
89           ISSUE_ID = "SCARAB_ATTACHMENT.ISSUE_ID";
90           ATTACHMENT_TYPE_ID = "SCARAB_ATTACHMENT.ATTACHMENT_TYPE_ID";
91           ATTACHMENT_NAME = "SCARAB_ATTACHMENT.ATTACHMENT_NAME";
92           ATTACHMENT_DATA = "SCARAB_ATTACHMENT.ATTACHMENT_DATA";
93           ATTACHMENT_FILE_PATH = "SCARAB_ATTACHMENT.ATTACHMENT_FILE_PATH";
94           ATTACHMENT_MIME_TYPE = "SCARAB_ATTACHMENT.ATTACHMENT_MIME_TYPE";
95           MODIFIED_BY = "SCARAB_ATTACHMENT.MODIFIED_BY";
96           CREATED_BY = "SCARAB_ATTACHMENT.CREATED_BY";
97           MODIFIED_DATE = "SCARAB_ATTACHMENT.MODIFIED_DATE";
98           CREATED_DATE = "SCARAB_ATTACHMENT.CREATED_DATE";
99           DELETED = "SCARAB_ATTACHMENT.DELETED";
100           if (Torque.isInit())
101         {
102             try
103             {
104                 getMapBuilder(AttachmentMapBuilder.CLASS_NAME);
105             }
106             catch (Exception JavaDoc e)
107             {
108                 log.error("Could not initialize Peer", e);
109             }
110         }
111         else
112         {
113             Torque.registerMapBuilder(AttachmentMapBuilder.CLASS_NAME);
114         }
115     }
116  
117     /** number of columns for this peer */
118     public static final int numColumns = 12;
119
120     /** A class that can be returned by this peer. */
121     protected static final String JavaDoc CLASSNAME_DEFAULT =
122         "org.tigris.scarab.om.Attachment";
123
124     /** A class that can be returned by this peer. */
125     protected static final Class JavaDoc CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT);
126
127     /**
128      * Class object initialization method.
129      *
130      * @param className name of the class to initialize
131      * @return the initialized class
132      */

133     private static Class JavaDoc initClass(String JavaDoc className)
134     {
135         Class JavaDoc c = null;
136         try
137         {
138             c = Class.forName(className);
139         }
140         catch (Throwable JavaDoc t)
141         {
142             log.error("A FATAL ERROR has occurred which should not "
143                 + "have happened under any circumstance. Please notify "
144                 + "the Torque developers <torque-dev@db.apache.org> "
145                 + "and give as many details as possible (including the error "
146                 + "stack trace).", t);
147
148             // Error objects should always be propogated.
149
if (t instanceof Error JavaDoc)
150             {
151                 throw (Error JavaDoc) t.fillInStackTrace();
152             }
153         }
154         return c;
155     }
156
157     /**
158      * Get the list of objects for a ResultSet. Please not that your
159      * resultset MUST return columns in the right order. You can use
160      * getFieldNames() in BaseObject to get the correct sequence.
161      *
162      * @param results the ResultSet
163      * @return the list of objects
164      * @throws TorqueException Any exceptions caught during processing will be
165      * rethrown wrapped into a TorqueException.
166      */

167     public static List JavaDoc resultSet2Objects(java.sql.ResultSet JavaDoc results)
168             throws TorqueException
169     {
170         try
171         {
172             QueryDataSet qds = null;
173             List JavaDoc rows = null;
174             try
175             {
176                 qds = new QueryDataSet(results);
177                 rows = getSelectResults(qds);
178             }
179             finally
180             {
181                 if (qds != null)
182                 {
183                     qds.close();
184                 }
185             }
186
187             return populateObjects(rows);
188         }
189         catch (SQLException JavaDoc e)
190         {
191             throw new TorqueException(e);
192         }
193         catch (DataSetException e)
194         {
195             throw new TorqueException(e);
196         }
197     }
198
199
200   
201     /**
202      * Method to do inserts.
203      *
204      * @param criteria object used to create the INSERT statement.
205      * @throws TorqueException Any exceptions caught during processing will be
206      * rethrown wrapped into a TorqueException.
207      */

208     public static ObjectKey doInsert(Criteria criteria)
209         throws TorqueException
210     {
211         return BaseAttachmentPeer
212             .doInsert(criteria, (Connection JavaDoc) null);
213     }
214
215     /**
216      * Method to do inserts. This method is to be used during a transaction,
217      * otherwise use the doInsert(Criteria) method. It will take care of
218      * the connection details internally.
219      *
220      * @param criteria object used to create the INSERT statement.
221      * @param con the connection to use
222      * @throws TorqueException Any exceptions caught during processing will be
223      * rethrown wrapped into a TorqueException.
224      */

225     public static ObjectKey doInsert(Criteria criteria, Connection JavaDoc con)
226         throws TorqueException
227     {
228                                                                                 // check for conversion from boolean to int
229
if (criteria.containsKey(DELETED))
230         {
231             Object JavaDoc possibleBoolean = criteria.get(DELETED);
232             if (possibleBoolean instanceof Boolean JavaDoc)
233             {
234                 criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
235             }
236          }
237       
238         setDbName(criteria);
239
240         if (con == null)
241         {
242             return BasePeer.doInsert(criteria);
243         }
244         else
245         {
246             return BasePeer.doInsert(criteria, con);
247         }
248     }
249
250     /**
251      * Add all the columns needed to create a new object.
252      *
253      * @param criteria object containing the columns to add.
254      * @throws TorqueException Any exceptions caught during processing will be
255      * rethrown wrapped into a TorqueException.
256      */

257     public static void addSelectColumns(Criteria criteria)
258             throws TorqueException
259     {
260           criteria.addSelectColumn(ATTACHMENT_ID);
261           criteria.addSelectColumn(ISSUE_ID);
262           criteria.addSelectColumn(ATTACHMENT_TYPE_ID);
263           criteria.addSelectColumn(ATTACHMENT_NAME);
264           criteria.addSelectColumn(ATTACHMENT_DATA);
265           criteria.addSelectColumn(ATTACHMENT_FILE_PATH);
266           criteria.addSelectColumn(ATTACHMENT_MIME_TYPE);
267           criteria.addSelectColumn(MODIFIED_BY);
268           criteria.addSelectColumn(CREATED_BY);
269           criteria.addSelectColumn(MODIFIED_DATE);
270           criteria.addSelectColumn(CREATED_DATE);
271           criteria.addSelectColumn(DELETED);
272       }
273
274     /**
275      * Create a new object of type cls from a resultset row starting
276      * from a specified offset. This is done so that you can select
277      * other rows than just those needed for this object. You may
278      * for example want to create two objects from the same row.
279      *
280      * @throws TorqueException Any exceptions caught during processing will be
281      * rethrown wrapped into a TorqueException.
282      */

283     public static Attachment row2Object(Record row,
284                                              int offset,
285                                              Class JavaDoc cls)
286         throws TorqueException
287     {
288         try
289         {
290             Attachment obj = (Attachment) cls.newInstance();
291             AttachmentPeer.populateObject(row, offset, obj);
292                   obj.setModified(false);
293               obj.setNew(false);
294
295             return obj;
296         }
297         catch (InstantiationException JavaDoc e)
298         {
299             throw new TorqueException(e);
300         }
301         catch (IllegalAccessException JavaDoc e)
302         {
303             throw new TorqueException(e);
304         }
305     }
306
307     /**
308      * Populates an object from a resultset row starting
309      * from a specified offset. This is done so that you can select
310      * other rows than just those needed for this object. You may
311      * for example want to create two objects from the same row.
312      *
313      * @throws TorqueException Any exceptions caught during processing will be
314      * rethrown wrapped into a TorqueException.
315      */

316     public static void populateObject(Record row,
317                                       int offset,
318                                       Attachment obj)
319         throws TorqueException
320     {
321         try
322         {
323                 obj.setAttachmentId(row.getValue(offset + 0).asLongObj());
324                   obj.setIssueId(row.getValue(offset + 1).asLongObj());
325                   obj.setTypeId(row.getValue(offset + 2).asIntegerObj());
326                   obj.setName(row.getValue(offset + 3).asString());
327                   obj.setData(row.getValue(offset + 4).asString());
328                   obj.setFileName(row.getValue(offset + 5).asString());
329                   obj.setMimeType(row.getValue(offset + 6).asString());
330                   obj.setModifiedBy(row.getValue(offset + 7).asIntegerObj());
331                   obj.setCreatedBy(row.getValue(offset + 8).asIntegerObj());
332                   obj.setModifiedDate(row.getValue(offset + 9).asUtilDate());
333                   obj.setCreatedDate(row.getValue(offset + 10).asUtilDate());
334                   obj.setDeleted(row.getValue(offset + 11).asBoolean());
335               }
336         catch (DataSetException e)
337         {
338             throw new TorqueException(e);
339         }
340     }
341
342     /**
343      * Method to do selects.
344      *
345      * @param criteria object used to create the SELECT statement.
346      * @return List of selected Objects
347      * @throws TorqueException Any exceptions caught during processing will be
348      * rethrown wrapped into a TorqueException.
349      */

350     public static List JavaDoc doSelect(Criteria criteria) throws TorqueException
351     {
352         return populateObjects(doSelectVillageRecords(criteria));
353     }
354
355     /**
356      * Method to do selects within a transaction.
357      *
358      * @param criteria object used to create the SELECT statement.
359      * @param con the connection to use
360      * @return List of selected Objects
361      * @throws TorqueException Any exceptions caught during processing will be
362      * rethrown wrapped into a TorqueException.
363      */

364     public static List JavaDoc doSelect(Criteria criteria, Connection JavaDoc con)
365         throws TorqueException
366     {
367         return populateObjects(doSelectVillageRecords(criteria, con));
368     }
369
370     /**
371      * Grabs the raw Village records to be formed into objects.
372      * This method handles connections internally. The Record objects
373      * returned by this method should be considered readonly. Do not
374      * alter the data and call save(), your results may vary, but are
375      * certainly likely to result in hard to track MT bugs.
376      *
377      * @throws TorqueException Any exceptions caught during processing will be
378      * rethrown wrapped into a TorqueException.
379      */

380     public static List JavaDoc doSelectVillageRecords(Criteria criteria)
381         throws TorqueException
382     {
383         return BaseAttachmentPeer
384             .doSelectVillageRecords(criteria, (Connection JavaDoc) null);
385     }
386
387     /**
388      * Grabs the raw Village records to be formed into objects.
389      * This method should be used for transactions
390      *
391      * @param criteria object used to create the SELECT statement.
392      * @param con the connection to use
393      * @throws TorqueException Any exceptions caught during processing will be
394      * rethrown wrapped into a TorqueException.
395      */

396     public static List JavaDoc doSelectVillageRecords(Criteria criteria, Connection JavaDoc con)
397         throws TorqueException
398     {
399         if (criteria.getSelectColumns().size() == 0)
400         {
401             addSelectColumns(criteria);
402         }
403
404                                                                                 // check for conversion from boolean to int
405
if (criteria.containsKey(DELETED))
406         {
407             Object JavaDoc possibleBoolean = criteria.get(DELETED);
408             if (possibleBoolean instanceof Boolean JavaDoc)
409             {
410                 criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
411             }
412          }
413       
414         setDbName(criteria);
415
416         // BasePeer returns a List of Value (Village) arrays. The array
417
// order follows the order columns were placed in the Select clause.
418
if (con == null)
419         {
420             return BasePeer.doSelect(criteria);
421         }
422         else
423         {
424             return BasePeer.doSelect(criteria, con);
425         }
426     }
427
428     /**
429      * The returned List will contain objects of the default type or
430      * objects that inherit from the default.
431      *
432      * @throws TorqueException Any exceptions caught during processing will be
433      * rethrown wrapped into a TorqueException.
434      */

435     public static List JavaDoc populateObjects(List JavaDoc records)
436         throws TorqueException
437     {
438         List JavaDoc results = new ArrayList JavaDoc(records.size());
439
440         // populate the object(s)
441
for (int i = 0; i < records.size(); i++)
442         {
443             Record row = (Record) records.get(i);
444               results.add(AttachmentPeer.row2Object(row, 1,
445                 AttachmentPeer.getOMClass()));
446           }
447         return results;
448     }
449  
450
451     /**
452      * The class that the Peer will make instances of.
453      * If the BO is abstract then you must implement this method
454      * in the BO.
455      *
456      * @throws TorqueException Any exceptions caught during processing will be
457      * rethrown wrapped into a TorqueException.
458      */

459     public static Class JavaDoc getOMClass()
460         throws TorqueException
461     {
462         return CLASS_DEFAULT;
463     }
464
465     /**
466      * Method to do updates.
467      *
468      * @param criteria object containing data that is used to create the UPDATE
469      * statement.
470      * @throws TorqueException Any exceptions caught during processing will be
471      * rethrown wrapped into a TorqueException.
472      */

473     public static void doUpdate(Criteria criteria) throws TorqueException
474     {
475          BaseAttachmentPeer
476             .doUpdate(criteria, (Connection JavaDoc) null);
477     }
478
479     /**
480      * Method to do updates. This method is to be used during a transaction,
481      * otherwise use the doUpdate(Criteria) method. It will take care of
482      * the connection details internally.
483      *
484      * @param criteria object containing data that is used to create the UPDATE
485      * statement.
486      * @param con the connection to use
487      * @throws TorqueException Any exceptions caught during processing will be
488      * rethrown wrapped into a TorqueException.
489      */

490     public static void doUpdate(Criteria criteria, Connection JavaDoc con)
491         throws TorqueException
492     {
493         Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
494                    selectCriteria.put(ATTACHMENT_ID, criteria.remove(ATTACHMENT_ID));
495                                                                                                                       // check for conversion from boolean to int
496
if (criteria.containsKey(DELETED))
497         {
498             Object JavaDoc possibleBoolean = criteria.get(DELETED);
499             if (possibleBoolean instanceof Boolean JavaDoc)
500             {
501                 criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
502             }
503          }
504           
505         setDbName(criteria);
506
507         if (con == null)
508         {
509             BasePeer.doUpdate(selectCriteria, criteria);
510         }
511         else
512         {
513             BasePeer.doUpdate(selectCriteria, criteria, con);
514         }
515     }
516
517     /**
518      * Method to do deletes.
519      *
520      * @param criteria object containing data that is used DELETE from database.
521      * @throws TorqueException Any exceptions caught during processing will be
522      * rethrown wrapped into a TorqueException.
523      */

524      public static void doDelete(Criteria criteria) throws TorqueException
525      {
526          AttachmentPeer
527             .doDelete(criteria, (Connection JavaDoc) null);
528      }
529
530     /**
531      * Method to do deletes. This method is to be used during a transaction,
532      * otherwise use the doDelete(Criteria) method. It will take care of
533      * the connection details internally.
534      *
535      * @param criteria object containing data that is used DELETE from database.
536      * @param con the connection to use
537      * @throws TorqueException Any exceptions caught during processing will be
538      * rethrown wrapped into a TorqueException.
539      */

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

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

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

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

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

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

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

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

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

684     public static void doDelete(ObjectKey pk, Connection JavaDoc con)
685         throws TorqueException
686     {
687         doDelete(buildCriteria(pk), con);
688     }
689
690     /** Build a Criteria object from an ObjectKey */
691     public static Criteria buildCriteria( ObjectKey pk )
692     {
693         Criteria criteria = new Criteria();
694               criteria.add(ATTACHMENT_ID, pk);
695           return criteria;
696      }
697
698     /** Build a Criteria object from the data object for this peer */
699     public static Criteria buildCriteria( Attachment obj )
700     {
701         Criteria criteria = new Criteria(DATABASE_NAME);
702               if (!obj.isNew())
703             criteria.add(ATTACHMENT_ID, obj.getAttachmentId());
704               criteria.add(ISSUE_ID, obj.getIssueId());
705               criteria.add(ATTACHMENT_TYPE_ID, obj.getTypeId());
706               criteria.add(ATTACHMENT_NAME, obj.getName());
707               criteria.add(ATTACHMENT_DATA, obj.getData());
708               criteria.add(ATTACHMENT_FILE_PATH, obj.getFileName());
709               criteria.add(ATTACHMENT_MIME_TYPE, obj.getMimeType());
710               criteria.add(MODIFIED_BY, obj.getModifiedBy());
711               criteria.add(CREATED_BY, obj.getCreatedBy());
712               criteria.add(MODIFIED_DATE, obj.getModifiedDate());
713               criteria.add(CREATED_DATE, obj.getCreatedDate());
714               criteria.add(DELETED, obj.getDeleted());
715           return criteria;
716     }
717
718     /** Build a Criteria object from the data object for this peer, skipping all binary columns */
719     public static Criteria buildSelectCriteria( Attachment obj )
720     {
721         Criteria criteria = new Criteria(DATABASE_NAME);
722               if (!obj.isNew())
723                     criteria.add(ATTACHMENT_ID, obj.getAttachmentId());
724                           criteria.add(ISSUE_ID, obj.getIssueId());
725                           criteria.add(ATTACHMENT_TYPE_ID, obj.getTypeId());
726                           criteria.add(ATTACHMENT_NAME, obj.getName());
727                           criteria.add(ATTACHMENT_DATA, obj.getData());
728                           criteria.add(ATTACHMENT_FILE_PATH, obj.getFileName());
729                           criteria.add(ATTACHMENT_MIME_TYPE, obj.getMimeType());
730                           criteria.add(MODIFIED_BY, obj.getModifiedBy());
731                           criteria.add(CREATED_BY, obj.getCreatedBy());
732                           criteria.add(MODIFIED_DATE, obj.getModifiedDate());
733                           criteria.add(CREATED_DATE, obj.getCreatedDate());
734                           criteria.add(DELETED, obj.getDeleted());
735               return criteria;
736     }
737  
738     
739         /**
740      * Retrieve a single object by pk
741      *
742      * @param pk the primary key
743      * @throws TorqueException Any exceptions caught during processing will be
744      * rethrown wrapped into a TorqueException.
745      * @throws NoRowsException Primary key was not found in database.
746      * @throws TooManyRowsException Primary key was not found in database.
747      */

748     public static Attachment retrieveByPK(Long JavaDoc pk)
749         throws TorqueException, NoRowsException, TooManyRowsException
750     {
751         return retrieveByPK(SimpleKey.keyFor(pk));
752     }
753
754     /**
755      * Retrieve a single object by pk
756      *
757      * @param pk the primary key
758      * @param con the connection to use
759      * @throws TorqueException Any exceptions caught during processing will be
760      * rethrown wrapped into a TorqueException.
761      * @throws NoRowsException Primary key was not found in database.
762      * @throws TooManyRowsException Primary key was not found in database.
763      */

764     public static Attachment retrieveByPK(Long JavaDoc pk, Connection JavaDoc con)
765         throws TorqueException, NoRowsException, TooManyRowsException
766     {
767         return retrieveByPK(SimpleKey.keyFor(pk), con);
768     }
769   
770     /**
771      * Retrieve a single object by pk
772      *
773      * @param pk the primary key
774      * @throws TorqueException Any exceptions caught during processing will be
775      * rethrown wrapped into a TorqueException.
776      * @throws NoRowsException Primary key was not found in database.
777      * @throws TooManyRowsException Primary key was not found in database.
778      */

779     public static Attachment retrieveByPK(ObjectKey pk)
780         throws TorqueException, NoRowsException, TooManyRowsException
781     {
782         Connection JavaDoc db = null;
783         Attachment retVal = null;
784         try
785         {
786             db = Torque.getConnection(DATABASE_NAME);
787             retVal = retrieveByPK(pk, db);
788         }
789         finally
790         {
791             Torque.closeConnection(db);
792         }
793         return(retVal);
794     }
795
796     /**
797      * Retrieve a single object by pk
798      *
799      * @param pk the primary key
800      * @param con the connection to use
801      * @throws TorqueException Any exceptions caught during processing will be
802      * rethrown wrapped into a TorqueException.
803      * @throws NoRowsException Primary key was not found in database.
804      * @throws TooManyRowsException Primary key was not found in database.
805      */

806     public static Attachment retrieveByPK(ObjectKey pk, Connection JavaDoc con)
807         throws TorqueException, NoRowsException, TooManyRowsException
808     {
809         Criteria criteria = buildCriteria(pk);
810         List JavaDoc v = doSelect(criteria, con);
811         if (v.size() == 0)
812         {
813             throw new NoRowsException("Failed to select a row.");
814         }
815         else if (v.size() > 1)
816         {
817             throw new TooManyRowsException("Failed to select only one row.");
818         }
819         else
820         {
821             return (Attachment)v.get(0);
822         }
823     }
824
825     /**
826      * Retrieve a multiple objects by pk
827      *
828      * @param pks List of primary keys
829      * @throws TorqueException Any exceptions caught during processing will be
830      * rethrown wrapped into a TorqueException.
831      */

832     public static List JavaDoc retrieveByPKs(List JavaDoc pks)
833         throws TorqueException
834     {
835         Connection JavaDoc db = null;
836         List JavaDoc retVal = null;
837         try
838         {
839            db = Torque.getConnection(DATABASE_NAME);
840            retVal = retrieveByPKs(pks, db);
841         }
842         finally
843         {
844             Torque.closeConnection(db);
845         }
846         return(retVal);
847     }
848
849     /**
850      * Retrieve a multiple objects by pk
851      *
852      * @param pks List of primary keys
853      * @param dbcon the connection to use
854      * @throws TorqueException Any exceptions caught during processing will be
855      * rethrown wrapped into a TorqueException.
856      */

857     public static List JavaDoc retrieveByPKs( List JavaDoc pks, Connection JavaDoc dbcon )
858         throws TorqueException
859     {
860         List JavaDoc objs = null;
861         if (pks == null || pks.size() == 0)
862         {
863             objs = new LinkedList JavaDoc();
864         }
865         else
866         {
867             Criteria criteria = new Criteria();
868               criteria.addIn( ATTACHMENT_ID, pks );
869           objs = doSelect(criteria, dbcon);
870         }
871         return objs;
872     }
873
874  
875
876
877
878                 
879                                               
880                 
881                 
882
883     /**
884      * selects a collection of Attachment objects pre-filled with their
885      * Issue objects.
886      *
887      * This method is protected by default in order to keep the public
888      * api reasonable. You can provide public methods for those you
889      * actually need in AttachmentPeer.
890      *
891      * @throws TorqueException Any exceptions caught during processing will be
892      * rethrown wrapped into a TorqueException.
893      */

894     protected static List JavaDoc doSelectJoinIssue(Criteria criteria)
895         throws TorqueException
896     {
897         setDbName(criteria);
898
899         AttachmentPeer.addSelectColumns(criteria);
900         int offset = numColumns + 1;
901         IssuePeer.addSelectColumns(criteria);
902
903
904                         criteria.addJoin(AttachmentPeer.ISSUE_ID,
905             IssuePeer.ISSUE_ID);
906         
907
908                                                                                                                                                                                                                                 // check for conversion from boolean to int
909
if (criteria.containsKey(DELETED))
910         {
911             Object JavaDoc possibleBoolean = criteria.get(DELETED);
912             if (possibleBoolean instanceof Boolean JavaDoc)
913             {
914                 criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
915             }
916          }
917                   
918         List JavaDoc rows = BasePeer.doSelect(criteria);
919         List JavaDoc results = new ArrayList JavaDoc();
920
921         for (int i = 0; i < rows.size(); i++)
922         {
923             Record row = (Record) rows.get(i);
924
925                             Class JavaDoc omClass = AttachmentPeer.getOMClass();
926                     Attachment obj1 = (Attachment) AttachmentPeer
927                 .row2Object(row, 1, omClass);
928                      omClass = IssuePeer.getOMClass();
929                     Issue obj2 = (Issue)IssuePeer
930                 .row2Object(row, offset, omClass);
931
932             boolean newObject = true;
933             for (int j = 0; j < results.size(); j++)
934             {
935                 Attachment temp_obj1 = (Attachment)results.get(j);
936                 Issue temp_obj2 = (Issue)temp_obj1.getIssue();
937                 if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
938                 {
939                     newObject = false;
940                               temp_obj2.addAttachment(obj1);
941                               break;
942                 }
943             }
944                       if (newObject)
945             {
946                 obj2.initAttachments();
947                 obj2.addAttachment(obj1);
948             }
949                       results.add(obj1);
950         }
951         return results;
952     }
953                                                             
954                 
955                 
956
957     /**
958      * selects a collection of Attachment objects pre-filled with their
959      * AttachmentType objects.
960      *
961      * This method is protected by default in order to keep the public
962      * api reasonable. You can provide public methods for those you
963      * actually need in AttachmentPeer.
964      *
965      * @throws TorqueException Any exceptions caught during processing will be
966      * rethrown wrapped into a TorqueException.
967      */

968     protected static List JavaDoc doSelectJoinAttachmentType(Criteria criteria)
969         throws TorqueException
970     {
971         setDbName(criteria);
972
973         AttachmentPeer.addSelectColumns(criteria);
974         int offset = numColumns + 1;
975         AttachmentTypePeer.addSelectColumns(criteria);
976
977
978                         criteria.addJoin(AttachmentPeer.ATTACHMENT_TYPE_ID,
979             AttachmentTypePeer.ATTACHMENT_TYPE_ID);
980         
981
982                                                                                                                                                                                                                                 // check for conversion from boolean to int
983
if (criteria.containsKey(DELETED))
984         {
985             Object JavaDoc possibleBoolean = criteria.get(DELETED);
986             if (possibleBoolean instanceof Boolean JavaDoc)
987             {
988                 criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
989             }
990          }
991                   
992         List JavaDoc rows = BasePeer.doSelect(criteria);
993         List JavaDoc results = new ArrayList JavaDoc();
994
995         for (int i = 0; i < rows.size(); i++)
996         {
997             Record row = (Record) rows.get(i);
998
999                             Class JavaDoc omClass = AttachmentPeer.getOMClass();
1000                    Attachment obj1 = (Attachment) AttachmentPeer
1001                .row2Object(row, 1, omClass);
1002                     omClass = AttachmentTypePeer.getOMClass();
1003                    AttachmentType obj2 = (AttachmentType)AttachmentTypePeer
1004                .row2Object(row, offset, omClass);
1005
1006            boolean newObject = true;
1007            for (int j = 0; j < results.size(); j++)
1008            {
1009                Attachment temp_obj1 = (Attachment)results.get(j);
1010                AttachmentType temp_obj2 = (AttachmentType)temp_obj1.getAttachmentType();
1011                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1012                {
1013                    newObject = false;
1014                              temp_obj2.addAttachment(obj1);
1015                              break;
1016                }
1017            }
1018                      if (newObject)
1019            {
1020                obj2.initAttachments();
1021                obj2.addAttachment(obj1);
1022            }
1023                      results.add(obj1);
1024        }
1025        return results;
1026    }
1027                                                                      
1028                        
1029                
1030
1031    /**
1032     * selects a collection of Attachment objects pre-filled with their
1033     * ScarabUserImpl objects.
1034     *
1035     * This method is protected by default in order to keep the public
1036     * api reasonable. You can provide public methods for those you
1037     * actually need in AttachmentPeer.
1038     *
1039     * @throws TorqueException Any exceptions caught during processing will be
1040     * rethrown wrapped into a TorqueException.
1041     */

1042    protected static List JavaDoc doSelectJoinScarabUserImplRelatedByCreatedBy(Criteria criteria)
1043        throws TorqueException
1044    {
1045        setDbName(criteria);
1046
1047        AttachmentPeer.addSelectColumns(criteria);
1048        int offset = numColumns + 1;
1049        ScarabUserImplPeer.addSelectColumns(criteria);
1050
1051
1052                        criteria.addJoin(AttachmentPeer.CREATED_BY,
1053            ScarabUserImplPeer.USER_ID);
1054        
1055
1056                                                                                                                                                                                                                                // check for conversion from boolean to int
1057
if (criteria.containsKey(DELETED))
1058        {
1059            Object JavaDoc possibleBoolean = criteria.get(DELETED);
1060            if (possibleBoolean instanceof Boolean JavaDoc)
1061            {
1062                criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1063            }
1064         }
1065                  
1066        List JavaDoc rows = BasePeer.doSelect(criteria);
1067        List JavaDoc results = new ArrayList JavaDoc();
1068
1069        for (int i = 0; i < rows.size(); i++)
1070        {
1071            Record row = (Record) rows.get(i);
1072
1073                            Class JavaDoc omClass = AttachmentPeer.getOMClass();
1074                    Attachment obj1 = (Attachment) AttachmentPeer
1075                .row2Object(row, 1, omClass);
1076                     omClass = ScarabUserImplPeer.getOMClass();
1077                    ScarabUserImpl obj2 = (ScarabUserImpl)ScarabUserImplPeer
1078                .row2Object(row, offset, omClass);
1079
1080            boolean newObject = true;
1081            for (int j = 0; j < results.size(); j++)
1082            {
1083                Attachment temp_obj1 = (Attachment)results.get(j);
1084                ScarabUserImpl temp_obj2 = (ScarabUserImpl)temp_obj1.getScarabUserRelatedByCreatedBy();
1085                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1086                {
1087                    newObject = false;
1088                              temp_obj2.addAttachmentRelatedByCreatedBy(obj1);
1089                              break;
1090                }
1091            }
1092                      if (newObject)
1093            {
1094                obj2.initAttachmentsRelatedByCreatedBy();
1095                obj2.addAttachmentRelatedByCreatedBy(obj1);
1096            }
1097                      results.add(obj1);
1098        }
1099        return results;
1100    }
1101                                                                      
1102                        
1103                
1104
1105    /**
1106     * selects a collection of Attachment objects pre-filled with their
1107     * ScarabUserImpl objects.
1108     *
1109     * This method is protected by default in order to keep the public
1110     * api reasonable. You can provide public methods for those you
1111     * actually need in AttachmentPeer.
1112     *
1113     * @throws TorqueException Any exceptions caught during processing will be
1114     * rethrown wrapped into a TorqueException.
1115     */

1116    protected static List JavaDoc doSelectJoinScarabUserImplRelatedByModifiedBy(Criteria criteria)
1117        throws TorqueException
1118    {
1119        setDbName(criteria);
1120
1121        AttachmentPeer.addSelectColumns(criteria);
1122        int offset = numColumns + 1;
1123        ScarabUserImplPeer.addSelectColumns(criteria);
1124
1125
1126                        criteria.addJoin(AttachmentPeer.MODIFIED_BY,
1127            ScarabUserImplPeer.USER_ID);
1128        
1129
1130                                                                                                                                                                                                                                // check for conversion from boolean to int
1131
if (criteria.containsKey(DELETED))
1132        {
1133            Object JavaDoc possibleBoolean = criteria.get(DELETED);
1134            if (possibleBoolean instanceof Boolean JavaDoc)
1135            {
1136                criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1137            }
1138         }
1139                  
1140        List JavaDoc rows = BasePeer.doSelect(criteria);
1141        List JavaDoc results = new ArrayList JavaDoc();
1142
1143        for (int i = 0; i < rows.size(); i++)
1144        {
1145            Record row = (Record) rows.get(i);
1146
1147                            Class JavaDoc omClass = AttachmentPeer.getOMClass();
1148                    Attachment obj1 = (Attachment) AttachmentPeer
1149                .row2Object(row, 1, omClass);
1150                     omClass = ScarabUserImplPeer.getOMClass();
1151                    ScarabUserImpl obj2 = (ScarabUserImpl)ScarabUserImplPeer
1152                .row2Object(row, offset, omClass);
1153
1154            boolean newObject = true;
1155            for (int j = 0; j < results.size(); j++)
1156            {
1157                Attachment temp_obj1 = (Attachment)results.get(j);
1158                ScarabUserImpl temp_obj2 = (ScarabUserImpl)temp_obj1.getScarabUserRelatedByModifiedBy();
1159                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1160                {
1161                    newObject = false;
1162                              temp_obj2.addAttachmentRelatedByModifiedBy(obj1);
1163                              break;
1164                }
1165            }
1166                      if (newObject)
1167            {
1168                obj2.initAttachmentsRelatedByModifiedBy();
1169                obj2.addAttachmentRelatedByModifiedBy(obj1);
1170            }
1171                      results.add(obj1);
1172        }
1173        return results;
1174    }
1175                    
1176  
1177                                              
1178          
1179        
1180                                  
1181                
1182
1183    /**
1184     * selects a collection of Attachment objects pre-filled with
1185     * all related objects.
1186     *
1187     * This method is protected by default in order to keep the public
1188     * api reasonable. You can provide public methods for those you
1189     * actually need in AttachmentPeer.
1190     *
1191     * @throws TorqueException Any exceptions caught during processing will be
1192     * rethrown wrapped into a TorqueException.
1193     */

1194    protected static List JavaDoc doSelectJoinAllExceptIssue(Criteria criteria)
1195        throws TorqueException
1196    {
1197        setDbName(criteria);
1198
1199        addSelectColumns(criteria);
1200        int offset2 = numColumns + 1;
1201                                    
1202                                                  
1203                    AttachmentTypePeer.addSelectColumns(criteria);
1204        int offset3 = offset2 + AttachmentTypePeer.numColumns;
1205                                                                
1206                    ScarabUserImplPeer.addSelectColumns(criteria);
1207        int offset4 = offset3 + ScarabUserImplPeer.numColumns;
1208                                                                
1209                    ScarabUserImplPeer.addSelectColumns(criteria);
1210        int offset5 = offset4 + ScarabUserImplPeer.numColumns;
1211                                                                                                                                                                                                                                                                            // check for conversion from boolean to int
1212
if (criteria.containsKey(DELETED))
1213        {
1214            Object JavaDoc possibleBoolean = criteria.get(DELETED);
1215            if (possibleBoolean instanceof Boolean JavaDoc)
1216            {
1217                criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1218            }
1219         }
1220                  
1221        List JavaDoc rows = BasePeer.doSelect(criteria);
1222        List JavaDoc results = new ArrayList JavaDoc();
1223
1224        for (int i = 0; i < rows.size(); i++)
1225        {
1226            Record row = (Record)rows.get(i);
1227
1228                            Class JavaDoc omClass = AttachmentPeer.getOMClass();
1229                    Attachment obj1 = (Attachment)AttachmentPeer
1230                .row2Object(row, 1, omClass);
1231                                                
1232                                                                  
1233                                                        
1234                            
1235              
1236                           omClass = AttachmentTypePeer.getOMClass();
1237                          AttachmentType obj2 = (AttachmentType)AttachmentTypePeer
1238                .row2Object( row, offset2, omClass);
1239
1240               boolean newObject = true;
1241            for (int j = 0; j < results.size(); j++)
1242            {
1243                Attachment temp_obj1 = (Attachment)results.get(j);
1244                AttachmentType temp_obj2 = (AttachmentType)temp_obj1.getAttachmentType();
1245                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1246                {
1247                    newObject = false;
1248                                    temp_obj2.addAttachment(obj1);
1249                                    break;
1250                }
1251            }
1252                            if (newObject)
1253            {
1254                obj2.initAttachments();
1255                obj2.addAttachment(obj1);
1256            }
1257                                                                                                
1258                                                                        
1259                            
1260              
1261                           omClass = ScarabUserImplPeer.getOMClass();
1262                          ScarabUserImpl obj3 = (ScarabUserImpl)ScarabUserImplPeer
1263                .row2Object( row, offset3, omClass);
1264
1265               newObject = true;
1266            for (int j = 0; j < results.size(); j++)
1267            {
1268                Attachment temp_obj1 = (Attachment)results.get(j);
1269                ScarabUserImpl temp_obj3 = (ScarabUserImpl)temp_obj1.getScarabUserRelatedByCreatedBy();
1270                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1271                {
1272                    newObject = false;
1273                                    temp_obj3.addAttachmentRelatedByCreatedBy(obj1);
1274                                    break;
1275                }
1276            }
1277                            if (newObject)
1278            {
1279                obj3.initAttachmentsRelatedByCreatedBy();
1280                obj3.addAttachmentRelatedByCreatedBy(obj1);
1281            }
1282                                                                                                
1283                                                                        
1284                            
1285              
1286                           omClass = ScarabUserImplPeer.getOMClass();
1287                          ScarabUserImpl obj4 = (ScarabUserImpl)ScarabUserImplPeer
1288                .row2Object( row, offset4, omClass);
1289
1290               newObject = true;
1291            for (int j = 0; j < results.size(); j++)
1292            {
1293                Attachment temp_obj1 = (Attachment)results.get(j);
1294                ScarabUserImpl temp_obj4 = (ScarabUserImpl)temp_obj1.getScarabUserRelatedByModifiedBy();
1295                if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey()))
1296                {
1297                    newObject = false;
1298                                    temp_obj4.addAttachmentRelatedByModifiedBy(obj1);
1299                                    break;
1300                }
1301            }
1302                            if (newObject)
1303            {
1304                obj4.initAttachmentsRelatedByModifiedBy();
1305                obj4.addAttachmentRelatedByModifiedBy(obj1);
1306            }
1307                                                                results.add(obj1);
1308        }
1309        return results;
1310    }
1311        
1312        
1313                                  
1314                
1315
1316    /**
1317     * selects a collection of Attachment objects pre-filled with
1318     * all related objects.
1319     *
1320     * This method is protected by default in order to keep the public
1321     * api reasonable. You can provide public methods for those you
1322     * actually need in AttachmentPeer.
1323     *
1324     * @throws TorqueException Any exceptions caught during processing will be
1325     * rethrown wrapped into a TorqueException.
1326     */

1327    protected static List JavaDoc doSelectJoinAllExceptAttachmentType(Criteria criteria)
1328        throws TorqueException
1329    {
1330        setDbName(criteria);
1331
1332        addSelectColumns(criteria);
1333        int offset2 = numColumns + 1;
1334                                    
1335                    IssuePeer.addSelectColumns(criteria);
1336        int offset3 = offset2 + IssuePeer.numColumns;
1337                                                                
1338                                                  
1339                    ScarabUserImplPeer.addSelectColumns(criteria);
1340        int offset4 = offset3 + ScarabUserImplPeer.numColumns;
1341                                                                
1342                    ScarabUserImplPeer.addSelectColumns(criteria);
1343        int offset5 = offset4 + ScarabUserImplPeer.numColumns;
1344                                                                                                                                                                                                                                                                            // check for conversion from boolean to int
1345
if (criteria.containsKey(DELETED))
1346        {
1347            Object JavaDoc possibleBoolean = criteria.get(DELETED);
1348            if (possibleBoolean instanceof Boolean JavaDoc)
1349            {
1350                criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1351            }
1352         }
1353                  
1354        List JavaDoc rows = BasePeer.doSelect(criteria);
1355        List JavaDoc results = new ArrayList JavaDoc();
1356
1357        for (int i = 0; i < rows.size(); i++)
1358        {
1359            Record row = (Record)rows.get(i);
1360
1361                            Class JavaDoc omClass = AttachmentPeer.getOMClass();
1362                    Attachment obj1 = (Attachment)AttachmentPeer
1363                .row2Object(row, 1, omClass);
1364                                                
1365                                                        
1366                            
1367              
1368                           omClass = IssuePeer.getOMClass();
1369                          Issue obj2 = (Issue)IssuePeer
1370                .row2Object( row, offset2, omClass);
1371
1372               boolean newObject = true;
1373            for (int j = 0; j < results.size(); j++)
1374            {
1375                Attachment temp_obj1 = (Attachment)results.get(j);
1376                Issue temp_obj2 = (Issue)temp_obj1.getIssue();
1377                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1378                {
1379                    newObject = false;
1380                                    temp_obj2.addAttachment(obj1);
1381                                    break;
1382                }
1383            }
1384                            if (newObject)
1385            {
1386                obj2.initAttachments();
1387                obj2.addAttachment(obj1);
1388            }
1389                                                                                    
1390                                                                              
1391                                                                        
1392                            
1393              
1394                           omClass = ScarabUserImplPeer.getOMClass();
1395                          ScarabUserImpl obj3 = (ScarabUserImpl)ScarabUserImplPeer
1396                .row2Object( row, offset3, omClass);
1397
1398               newObject = true;
1399            for (int j = 0; j < results.size(); j++)
1400            {
1401                Attachment temp_obj1 = (Attachment)results.get(j);
1402                ScarabUserImpl temp_obj3 = (ScarabUserImpl)temp_obj1.getScarabUserRelatedByCreatedBy();
1403                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1404                {
1405                    newObject = false;
1406                                    temp_obj3.addAttachmentRelatedByCreatedBy(obj1);
1407                                    break;
1408                }
1409            }
1410                            if (newObject)
1411            {
1412                obj3.initAttachmentsRelatedByCreatedBy();
1413                obj3.addAttachmentRelatedByCreatedBy(obj1);
1414            }
1415                                                                                                
1416                                                                        
1417                            
1418              
1419                           omClass = ScarabUserImplPeer.getOMClass();
1420                          ScarabUserImpl obj4 = (ScarabUserImpl)ScarabUserImplPeer
1421                .row2Object( row, offset4, omClass);
1422
1423               newObject = true;
1424            for (int j = 0; j < results.size(); j++)
1425            {
1426                Attachment temp_obj1 = (Attachment)results.get(j);
1427                ScarabUserImpl temp_obj4 = (ScarabUserImpl)temp_obj1.getScarabUserRelatedByModifiedBy();
1428                if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey()))
1429                {
1430                    newObject = false;
1431                                    temp_obj4.addAttachmentRelatedByModifiedBy(obj1);
1432                                    break;
1433                }
1434            }
1435                            if (newObject)
1436            {
1437                obj4.initAttachmentsRelatedByModifiedBy();
1438                obj4.addAttachmentRelatedByModifiedBy(obj1);
1439            }
1440                                                                results.add(obj1);
1441        }
1442        return results;
1443    }
1444        
1445        
1446                                            
1447                
1448
1449    /**
1450     * selects a collection of Attachment objects pre-filled with
1451     * all related objects.
1452     *
1453     * This method is protected by default in order to keep the public
1454     * api reasonable. You can provide public methods for those you
1455     * actually need in AttachmentPeer.
1456     *
1457     * @throws TorqueException Any exceptions caught during processing will be
1458     * rethrown wrapped into a TorqueException.
1459     */

1460    protected static List JavaDoc doSelectJoinAllExceptScarabUserImplRelatedByCreatedBy(Criteria criteria)
1461        throws TorqueException
1462    {
1463        setDbName(criteria);
1464
1465        addSelectColumns(criteria);
1466        int offset2 = numColumns + 1;
1467                                    
1468                    IssuePeer.addSelectColumns(criteria);
1469        int offset3 = offset2 + IssuePeer.numColumns;
1470                                                                
1471                    AttachmentTypePeer.addSelectColumns(criteria);
1472        int offset4 = offset3 + AttachmentTypePeer.numColumns;
1473                                                                
1474                                                  
1475                                                                                                                                                                                                                                                              // check for conversion from boolean to int
1476
if (criteria.containsKey(DELETED))
1477        {
1478            Object JavaDoc possibleBoolean = criteria.get(DELETED);
1479            if (possibleBoolean instanceof Boolean JavaDoc)
1480            {
1481                criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1482            }
1483         }
1484                  
1485        List JavaDoc rows = BasePeer.doSelect(criteria);
1486        List JavaDoc results = new ArrayList JavaDoc();
1487
1488        for (int i = 0; i < rows.size(); i++)
1489        {
1490            Record row = (Record)rows.get(i);
1491
1492                            Class JavaDoc omClass = AttachmentPeer.getOMClass();
1493                    Attachment obj1 = (Attachment)AttachmentPeer
1494                .row2Object(row, 1, omClass);
1495                                                
1496                                                        
1497                            
1498              
1499                           omClass = IssuePeer.getOMClass();
1500                          Issue obj2 = (Issue)IssuePeer
1501                .row2Object( row, offset2, omClass);
1502
1503               boolean newObject = true;
1504            for (int j = 0; j < results.size(); j++)
1505            {
1506                Attachment temp_obj1 = (Attachment)results.get(j);
1507                Issue temp_obj2 = (Issue)temp_obj1.getIssue();
1508                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1509                {
1510                    newObject = false;
1511                                    temp_obj2.addAttachment(obj1);
1512                                    break;
1513                }
1514            }
1515                            if (newObject)
1516            {
1517                obj2.initAttachments();
1518                obj2.addAttachment(obj1);
1519            }
1520                                                                                    
1521                                                        
1522                            
1523              
1524                           omClass = AttachmentTypePeer.getOMClass();
1525                          AttachmentType obj3 = (AttachmentType)AttachmentTypePeer
1526                .row2Object( row, offset3, omClass);
1527
1528               newObject = true;
1529            for (int j = 0; j < results.size(); j++)
1530            {
1531                Attachment temp_obj1 = (Attachment)results.get(j);
1532                AttachmentType temp_obj3 = (AttachmentType)temp_obj1.getAttachmentType();
1533                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1534                {
1535                    newObject = false;
1536                                    temp_obj3.addAttachment(obj1);
1537                                    break;
1538                }
1539            }
1540                            if (newObject)
1541            {
1542                obj3.initAttachments();
1543                obj3.addAttachment(obj1);
1544            }
1545                                                                                                
1546                                                                              
1547                                              results.add(obj1);
1548        }
1549        return results;
1550    }
1551        
1552        
1553                                            
1554                
1555
1556    /**
1557     * selects a collection of Attachment objects pre-filled with
1558     * all related objects.
1559     *
1560     * This method is protected by default in order to keep the public
1561     * api reasonable. You can provide public methods for those you
1562     * actually need in AttachmentPeer.
1563     *
1564     * @throws TorqueException Any exceptions caught during processing will be
1565     * rethrown wrapped into a TorqueException.
1566     */

1567    protected static List JavaDoc doSelectJoinAllExceptScarabUserImplRelatedByModifiedBy(Criteria criteria)
1568        throws TorqueException
1569    {
1570        setDbName(criteria);
1571
1572        addSelectColumns(criteria);
1573        int offset2 = numColumns + 1;
1574                                    
1575                    IssuePeer.addSelectColumns(criteria);
1576        int offset3 = offset2 + IssuePeer.numColumns;
1577                                                                
1578                    AttachmentTypePeer.addSelectColumns(criteria);
1579        int offset4 = offset3 + AttachmentTypePeer.numColumns;
1580                                                                
1581                                                  
1582                                                                                                                                                                                                                                                              // check for conversion from boolean to int
1583
if (criteria.containsKey(DELETED))
1584        {
1585            Object JavaDoc possibleBoolean = criteria.get(DELETED);
1586            if (possibleBoolean instanceof Boolean JavaDoc)
1587            {
1588                criteria.add(DELETED, ((Boolean JavaDoc) possibleBoolean).booleanValue() ? 1 : 0);
1589            }
1590         }
1591                  
1592        List JavaDoc rows = BasePeer.doSelect(criteria);
1593        List JavaDoc results = new ArrayList JavaDoc();
1594
1595        for (int i = 0; i < rows.size(); i++)
1596        {
1597            Record row = (Record)rows.get(i);
1598
1599                            Class JavaDoc omClass = AttachmentPeer.getOMClass();
1600                    Attachment obj1 = (Attachment)AttachmentPeer
1601                .row2Object(row, 1, omClass);
1602                                                
1603                                                        
1604                            
1605              
1606                           omClass = IssuePeer.getOMClass();
1607                          Issue obj2 = (Issue)IssuePeer
1608                .row2Object( row, offset2, omClass);
1609
1610               boolean newObject = true;
1611            for (int j = 0; j < results.size(); j++)
1612            {
1613                Attachment temp_obj1 = (Attachment)results.get(j);
1614                Issue temp_obj2 = (Issue)temp_obj1.getIssue();
1615                if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1616                {
1617                    newObject = false;
1618                                    temp_obj2.addAttachment(obj1);
1619                                    break;
1620                }
1621            }
1622                            if (newObject)
1623            {
1624                obj2.initAttachments();
1625                obj2.addAttachment(obj1);
1626            }
1627                                                                                    
1628                                                        
1629                            
1630              
1631                           omClass = AttachmentTypePeer.getOMClass();
1632                          AttachmentType obj3 = (AttachmentType)AttachmentTypePeer
1633                .row2Object( row, offset3, omClass);
1634
1635               newObject = true;
1636            for (int j = 0; j < results.size(); j++)
1637            {
1638                Attachment temp_obj1 = (Attachment)results.get(j);
1639                AttachmentType temp_obj3 = (AttachmentType)temp_obj1.getAttachmentType();
1640                if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey()))
1641                {
1642                    newObject = false;
1643                                    temp_obj3.addAttachment(obj1);
1644                                    break;
1645                }
1646            }
1647                            if (newObject)
1648            {
1649                obj3.initAttachments();
1650                obj3.addAttachment(obj1);
1651            }
1652                                                                                                
1653                                                                              
1654                                              results.add(obj1);
1655        }
1656        return results;
1657    }
1658                    
1659  
1660      /**
1661     * Returns the TableMap related to this peer. This method is not
1662     * needed for general use but a specific application could have a need.
1663     *
1664     * @throws TorqueException Any exceptions caught during processing will be
1665     * rethrown wrapped into a TorqueException.
1666     */

1667    protected static TableMap getTableMap()
1668        throws TorqueException
1669    {
1670        return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME);
1671    }
1672   
1673    private static void setDbName(Criteria crit)
1674    {
1675        // Set the correct dbName if it has not been overridden
1676
// crit.getDbName will return the same object if not set to
1677
// another value so == check is okay and faster
1678
if (crit.getDbName() == Torque.getDefaultDB())
1679        {
1680            crit.setDbName(DATABASE_NAME);
1681        }
1682    }
1683}
1684
Popular Tags