KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > campware > cream > om > BaseCustomerCategory


1 package org.campware.cream.om;
2
3
4 import java.math.BigDecimal JavaDoc;
5 import java.sql.Connection JavaDoc;
6 import java.util.ArrayList JavaDoc;
7 import java.util.Collections JavaDoc;
8 import java.util.Date JavaDoc;
9 import java.util.List JavaDoc;
10
11 import org.apache.commons.lang.ObjectUtils;
12 import org.apache.turbine.om.Retrievable;
13 import org.apache.torque.TorqueException;
14 import org.apache.torque.om.BaseObject;
15 import org.apache.torque.om.ComboKey;
16 import org.apache.torque.om.DateKey;
17 import org.apache.torque.om.NumberKey;
18 import org.apache.torque.om.ObjectKey;
19 import org.apache.torque.om.SimpleKey;
20 import org.apache.torque.om.StringKey;
21 import org.apache.torque.om.Persistent;
22 import org.apache.torque.util.Criteria;
23 import org.apache.torque.util.Transaction;
24
25
26 /**
27  * This class was autogenerated by Torque on:
28  *
29  * [Wed May 04 09:10:56 CEST 2005]
30  *
31  * You should not use this class directly. It should not even be
32  * extended all references should be to CustomerCategory
33  */

34 public abstract class BaseCustomerCategory extends BaseObject
35     implements org.apache.turbine.om.Retrievable
36 {
37     /** The Peer class */
38     private static final CustomerCategoryPeer peer =
39         new CustomerCategoryPeer();
40
41         
42     /** The value for the customerCatId field */
43     private int customerCatId;
44       
45     /** The value for the customerCatName field */
46     private String JavaDoc customerCatName;
47   
48     
49     /**
50      * Get the CustomerCatId
51      *
52      * @return int
53      */

54     public int getCustomerCatId()
55     {
56         return customerCatId;
57     }
58
59                                               
60     /**
61      * Set the value of CustomerCatId
62      *
63      * @param v new value
64      */

65     public void setCustomerCatId(int v) throws TorqueException
66     {
67     
68                   if (this.customerCatId != v)
69               {
70             this.customerCatId = v;
71             setModified(true);
72         }
73     
74           
75                                   
76                   // update associated Customer
77
if (collCustomers != null)
78         {
79             for (int i = 0; i < collCustomers.size(); i++)
80             {
81                 ((Customer) collCustomers.get(i))
82                     .setCustomerCatId(v);
83             }
84         }
85                                                     
86                   // update associated Newsletter
87
if (collNewsletters != null)
88         {
89             for (int i = 0; i < collNewsletters.size(); i++)
90             {
91                 ((Newsletter) collNewsletters.get(i))
92                     .setCustomerCatId(v);
93             }
94         }
95                                 }
96   
97     /**
98      * Get the CustomerCatName
99      *
100      * @return String
101      */

102     public String JavaDoc getCustomerCatName()
103     {
104         return customerCatName;
105     }
106
107                         
108     /**
109      * Set the value of CustomerCatName
110      *
111      * @param v new value
112      */

113     public void setCustomerCatName(String JavaDoc v)
114     {
115     
116                   if (!ObjectUtils.equals(this.customerCatName, v))
117               {
118             this.customerCatName = v;
119             setModified(true);
120         }
121     
122           
123               }
124   
125          
126                                 
127             
128           /**
129      * Collection to store aggregation of collCustomers
130      */

131     protected List JavaDoc collCustomers;
132
133     /**
134      * Temporary storage of collCustomers to save a possible db hit in
135      * the event objects are add to the collection, but the
136      * complete collection is never requested.
137      */

138     protected void initCustomers()
139     {
140         if (collCustomers == null)
141         {
142             collCustomers = new ArrayList JavaDoc();
143         }
144     }
145
146     /**
147      * Method called to associate a Customer object to this object
148      * through the Customer foreign key attribute
149      *
150      * @param l Customer
151      * @throws TorqueException
152      */

153     public void addCustomer(Customer l) throws TorqueException
154     {
155         getCustomers().add(l);
156         l.setCustomerCategory((CustomerCategory) this);
157     }
158
159     /**
160      * The criteria used to select the current contents of collCustomers
161      */

162     private Criteria lastCustomersCriteria = null;
163       
164     /**
165      * If this collection has already been initialized, returns
166      * the collection. Otherwise returns the results of
167      * getCustomers(new Criteria())
168      *
169      * @throws TorqueException
170      */

171     public List JavaDoc getCustomers() throws TorqueException
172     {
173               if (collCustomers == null)
174         {
175             collCustomers = getCustomers(new Criteria(10));
176         }
177         return collCustomers;
178           }
179
180     /**
181      * If this collection has already been initialized with
182      * an identical criteria, it returns the collection.
183      * Otherwise if this CustomerCategory has previously
184      * been saved, it will retrieve related Customers from storage.
185      * If this CustomerCategory is new, it will return
186      * an empty collection or the current collection, the criteria
187      * is ignored on a new object.
188      *
189      * @throws TorqueException
190      */

191     public List JavaDoc getCustomers(Criteria criteria) throws TorqueException
192     {
193               if (collCustomers == null)
194         {
195             if (isNew())
196             {
197                collCustomers = new ArrayList JavaDoc();
198             }
199             else
200             {
201                         criteria.add(CustomerPeer.CUSTOMER_CAT_ID, getCustomerCatId() );
202                         collCustomers = CustomerPeer.doSelect(criteria);
203             }
204         }
205         else
206         {
207             // criteria has no effect for a new object
208
if (!isNew())
209             {
210                 // the following code is to determine if a new query is
211
// called for. If the criteria is the same as the last
212
// one, just return the collection.
213
criteria.add(CustomerPeer.CUSTOMER_CAT_ID, getCustomerCatId());
214                             if (!lastCustomersCriteria.equals(criteria))
215                 {
216                     collCustomers = CustomerPeer.doSelect(criteria);
217                 }
218             }
219         }
220         lastCustomersCriteria = criteria;
221
222         return collCustomers;
223           }
224
225     /**
226      * If this collection has already been initialized, returns
227      * the collection. Otherwise returns the results of
228      * getCustomers(new Criteria(),Connection)
229      * This method takes in the Connection also as input so that
230      * referenced objects can also be obtained using a Connection
231      * that is taken as input
232      */

233     public List JavaDoc getCustomers(Connection JavaDoc con) throws TorqueException
234     {
235               if (collCustomers == null)
236         {
237             collCustomers = getCustomers(new Criteria(10), con);
238         }
239         return collCustomers;
240           }
241
242     /**
243      * If this collection has already been initialized with
244      * an identical criteria, it returns the collection.
245      * Otherwise if this CustomerCategory has previously
246      * been saved, it will retrieve related Customers from storage.
247      * If this CustomerCategory is new, it will return
248      * an empty collection or the current collection, the criteria
249      * is ignored on a new object.
250      * This method takes in the Connection also as input so that
251      * referenced objects can also be obtained using a Connection
252      * that is taken as input
253      */

254     public List JavaDoc getCustomers(Criteria criteria, Connection JavaDoc con)
255             throws TorqueException
256     {
257               if (collCustomers == null)
258         {
259             if (isNew())
260             {
261                collCustomers = new ArrayList JavaDoc();
262             }
263             else
264             {
265                          criteria.add(CustomerPeer.CUSTOMER_CAT_ID, getCustomerCatId());
266                          collCustomers = CustomerPeer.doSelect(criteria, con);
267              }
268          }
269          else
270          {
271              // criteria has no effect for a new object
272
if (!isNew())
273              {
274                  // the following code is to determine if a new query is
275
// called for. If the criteria is the same as the last
276
// one, just return the collection.
277
criteria.add(CustomerPeer.CUSTOMER_CAT_ID, getCustomerCatId());
278                              if (!lastCustomersCriteria.equals(criteria))
279                  {
280                      collCustomers = CustomerPeer.doSelect(criteria, con);
281                  }
282              }
283          }
284          lastCustomersCriteria = criteria;
285
286          return collCustomers;
287            }
288
289                                                 
290               
291                     
292                               
293                                 
294                                                               
295                                         
296                     
297                     
298           
299     /**
300      * If this collection has already been initialized with
301      * an identical criteria, it returns the collection.
302      * Otherwise if this CustomerCategory is new, it will return
303      * an empty collection; or if this CustomerCategory has previously
304      * been saved, it will retrieve related Customers from storage.
305      *
306      * This method is protected by default in order to keep the public
307      * api reasonable. You can provide public methods for those you
308      * actually need in CustomerCategory.
309      */

310     protected List JavaDoc getCustomersJoinCustomerCategory(Criteria criteria)
311         throws TorqueException
312     {
313                     if (collCustomers == null)
314         {
315             if (isNew())
316             {
317                collCustomers = new ArrayList JavaDoc();
318             }
319             else
320             {
321                               criteria.add(CustomerPeer.CUSTOMER_CAT_ID, getCustomerCatId());
322                               collCustomers = CustomerPeer.doSelectJoinCustomerCategory(criteria);
323             }
324         }
325         else
326         {
327             // the following code is to determine if a new query is
328
// called for. If the criteria is the same as the last
329
// one, just return the collection.
330

331                         criteria.add(CustomerPeer.CUSTOMER_CAT_ID, getCustomerCatId());
332                                     if (!lastCustomersCriteria.equals(criteria))
333             {
334                 collCustomers = CustomerPeer.doSelectJoinCustomerCategory(criteria);
335             }
336         }
337         lastCustomersCriteria = criteria;
338
339         return collCustomers;
340                 }
341                   
342                     
343                     
344                                 
345                                                               
346                                         
347                     
348                     
349           
350     /**
351      * If this collection has already been initialized with
352      * an identical criteria, it returns the collection.
353      * Otherwise if this CustomerCategory is new, it will return
354      * an empty collection; or if this CustomerCategory has previously
355      * been saved, it will retrieve related Customers from storage.
356      *
357      * This method is protected by default in order to keep the public
358      * api reasonable. You can provide public methods for those you
359      * actually need in CustomerCategory.
360      */

361     protected List JavaDoc getCustomersJoinCountry(Criteria criteria)
362         throws TorqueException
363     {
364                     if (collCustomers == null)
365         {
366             if (isNew())
367             {
368                collCustomers = new ArrayList JavaDoc();
369             }
370             else
371             {
372                               criteria.add(CustomerPeer.CUSTOMER_CAT_ID, getCustomerCatId());
373                               collCustomers = CustomerPeer.doSelectJoinCountry(criteria);
374             }
375         }
376         else
377         {
378             // the following code is to determine if a new query is
379
// called for. If the criteria is the same as the last
380
// one, just return the collection.
381

382                         criteria.add(CustomerPeer.CUSTOMER_CAT_ID, getCustomerCatId());
383                                     if (!lastCustomersCriteria.equals(criteria))
384             {
385                 collCustomers = CustomerPeer.doSelectJoinCountry(criteria);
386             }
387         }
388         lastCustomersCriteria = criteria;
389
390         return collCustomers;
391                 }
392                   
393                     
394                     
395                                 
396                                                               
397                                         
398                     
399                     
400           
401     /**
402      * If this collection has already been initialized with
403      * an identical criteria, it returns the collection.
404      * Otherwise if this CustomerCategory is new, it will return
405      * an empty collection; or if this CustomerCategory has previously
406      * been saved, it will retrieve related Customers from storage.
407      *
408      * This method is protected by default in order to keep the public
409      * api reasonable. You can provide public methods for those you
410      * actually need in CustomerCategory.
411      */

412     protected List JavaDoc getCustomersJoinRegion(Criteria criteria)
413         throws TorqueException
414     {
415                     if (collCustomers == null)
416         {
417             if (isNew())
418             {
419                collCustomers = new ArrayList JavaDoc();
420             }
421             else
422             {
423                               criteria.add(CustomerPeer.CUSTOMER_CAT_ID, getCustomerCatId());
424                               collCustomers = CustomerPeer.doSelectJoinRegion(criteria);
425             }
426         }
427         else
428         {
429             // the following code is to determine if a new query is
430
// called for. If the criteria is the same as the last
431
// one, just return the collection.
432

433                         criteria.add(CustomerPeer.CUSTOMER_CAT_ID, getCustomerCatId());
434                                     if (!lastCustomersCriteria.equals(criteria))
435             {
436                 collCustomers = CustomerPeer.doSelectJoinRegion(criteria);
437             }
438         }
439         lastCustomersCriteria = criteria;
440
441         return collCustomers;
442                 }
443                   
444                     
445                     
446                                 
447                                                               
448                                         
449                     
450                     
451           
452     /**
453      * If this collection has already been initialized with
454      * an identical criteria, it returns the collection.
455      * Otherwise if this CustomerCategory is new, it will return
456      * an empty collection; or if this CustomerCategory has previously
457      * been saved, it will retrieve related Customers from storage.
458      *
459      * This method is protected by default in order to keep the public
460      * api reasonable. You can provide public methods for those you
461      * actually need in CustomerCategory.
462      */

463     protected List JavaDoc getCustomersJoinLanguage(Criteria criteria)
464         throws TorqueException
465     {
466                     if (collCustomers == null)
467         {
468             if (isNew())
469             {
470                collCustomers = new ArrayList JavaDoc();
471             }
472             else
473             {
474                               criteria.add(CustomerPeer.CUSTOMER_CAT_ID, getCustomerCatId());
475                               collCustomers = CustomerPeer.doSelectJoinLanguage(criteria);
476             }
477         }
478         else
479         {
480             // the following code is to determine if a new query is
481
// called for. If the criteria is the same as the last
482
// one, just return the collection.
483

484                         criteria.add(CustomerPeer.CUSTOMER_CAT_ID, getCustomerCatId());
485                                     if (!lastCustomersCriteria.equals(criteria))
486             {
487                 collCustomers = CustomerPeer.doSelectJoinLanguage(criteria);
488             }
489         }
490         lastCustomersCriteria = criteria;
491
492         return collCustomers;
493                 }
494                   
495                     
496                     
497                                 
498                                                               
499                                         
500                     
501                     
502           
503     /**
504      * If this collection has already been initialized with
505      * an identical criteria, it returns the collection.
506      * Otherwise if this CustomerCategory is new, it will return
507      * an empty collection; or if this CustomerCategory has previously
508      * been saved, it will retrieve related Customers from storage.
509      *
510      * This method is protected by default in order to keep the public
511      * api reasonable. You can provide public methods for those you
512      * actually need in CustomerCategory.
513      */

514     protected List JavaDoc getCustomersJoinEducationCategory(Criteria criteria)
515         throws TorqueException
516     {
517                     if (collCustomers == null)
518         {
519             if (isNew())
520             {
521                collCustomers = new ArrayList JavaDoc();
522             }
523             else
524             {
525                               criteria.add(CustomerPeer.CUSTOMER_CAT_ID, getCustomerCatId());
526                               collCustomers = CustomerPeer.doSelectJoinEducationCategory(criteria);
527             }
528         }
529         else
530         {
531             // the following code is to determine if a new query is
532
// called for. If the criteria is the same as the last
533
// one, just return the collection.
534

535                         criteria.add(CustomerPeer.CUSTOMER_CAT_ID, getCustomerCatId());
536                                     if (!lastCustomersCriteria.equals(criteria))
537             {
538                 collCustomers = CustomerPeer.doSelectJoinEducationCategory(criteria);
539             }
540         }
541         lastCustomersCriteria = criteria;
542
543         return collCustomers;
544                 }
545                   
546                     
547                     
548                                 
549                                                               
550                                         
551                     
552                     
553           
554     /**
555      * If this collection has already been initialized with
556      * an identical criteria, it returns the collection.
557      * Otherwise if this CustomerCategory is new, it will return
558      * an empty collection; or if this CustomerCategory has previously
559      * been saved, it will retrieve related Customers from storage.
560      *
561      * This method is protected by default in order to keep the public
562      * api reasonable. You can provide public methods for those you
563      * actually need in CustomerCategory.
564      */

565     protected List JavaDoc getCustomersJoinHouseholdCategory(Criteria criteria)
566         throws TorqueException
567     {
568                     if (collCustomers == null)
569         {
570             if (isNew())
571             {
572                collCustomers = new ArrayList JavaDoc();
573             }
574             else
575             {
576                               criteria.add(CustomerPeer.CUSTOMER_CAT_ID, getCustomerCatId());
577                               collCustomers = CustomerPeer.doSelectJoinHouseholdCategory(criteria);
578             }
579         }
580         else
581         {
582             // the following code is to determine if a new query is
583
// called for. If the criteria is the same as the last
584
// one, just return the collection.
585

586                         criteria.add(CustomerPeer.CUSTOMER_CAT_ID, getCustomerCatId());
587                                     if (!lastCustomersCriteria.equals(criteria))
588             {
589                 collCustomers = CustomerPeer.doSelectJoinHouseholdCategory(criteria);
590             }
591         }
592         lastCustomersCriteria = criteria;
593
594         return collCustomers;
595                 }
596                             
597
598
599                           
600             
601           /**
602      * Collection to store aggregation of collNewsletters
603      */

604     protected List JavaDoc collNewsletters;
605
606     /**
607      * Temporary storage of collNewsletters to save a possible db hit in
608      * the event objects are add to the collection, but the
609      * complete collection is never requested.
610      */

611     protected void initNewsletters()
612     {
613         if (collNewsletters == null)
614         {
615             collNewsletters = new ArrayList JavaDoc();
616         }
617     }
618
619     /**
620      * Method called to associate a Newsletter object to this object
621      * through the Newsletter foreign key attribute
622      *
623      * @param l Newsletter
624      * @throws TorqueException
625      */

626     public void addNewsletter(Newsletter l) throws TorqueException
627     {
628         getNewsletters().add(l);
629         l.setCustomerCategory((CustomerCategory) this);
630     }
631
632     /**
633      * The criteria used to select the current contents of collNewsletters
634      */

635     private Criteria lastNewslettersCriteria = null;
636       
637     /**
638      * If this collection has already been initialized, returns
639      * the collection. Otherwise returns the results of
640      * getNewsletters(new Criteria())
641      *
642      * @throws TorqueException
643      */

644     public List JavaDoc getNewsletters() throws TorqueException
645     {
646               if (collNewsletters == null)
647         {
648             collNewsletters = getNewsletters(new Criteria(10));
649         }
650         return collNewsletters;
651           }
652
653     /**
654      * If this collection has already been initialized with
655      * an identical criteria, it returns the collection.
656      * Otherwise if this CustomerCategory has previously
657      * been saved, it will retrieve related Newsletters from storage.
658      * If this CustomerCategory is new, it will return
659      * an empty collection or the current collection, the criteria
660      * is ignored on a new object.
661      *
662      * @throws TorqueException
663      */

664     public List JavaDoc getNewsletters(Criteria criteria) throws TorqueException
665     {
666               if (collNewsletters == null)
667         {
668             if (isNew())
669             {
670                collNewsletters = new ArrayList JavaDoc();
671             }
672             else
673             {
674                         criteria.add(NewsletterPeer.CUSTOMER_CAT_ID, getCustomerCatId() );
675                         collNewsletters = NewsletterPeer.doSelect(criteria);
676             }
677         }
678         else
679         {
680             // criteria has no effect for a new object
681
if (!isNew())
682             {
683                 // the following code is to determine if a new query is
684
// called for. If the criteria is the same as the last
685
// one, just return the collection.
686
criteria.add(NewsletterPeer.CUSTOMER_CAT_ID, getCustomerCatId());
687                             if (!lastNewslettersCriteria.equals(criteria))
688                 {
689                     collNewsletters = NewsletterPeer.doSelect(criteria);
690                 }
691             }
692         }
693         lastNewslettersCriteria = criteria;
694
695         return collNewsletters;
696           }
697
698     /**
699      * If this collection has already been initialized, returns
700      * the collection. Otherwise returns the results of
701      * getNewsletters(new Criteria(),Connection)
702      * This method takes in the Connection also as input so that
703      * referenced objects can also be obtained using a Connection
704      * that is taken as input
705      */

706     public List JavaDoc getNewsletters(Connection JavaDoc con) throws TorqueException
707     {
708               if (collNewsletters == null)
709         {
710             collNewsletters = getNewsletters(new Criteria(10), con);
711         }
712         return collNewsletters;
713           }
714
715     /**
716      * If this collection has already been initialized with
717      * an identical criteria, it returns the collection.
718      * Otherwise if this CustomerCategory has previously
719      * been saved, it will retrieve related Newsletters from storage.
720      * If this CustomerCategory is new, it will return
721      * an empty collection or the current collection, the criteria
722      * is ignored on a new object.
723      * This method takes in the Connection also as input so that
724      * referenced objects can also be obtained using a Connection
725      * that is taken as input
726      */

727     public List JavaDoc getNewsletters(Criteria criteria, Connection JavaDoc con)
728             throws TorqueException
729     {
730               if (collNewsletters == null)
731         {
732             if (isNew())
733             {
734                collNewsletters = new ArrayList JavaDoc();
735             }
736             else
737             {
738                          criteria.add(NewsletterPeer.CUSTOMER_CAT_ID, getCustomerCatId());
739                          collNewsletters = NewsletterPeer.doSelect(criteria, con);
740              }
741          }
742          else
743          {
744              // criteria has no effect for a new object
745
if (!isNew())
746              {
747                  // the following code is to determine if a new query is
748
// called for. If the criteria is the same as the last
749
// one, just return the collection.
750
criteria.add(NewsletterPeer.CUSTOMER_CAT_ID, getCustomerCatId());
751                              if (!lastNewslettersCriteria.equals(criteria))
752                  {
753                      collNewsletters = NewsletterPeer.doSelect(criteria, con);
754                  }
755              }
756          }
757          lastNewslettersCriteria = criteria;
758
759          return collNewsletters;
760            }
761
762                                                             
763               
764                     
765                               
766                                 
767                                                               
768                                         
769                     
770                     
771           
772     /**
773      * If this collection has already been initialized with
774      * an identical criteria, it returns the collection.
775      * Otherwise if this CustomerCategory is new, it will return
776      * an empty collection; or if this CustomerCategory has previously
777      * been saved, it will retrieve related Newsletters from storage.
778      *
779      * This method is protected by default in order to keep the public
780      * api reasonable. You can provide public methods for those you
781      * actually need in CustomerCategory.
782      */

783     protected List JavaDoc getNewslettersJoinCustomerCategory(Criteria criteria)
784         throws TorqueException
785     {
786                     if (collNewsletters == null)
787         {
788             if (isNew())
789             {
790                collNewsletters = new ArrayList JavaDoc();
791             }
792             else
793             {
794                               criteria.add(NewsletterPeer.CUSTOMER_CAT_ID, getCustomerCatId());
795                               collNewsletters = NewsletterPeer.doSelectJoinCustomerCategory(criteria);
796             }
797         }
798         else
799         {
800             // the following code is to determine if a new query is
801
// called for. If the criteria is the same as the last
802
// one, just return the collection.
803

804                         criteria.add(NewsletterPeer.CUSTOMER_CAT_ID, getCustomerCatId());
805                                     if (!lastNewslettersCriteria.equals(criteria))
806             {
807                 collNewsletters = NewsletterPeer.doSelectJoinCustomerCategory(criteria);
808             }
809         }
810         lastNewslettersCriteria = criteria;
811
812         return collNewsletters;
813                 }
814                   
815                     
816                     
817                                             
818                                                                           
819                                         
820                     
821                     
822           
823     /**
824      * If this collection has already been initialized with
825      * an identical criteria, it returns the collection.
826      * Otherwise if this CustomerCategory is new, it will return
827      * an empty collection; or if this CustomerCategory has previously
828      * been saved, it will retrieve related Newsletters from storage.
829      *
830      * This method is protected by default in order to keep the public
831      * api reasonable. You can provide public methods for those you
832      * actually need in CustomerCategory.
833      */

834     protected List JavaDoc getNewslettersJoinProjectRelatedByProjectId(Criteria criteria)
835         throws TorqueException
836     {
837                     if (collNewsletters == null)
838         {
839             if (isNew())
840             {
841                collNewsletters = new ArrayList JavaDoc();
842             }
843             else
844             {
845                               criteria.add(NewsletterPeer.CUSTOMER_CAT_ID, getCustomerCatId());
846                               collNewsletters = NewsletterPeer.doSelectJoinProjectRelatedByProjectId(criteria);
847             }
848         }
849         else
850         {
851             // the following code is to determine if a new query is
852
// called for. If the criteria is the same as the last
853
// one, just return the collection.
854

855                         criteria.add(NewsletterPeer.CUSTOMER_CAT_ID, getCustomerCatId());
856                                     if (!lastNewslettersCriteria.equals(criteria))
857             {
858                 collNewsletters = NewsletterPeer.doSelectJoinProjectRelatedByProjectId(criteria);
859             }
860         }
861         lastNewslettersCriteria = criteria;
862
863         return collNewsletters;
864                 }
865                   
866                     
867                     
868                                             
869                                                                           
870                                         
871                     
872                     
873           
874     /**
875      * If this collection has already been initialized with
876      * an identical criteria, it returns the collection.
877      * Otherwise if this CustomerCategory is new, it will return
878      * an empty collection; or if this CustomerCategory has previously
879      * been saved, it will retrieve related Newsletters from storage.
880      *
881      * This method is protected by default in order to keep the public
882      * api reasonable. You can provide public methods for those you
883      * actually need in CustomerCategory.
884      */

885     protected List JavaDoc getNewslettersJoinProductRelatedByProductId(Criteria criteria)
886         throws TorqueException
887     {
888                     if (collNewsletters == null)
889         {
890             if (isNew())
891             {
892                collNewsletters = new ArrayList JavaDoc();
893             }
894             else
895             {
896                               criteria.add(NewsletterPeer.CUSTOMER_CAT_ID, getCustomerCatId());
897                               collNewsletters = NewsletterPeer.doSelectJoinProductRelatedByProductId(criteria);
898             }
899         }
900         else
901         {
902             // the following code is to determine if a new query is
903
// called for. If the criteria is the same as the last
904
// one, just return the collection.
905

906                         criteria.add(NewsletterPeer.CUSTOMER_CAT_ID, getCustomerCatId());
907                                     if (!lastNewslettersCriteria.equals(criteria))
908             {
909                 collNewsletters = NewsletterPeer.doSelectJoinProductRelatedByProductId(criteria);
910             }
911         }
912         lastNewslettersCriteria = criteria;
913
914         return collNewsletters;
915                 }
916                   
917                     
918                     
919                                             
920                                                                           
921                                         
922                     
923                     
924           
925     /**
926      * If this collection has already been initialized with
927      * an identical criteria, it returns the collection.
928      * Otherwise if this CustomerCategory is new, it will return
929      * an empty collection; or if this CustomerCategory has previously
930      * been saved, it will retrieve related Newsletters from storage.
931      *
932      * This method is protected by default in order to keep the public
933      * api reasonable. You can provide public methods for those you
934      * actually need in CustomerCategory.
935      */

936     protected List JavaDoc getNewslettersJoinProjectRelatedByRelProjectId(Criteria criteria)
937         throws TorqueException
938     {
939                     if (collNewsletters == null)
940         {
941             if (isNew())
942             {
943                collNewsletters = new ArrayList JavaDoc();
944             }
945             else
946             {
947                               criteria.add(NewsletterPeer.CUSTOMER_CAT_ID, getCustomerCatId());
948                               collNewsletters = NewsletterPeer.doSelectJoinProjectRelatedByRelProjectId(criteria);
949             }
950         }
951         else
952         {
953             // the following code is to determine if a new query is
954
// called for. If the criteria is the same as the last
955
// one, just return the collection.
956

957                         criteria.add(NewsletterPeer.CUSTOMER_CAT_ID, getCustomerCatId());
958                                     if (!lastNewslettersCriteria.equals(criteria))
959             {
960                 collNewsletters = NewsletterPeer.doSelectJoinProjectRelatedByRelProjectId(criteria);
961             }
962         }
963         lastNewslettersCriteria = criteria;
964
965         return collNewsletters;
966                 }
967                   
968                     
969                     
970                                             
971                                                                           
972                                         
973                     
974                     
975           
976     /**
977      * If this collection has already been initialized with
978      * an identical criteria, it returns the collection.
979      * Otherwise if this CustomerCategory is new, it will return
980      * an empty collection; or if this CustomerCategory has previously
981      * been saved, it will retrieve related Newsletters from storage.
982      *
983      * This method is protected by default in order to keep the public
984      * api reasonable. You can provide public methods for those you
985      * actually need in CustomerCategory.
986      */

987     protected List JavaDoc getNewslettersJoinProductRelatedByRelProductId(Criteria criteria)
988         throws TorqueException
989     {
990                     if (collNewsletters == null)
991         {
992             if (isNew())
993             {
994                collNewsletters = new ArrayList JavaDoc();
995             }
996             else
997             {
998                               criteria.add(NewsletterPeer.CUSTOMER_CAT_ID, getCustomerCatId());
999                               collNewsletters = NewsletterPeer.doSelectJoinProductRelatedByRelProductId(criteria);
1000            }
1001        }
1002        else
1003        {
1004            // the following code is to determine if a new query is
1005
// called for. If the criteria is the same as the last
1006
// one, just return the collection.
1007

1008                        criteria.add(NewsletterPeer.CUSTOMER_CAT_ID, getCustomerCatId());
1009                                    if (!lastNewslettersCriteria.equals(criteria))
1010            {
1011                collNewsletters = NewsletterPeer.doSelectJoinProductRelatedByRelProductId(criteria);
1012            }
1013        }
1014        lastNewslettersCriteria = criteria;
1015
1016        return collNewsletters;
1017                }
1018                  
1019                    
1020                    
1021                                
1022                                                              
1023                                        
1024                    
1025                    
1026          
1027    /**
1028     * If this collection has already been initialized with
1029     * an identical criteria, it returns the collection.
1030     * Otherwise if this CustomerCategory is new, it will return
1031     * an empty collection; or if this CustomerCategory has previously
1032     * been saved, it will retrieve related Newsletters from storage.
1033     *
1034     * This method is protected by default in order to keep the public
1035     * api reasonable. You can provide public methods for those you
1036     * actually need in CustomerCategory.
1037     */

1038    protected List JavaDoc getNewslettersJoinCountry(Criteria criteria)
1039        throws TorqueException
1040    {
1041                    if (collNewsletters == null)
1042        {
1043            if (isNew())
1044            {
1045               collNewsletters = new ArrayList JavaDoc();
1046            }
1047            else
1048            {
1049                              criteria.add(NewsletterPeer.CUSTOMER_CAT_ID, getCustomerCatId());
1050                              collNewsletters = NewsletterPeer.doSelectJoinCountry(criteria);
1051            }
1052        }
1053        else
1054        {
1055            // the following code is to determine if a new query is
1056
// called for. If the criteria is the same as the last
1057
// one, just return the collection.
1058

1059                        criteria.add(NewsletterPeer.CUSTOMER_CAT_ID, getCustomerCatId());
1060                                    if (!lastNewslettersCriteria.equals(criteria))
1061            {
1062                collNewsletters = NewsletterPeer.doSelectJoinCountry(criteria);
1063            }
1064        }
1065        lastNewslettersCriteria = criteria;
1066
1067        return collNewsletters;
1068                }
1069                  
1070                    
1071                    
1072                                            
1073                                                                          
1074                                        
1075                    
1076                    
1077          
1078    /**
1079     * If this collection has already been initialized with
1080     * an identical criteria, it returns the collection.
1081     * Otherwise if this CustomerCategory is new, it will return
1082     * an empty collection; or if this CustomerCategory has previously
1083     * been saved, it will retrieve related Newsletters from storage.
1084     *
1085     * This method is protected by default in order to keep the public
1086     * api reasonable. You can provide public methods for those you
1087     * actually need in CustomerCategory.
1088     */

1089    protected List JavaDoc getNewslettersJoinLanguageRelatedByCustLanguageId(Criteria criteria)
1090        throws TorqueException
1091    {
1092                    if (collNewsletters == null)
1093        {
1094            if (isNew())
1095            {
1096               collNewsletters = new ArrayList JavaDoc();
1097            }
1098            else
1099            {
1100                              criteria.add(NewsletterPeer.CUSTOMER_CAT_ID, getCustomerCatId());
1101                              collNewsletters = NewsletterPeer.doSelectJoinLanguageRelatedByCustLanguageId(criteria);
1102            }
1103        }
1104        else
1105        {
1106            // the following code is to determine if a new query is
1107
// called for. If the criteria is the same as the last
1108
// one, just return the collection.
1109

1110                        criteria.add(NewsletterPeer.CUSTOMER_CAT_ID, getCustomerCatId());
1111                                    if (!lastNewslettersCriteria.equals(criteria))
1112            {
1113                collNewsletters = NewsletterPeer.doSelectJoinLanguageRelatedByCustLanguageId(criteria);
1114            }
1115        }
1116        lastNewslettersCriteria = criteria;
1117
1118        return collNewsletters;
1119                }
1120                  
1121                    
1122                    
1123                                            
1124                                                                          
1125                                        
1126                    
1127                    
1128          
1129    /**
1130     * If this collection has already been initialized with
1131     * an identical criteria, it returns the collection.
1132     * Otherwise if this CustomerCategory is new, it will return
1133     * an empty collection; or if this CustomerCategory has previously
1134     * been saved, it will retrieve related Newsletters from storage.
1135     *
1136     * This method is protected by default in order to keep the public
1137     * api reasonable. You can provide public methods for those you
1138     * actually need in CustomerCategory.
1139     */

1140    protected List JavaDoc getNewslettersJoinLanguageRelatedByLanguageId(Criteria criteria)
1141        throws TorqueException
1142    {
1143                    if (collNewsletters == null)
1144        {
1145            if (isNew())
1146            {
1147               collNewsletters = new ArrayList JavaDoc();
1148            }
1149            else
1150            {
1151                              criteria.add(NewsletterPeer.CUSTOMER_CAT_ID, getCustomerCatId());
1152                              collNewsletters = NewsletterPeer.doSelectJoinLanguageRelatedByLanguageId(criteria);
1153            }
1154        }
1155        else
1156        {
1157            // the following code is to determine if a new query is
1158
// called for. If the criteria is the same as the last
1159
// one, just return the collection.
1160

1161                        criteria.add(NewsletterPeer.CUSTOMER_CAT_ID, getCustomerCatId());
1162                                    if (!lastNewslettersCriteria.equals(criteria))
1163            {
1164                collNewsletters = NewsletterPeer.doSelectJoinLanguageRelatedByLanguageId(criteria);
1165            }
1166        }
1167        lastNewslettersCriteria = criteria;
1168
1169        return collNewsletters;
1170                }
1171                            
1172
1173
1174          
1175    private static List JavaDoc fieldNames = null;
1176
1177    /**
1178     * Generate a list of field names.
1179     *
1180     * @return a list of field names
1181     */

1182    public static synchronized List JavaDoc getFieldNames()
1183    {
1184        if (fieldNames == null)
1185        {
1186            fieldNames = new ArrayList JavaDoc();
1187              fieldNames.add("CustomerCatId");
1188              fieldNames.add("CustomerCatName");
1189              fieldNames = Collections.unmodifiableList(fieldNames);
1190        }
1191        return fieldNames;
1192    }
1193
1194    /**
1195     * Retrieves a field from the object by name passed in as a String.
1196     *
1197     * @param name field name
1198     * @return value
1199     */

1200    public Object JavaDoc getByName(String JavaDoc name)
1201    {
1202          if (name.equals("CustomerCatId"))
1203        {
1204                return new Integer JavaDoc(getCustomerCatId());
1205            }
1206          if (name.equals("CustomerCatName"))
1207        {
1208                return getCustomerCatName();
1209            }
1210          return null;
1211    }
1212    
1213    /**
1214     * Retrieves a field from the object by name passed in
1215     * as a String. The String must be one of the static
1216     * Strings defined in this Class' Peer.
1217     *
1218     * @param name peer name
1219     * @return value
1220     */

1221    public Object JavaDoc getByPeerName(String JavaDoc name)
1222    {
1223          if (name.equals(CustomerCategoryPeer.CUSTOMER_CAT_ID))
1224        {
1225                return new Integer JavaDoc(getCustomerCatId());
1226            }
1227          if (name.equals(CustomerCategoryPeer.CUSTOMER_CAT_NAME))
1228        {
1229                return getCustomerCatName();
1230            }
1231          return null;
1232    }
1233
1234    /**
1235     * Retrieves a field from the object by Position as specified
1236     * in the xml schema. Zero-based.
1237     *
1238     * @param pos position in xml schema
1239     * @return value
1240     */

1241    public Object JavaDoc getByPosition(int pos)
1242    {
1243            if (pos == 0)
1244        {
1245                return new Integer JavaDoc(getCustomerCatId());
1246            }
1247              if (pos == 1)
1248        {
1249                return getCustomerCatName();
1250            }
1251              return null;
1252    }
1253     
1254    /**
1255     * Stores the object in the database. If the object is new,
1256     * it inserts it; otherwise an update is performed.
1257     *
1258     * @throws Exception
1259     */

1260    public void save() throws Exception JavaDoc
1261    {
1262          save(CustomerCategoryPeer.getMapBuilder()
1263                .getDatabaseMap().getName());
1264      }
1265
1266    /**
1267     * Stores the object in the database. If the object is new,
1268     * it inserts it; otherwise an update is performed.
1269       * Note: this code is here because the method body is
1270     * auto-generated conditionally and therefore needs to be
1271     * in this file instead of in the super class, BaseObject.
1272       *
1273     * @param dbName
1274     * @throws TorqueException
1275     */

1276    public void save(String JavaDoc dbName) throws TorqueException
1277    {
1278        Connection JavaDoc con = null;
1279          try
1280        {
1281            con = Transaction.begin(dbName);
1282            save(con);
1283            Transaction.commit(con);
1284        }
1285        catch(TorqueException e)
1286        {
1287            Transaction.safeRollback(con);
1288            throw e;
1289        }
1290      }
1291
1292      /** flag to prevent endless save loop, if this object is referenced
1293        by another object which falls in this transaction. */

1294    private boolean alreadyInSave = false;
1295      /**
1296     * Stores the object in the database. If the object is new,
1297     * it inserts it; otherwise an update is performed. This method
1298     * is meant to be used as part of a transaction, otherwise use
1299     * the save() method and the connection details will be handled
1300     * internally
1301     *
1302     * @param con
1303     * @throws TorqueException
1304     */

1305    public void save(Connection JavaDoc con) throws TorqueException
1306    {
1307          if (!alreadyInSave)
1308        {
1309            alreadyInSave = true;
1310
1311
1312  
1313            // If this object has been modified, then save it to the database.
1314
if (isModified())
1315            {
1316                if (isNew())
1317                {
1318                    CustomerCategoryPeer.doInsert((CustomerCategory) this, con);
1319                    setNew(false);
1320                }
1321                else
1322                {
1323                    CustomerCategoryPeer.doUpdate((CustomerCategory) this, con);
1324                }
1325            }
1326
1327                                      
1328                
1329                    if (collCustomers != null)
1330            {
1331                for (int i = 0; i < collCustomers.size(); i++)
1332                {
1333                    ((Customer) collCustomers.get(i)).save(con);
1334                }
1335            }
1336                                                  
1337                
1338                    if (collNewsletters != null)
1339            {
1340                for (int i = 0; i < collNewsletters.size(); i++)
1341                {
1342                    ((Newsletter) collNewsletters.get(i)).save(con);
1343                }
1344            }
1345                                  alreadyInSave = false;
1346        }
1347      }
1348
1349                        
1350      /**
1351     * Set the PrimaryKey using ObjectKey.
1352     *
1353     * @param key customerCatId ObjectKey
1354     */

1355    public void setPrimaryKey(ObjectKey key)
1356        throws TorqueException
1357    {
1358            setCustomerCatId(((NumberKey) key).intValue());
1359        }
1360
1361    /**
1362     * Set the PrimaryKey using a String.
1363     *
1364     * @param key
1365     */

1366    public void setPrimaryKey(String JavaDoc key) throws TorqueException
1367    {
1368            setCustomerCatId(Integer.parseInt(key));
1369        }
1370
1371  
1372    /**
1373     * returns an id that differentiates this object from others
1374     * of its class.
1375     */

1376    public ObjectKey getPrimaryKey()
1377    {
1378          return SimpleKey.keyFor(getCustomerCatId());
1379      }
1380 
1381    /**
1382     * get an id that differentiates this object from others
1383     * of its class.
1384     */

1385    public String JavaDoc getQueryKey()
1386    {
1387        if (getPrimaryKey() == null)
1388        {
1389            return "";
1390        }
1391        else
1392        {
1393            return getPrimaryKey().toString();
1394        }
1395    }
1396
1397    /**
1398     * set an id that differentiates this object from others
1399     * of its class.
1400     */

1401    public void setQueryKey(String JavaDoc key)
1402        throws TorqueException
1403    {
1404        setPrimaryKey(key);
1405    }
1406
1407    /**
1408     * Makes a copy of this object.
1409     * It creates a new object filling in the simple attributes.
1410       * It then fills all the association collections and sets the
1411     * related objects to isNew=true.
1412       */

1413      public CustomerCategory copy() throws TorqueException
1414    {
1415        return copyInto(new CustomerCategory());
1416    }
1417  
1418    protected CustomerCategory copyInto(CustomerCategory copyObj) throws TorqueException
1419    {
1420          copyObj.setCustomerCatId(customerCatId);
1421          copyObj.setCustomerCatName(customerCatName);
1422  
1423                            copyObj.setCustomerCatId( 0);
1424                  
1425                                      
1426                            
1427        List JavaDoc v = getCustomers();
1428        for (int i = 0; i < v.size(); i++)
1429        {
1430            Customer obj = (Customer) v.get(i);
1431            copyObj.addCustomer(obj.copy());
1432        }
1433                                                  
1434                            
1435        v = getNewsletters();
1436        for (int i = 0; i < v.size(); i++)
1437        {
1438            Newsletter obj = (Newsletter) v.get(i);
1439            copyObj.addNewsletter(obj.copy());
1440        }
1441                            return copyObj;
1442    }
1443
1444    /**
1445     * returns a peer instance associated with this om. Since Peer classes
1446     * are not to have any instance attributes, this method returns the
1447     * same instance for all member of this class. The method could therefore
1448     * be static, but this would prevent one from overriding the behavior.
1449     */

1450    public CustomerCategoryPeer getPeer()
1451    {
1452        return peer;
1453    }
1454
1455    public String JavaDoc toString()
1456    {
1457        StringBuffer JavaDoc str = new StringBuffer JavaDoc();
1458        str.append("CustomerCategory:\n");
1459        str.append("CustomerCatId = ")
1460               .append(getCustomerCatId())
1461             .append("\n");
1462        str.append("CustomerCatName = ")
1463               .append(getCustomerCatName())
1464             .append("\n");
1465        return(str.toString());
1466    }
1467}
1468
Popular Tags