KickJava   Java API By Example, From Geeks To Geeks.

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


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 Country
33  */

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

57     public int getCountryId()
58     {
59         return countryId;
60     }
61
62                                               
63     /**
64      * Set the value of CountryId
65      *
66      * @param v new value
67      */

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

105     public String JavaDoc getCountryName()
106     {
107         return countryName;
108     }
109
110                         
111     /**
112      * Set the value of CountryName
113      *
114      * @param v new value
115      */

116     public void setCountryName(String JavaDoc v)
117     {
118     
119                   if (!ObjectUtils.equals(this.countryName, v))
120               {
121             this.countryName = v;
122             setModified(true);
123         }
124     
125           
126               }
127   
128     /**
129      * Get the CountryCode
130      *
131      * @return String
132      */

133     public String JavaDoc getCountryCode()
134     {
135         return countryCode;
136     }
137
138                         
139     /**
140      * Set the value of CountryCode
141      *
142      * @param v new value
143      */

144     public void setCountryCode(String JavaDoc v)
145     {
146     
147                   if (!ObjectUtils.equals(this.countryCode, v))
148               {
149             this.countryCode = v;
150             setModified(true);
151         }
152     
153           
154               }
155   
156          
157                                 
158             
159           /**
160      * Collection to store aggregation of collCustomers
161      */

162     protected List JavaDoc collCustomers;
163
164     /**
165      * Temporary storage of collCustomers to save a possible db hit in
166      * the event objects are add to the collection, but the
167      * complete collection is never requested.
168      */

169     protected void initCustomers()
170     {
171         if (collCustomers == null)
172         {
173             collCustomers = new ArrayList JavaDoc();
174         }
175     }
176
177     /**
178      * Method called to associate a Customer object to this object
179      * through the Customer foreign key attribute
180      *
181      * @param l Customer
182      * @throws TorqueException
183      */

184     public void addCustomer(Customer l) throws TorqueException
185     {
186         getCustomers().add(l);
187         l.setCountry((Country) this);
188     }
189
190     /**
191      * The criteria used to select the current contents of collCustomers
192      */

193     private Criteria lastCustomersCriteria = null;
194       
195     /**
196      * If this collection has already been initialized, returns
197      * the collection. Otherwise returns the results of
198      * getCustomers(new Criteria())
199      *
200      * @throws TorqueException
201      */

202     public List JavaDoc getCustomers() throws TorqueException
203     {
204               if (collCustomers == null)
205         {
206             collCustomers = getCustomers(new Criteria(10));
207         }
208         return collCustomers;
209           }
210
211     /**
212      * If this collection has already been initialized with
213      * an identical criteria, it returns the collection.
214      * Otherwise if this Country has previously
215      * been saved, it will retrieve related Customers from storage.
216      * If this Country is new, it will return
217      * an empty collection or the current collection, the criteria
218      * is ignored on a new object.
219      *
220      * @throws TorqueException
221      */

222     public List JavaDoc getCustomers(Criteria criteria) throws TorqueException
223     {
224               if (collCustomers == null)
225         {
226             if (isNew())
227             {
228                collCustomers = new ArrayList JavaDoc();
229             }
230             else
231             {
232                         criteria.add(CustomerPeer.COUNTRY_ID, getCountryId() );
233                         collCustomers = CustomerPeer.doSelect(criteria);
234             }
235         }
236         else
237         {
238             // criteria has no effect for a new object
239
if (!isNew())
240             {
241                 // the following code is to determine if a new query is
242
// called for. If the criteria is the same as the last
243
// one, just return the collection.
244
criteria.add(CustomerPeer.COUNTRY_ID, getCountryId());
245                             if (!lastCustomersCriteria.equals(criteria))
246                 {
247                     collCustomers = CustomerPeer.doSelect(criteria);
248                 }
249             }
250         }
251         lastCustomersCriteria = criteria;
252
253         return collCustomers;
254           }
255
256     /**
257      * If this collection has already been initialized, returns
258      * the collection. Otherwise returns the results of
259      * getCustomers(new Criteria(),Connection)
260      * This method takes in the Connection also as input so that
261      * referenced objects can also be obtained using a Connection
262      * that is taken as input
263      */

264     public List JavaDoc getCustomers(Connection JavaDoc con) throws TorqueException
265     {
266               if (collCustomers == null)
267         {
268             collCustomers = getCustomers(new Criteria(10), con);
269         }
270         return collCustomers;
271           }
272
273     /**
274      * If this collection has already been initialized with
275      * an identical criteria, it returns the collection.
276      * Otherwise if this Country has previously
277      * been saved, it will retrieve related Customers from storage.
278      * If this Country is new, it will return
279      * an empty collection or the current collection, the criteria
280      * is ignored on a new object.
281      * This method takes in the Connection also as input so that
282      * referenced objects can also be obtained using a Connection
283      * that is taken as input
284      */

285     public List JavaDoc getCustomers(Criteria criteria, Connection JavaDoc con)
286             throws TorqueException
287     {
288               if (collCustomers == null)
289         {
290             if (isNew())
291             {
292                collCustomers = new ArrayList JavaDoc();
293             }
294             else
295             {
296                          criteria.add(CustomerPeer.COUNTRY_ID, getCountryId());
297                          collCustomers = CustomerPeer.doSelect(criteria, con);
298              }
299          }
300          else
301          {
302              // criteria has no effect for a new object
303
if (!isNew())
304              {
305                  // the following code is to determine if a new query is
306
// called for. If the criteria is the same as the last
307
// one, just return the collection.
308
criteria.add(CustomerPeer.COUNTRY_ID, getCountryId());
309                              if (!lastCustomersCriteria.equals(criteria))
310                  {
311                      collCustomers = CustomerPeer.doSelect(criteria, con);
312                  }
313              }
314          }
315          lastCustomersCriteria = criteria;
316
317          return collCustomers;
318            }
319
320                                                 
321               
322                     
323                     
324                                 
325                                                               
326                                         
327                     
328                     
329           
330     /**
331      * If this collection has already been initialized with
332      * an identical criteria, it returns the collection.
333      * Otherwise if this Country is new, it will return
334      * an empty collection; or if this Country has previously
335      * been saved, it will retrieve related Customers from storage.
336      *
337      * This method is protected by default in order to keep the public
338      * api reasonable. You can provide public methods for those you
339      * actually need in Country.
340      */

341     protected List JavaDoc getCustomersJoinCustomerCategory(Criteria criteria)
342         throws TorqueException
343     {
344                     if (collCustomers == null)
345         {
346             if (isNew())
347             {
348                collCustomers = new ArrayList JavaDoc();
349             }
350             else
351             {
352                               criteria.add(CustomerPeer.COUNTRY_ID, getCountryId());
353                               collCustomers = CustomerPeer.doSelectJoinCustomerCategory(criteria);
354             }
355         }
356         else
357         {
358             // the following code is to determine if a new query is
359
// called for. If the criteria is the same as the last
360
// one, just return the collection.
361

362                         criteria.add(CustomerPeer.COUNTRY_ID, getCountryId());
363                                     if (!lastCustomersCriteria.equals(criteria))
364             {
365                 collCustomers = CustomerPeer.doSelectJoinCustomerCategory(criteria);
366             }
367         }
368         lastCustomersCriteria = criteria;
369
370         return collCustomers;
371                 }
372                   
373                     
374                               
375                                 
376                                                               
377                                         
378                     
379                     
380           
381     /**
382      * If this collection has already been initialized with
383      * an identical criteria, it returns the collection.
384      * Otherwise if this Country is new, it will return
385      * an empty collection; or if this Country has previously
386      * been saved, it will retrieve related Customers from storage.
387      *
388      * This method is protected by default in order to keep the public
389      * api reasonable. You can provide public methods for those you
390      * actually need in Country.
391      */

392     protected List JavaDoc getCustomersJoinCountry(Criteria criteria)
393         throws TorqueException
394     {
395                     if (collCustomers == null)
396         {
397             if (isNew())
398             {
399                collCustomers = new ArrayList JavaDoc();
400             }
401             else
402             {
403                               criteria.add(CustomerPeer.COUNTRY_ID, getCountryId());
404                               collCustomers = CustomerPeer.doSelectJoinCountry(criteria);
405             }
406         }
407         else
408         {
409             // the following code is to determine if a new query is
410
// called for. If the criteria is the same as the last
411
// one, just return the collection.
412

413                         criteria.add(CustomerPeer.COUNTRY_ID, getCountryId());
414                                     if (!lastCustomersCriteria.equals(criteria))
415             {
416                 collCustomers = CustomerPeer.doSelectJoinCountry(criteria);
417             }
418         }
419         lastCustomersCriteria = criteria;
420
421         return collCustomers;
422                 }
423                   
424                     
425                     
426                                 
427                                                               
428                                         
429                     
430                     
431           
432     /**
433      * If this collection has already been initialized with
434      * an identical criteria, it returns the collection.
435      * Otherwise if this Country is new, it will return
436      * an empty collection; or if this Country has previously
437      * been saved, it will retrieve related Customers from storage.
438      *
439      * This method is protected by default in order to keep the public
440      * api reasonable. You can provide public methods for those you
441      * actually need in Country.
442      */

443     protected List JavaDoc getCustomersJoinRegion(Criteria criteria)
444         throws TorqueException
445     {
446                     if (collCustomers == null)
447         {
448             if (isNew())
449             {
450                collCustomers = new ArrayList JavaDoc();
451             }
452             else
453             {
454                               criteria.add(CustomerPeer.COUNTRY_ID, getCountryId());
455                               collCustomers = CustomerPeer.doSelectJoinRegion(criteria);
456             }
457         }
458         else
459         {
460             // the following code is to determine if a new query is
461
// called for. If the criteria is the same as the last
462
// one, just return the collection.
463

464                         criteria.add(CustomerPeer.COUNTRY_ID, getCountryId());
465                                     if (!lastCustomersCriteria.equals(criteria))
466             {
467                 collCustomers = CustomerPeer.doSelectJoinRegion(criteria);
468             }
469         }
470         lastCustomersCriteria = criteria;
471
472         return collCustomers;
473                 }
474                   
475                     
476                     
477                                 
478                                                               
479                                         
480                     
481                     
482           
483     /**
484      * If this collection has already been initialized with
485      * an identical criteria, it returns the collection.
486      * Otherwise if this Country is new, it will return
487      * an empty collection; or if this Country has previously
488      * been saved, it will retrieve related Customers from storage.
489      *
490      * This method is protected by default in order to keep the public
491      * api reasonable. You can provide public methods for those you
492      * actually need in Country.
493      */

494     protected List JavaDoc getCustomersJoinLanguage(Criteria criteria)
495         throws TorqueException
496     {
497                     if (collCustomers == null)
498         {
499             if (isNew())
500             {
501                collCustomers = new ArrayList JavaDoc();
502             }
503             else
504             {
505                               criteria.add(CustomerPeer.COUNTRY_ID, getCountryId());
506                               collCustomers = CustomerPeer.doSelectJoinLanguage(criteria);
507             }
508         }
509         else
510         {
511             // the following code is to determine if a new query is
512
// called for. If the criteria is the same as the last
513
// one, just return the collection.
514

515                         criteria.add(CustomerPeer.COUNTRY_ID, getCountryId());
516                                     if (!lastCustomersCriteria.equals(criteria))
517             {
518                 collCustomers = CustomerPeer.doSelectJoinLanguage(criteria);
519             }
520         }
521         lastCustomersCriteria = criteria;
522
523         return collCustomers;
524                 }
525                   
526                     
527                     
528                                 
529                                                               
530                                         
531                     
532                     
533           
534     /**
535      * If this collection has already been initialized with
536      * an identical criteria, it returns the collection.
537      * Otherwise if this Country is new, it will return
538      * an empty collection; or if this Country has previously
539      * been saved, it will retrieve related Customers from storage.
540      *
541      * This method is protected by default in order to keep the public
542      * api reasonable. You can provide public methods for those you
543      * actually need in Country.
544      */

545     protected List JavaDoc getCustomersJoinEducationCategory(Criteria criteria)
546         throws TorqueException
547     {
548                     if (collCustomers == null)
549         {
550             if (isNew())
551             {
552                collCustomers = new ArrayList JavaDoc();
553             }
554             else
555             {
556                               criteria.add(CustomerPeer.COUNTRY_ID, getCountryId());
557                               collCustomers = CustomerPeer.doSelectJoinEducationCategory(criteria);
558             }
559         }
560         else
561         {
562             // the following code is to determine if a new query is
563
// called for. If the criteria is the same as the last
564
// one, just return the collection.
565

566                         criteria.add(CustomerPeer.COUNTRY_ID, getCountryId());
567                                     if (!lastCustomersCriteria.equals(criteria))
568             {
569                 collCustomers = CustomerPeer.doSelectJoinEducationCategory(criteria);
570             }
571         }
572         lastCustomersCriteria = criteria;
573
574         return collCustomers;
575                 }
576                   
577                     
578                     
579                                 
580                                                               
581                                         
582                     
583                     
584           
585     /**
586      * If this collection has already been initialized with
587      * an identical criteria, it returns the collection.
588      * Otherwise if this Country is new, it will return
589      * an empty collection; or if this Country has previously
590      * been saved, it will retrieve related Customers from storage.
591      *
592      * This method is protected by default in order to keep the public
593      * api reasonable. You can provide public methods for those you
594      * actually need in Country.
595      */

596     protected List JavaDoc getCustomersJoinHouseholdCategory(Criteria criteria)
597         throws TorqueException
598     {
599                     if (collCustomers == null)
600         {
601             if (isNew())
602             {
603                collCustomers = new ArrayList JavaDoc();
604             }
605             else
606             {
607                               criteria.add(CustomerPeer.COUNTRY_ID, getCountryId());
608                               collCustomers = CustomerPeer.doSelectJoinHouseholdCategory(criteria);
609             }
610         }
611         else
612         {
613             // the following code is to determine if a new query is
614
// called for. If the criteria is the same as the last
615
// one, just return the collection.
616

617                         criteria.add(CustomerPeer.COUNTRY_ID, getCountryId());
618                                     if (!lastCustomersCriteria.equals(criteria))
619             {
620                 collCustomers = CustomerPeer.doSelectJoinHouseholdCategory(criteria);
621             }
622         }
623         lastCustomersCriteria = criteria;
624
625         return collCustomers;
626                 }
627                             
628
629
630                           
631             
632           /**
633      * Collection to store aggregation of collNewsletters
634      */

635     protected List JavaDoc collNewsletters;
636
637     /**
638      * Temporary storage of collNewsletters to save a possible db hit in
639      * the event objects are add to the collection, but the
640      * complete collection is never requested.
641      */

642     protected void initNewsletters()
643     {
644         if (collNewsletters == null)
645         {
646             collNewsletters = new ArrayList JavaDoc();
647         }
648     }
649
650     /**
651      * Method called to associate a Newsletter object to this object
652      * through the Newsletter foreign key attribute
653      *
654      * @param l Newsletter
655      * @throws TorqueException
656      */

657     public void addNewsletter(Newsletter l) throws TorqueException
658     {
659         getNewsletters().add(l);
660         l.setCountry((Country) this);
661     }
662
663     /**
664      * The criteria used to select the current contents of collNewsletters
665      */

666     private Criteria lastNewslettersCriteria = null;
667       
668     /**
669      * If this collection has already been initialized, returns
670      * the collection. Otherwise returns the results of
671      * getNewsletters(new Criteria())
672      *
673      * @throws TorqueException
674      */

675     public List JavaDoc getNewsletters() throws TorqueException
676     {
677               if (collNewsletters == null)
678         {
679             collNewsletters = getNewsletters(new Criteria(10));
680         }
681         return collNewsletters;
682           }
683
684     /**
685      * If this collection has already been initialized with
686      * an identical criteria, it returns the collection.
687      * Otherwise if this Country has previously
688      * been saved, it will retrieve related Newsletters from storage.
689      * If this Country is new, it will return
690      * an empty collection or the current collection, the criteria
691      * is ignored on a new object.
692      *
693      * @throws TorqueException
694      */

695     public List JavaDoc getNewsletters(Criteria criteria) throws TorqueException
696     {
697               if (collNewsletters == null)
698         {
699             if (isNew())
700             {
701                collNewsletters = new ArrayList JavaDoc();
702             }
703             else
704             {
705                         criteria.add(NewsletterPeer.CUST_COUNTRY_ID, getCountryId() );
706                         collNewsletters = NewsletterPeer.doSelect(criteria);
707             }
708         }
709         else
710         {
711             // criteria has no effect for a new object
712
if (!isNew())
713             {
714                 // the following code is to determine if a new query is
715
// called for. If the criteria is the same as the last
716
// one, just return the collection.
717
criteria.add(NewsletterPeer.CUST_COUNTRY_ID, getCountryId());
718                             if (!lastNewslettersCriteria.equals(criteria))
719                 {
720                     collNewsletters = NewsletterPeer.doSelect(criteria);
721                 }
722             }
723         }
724         lastNewslettersCriteria = criteria;
725
726         return collNewsletters;
727           }
728
729     /**
730      * If this collection has already been initialized, returns
731      * the collection. Otherwise returns the results of
732      * getNewsletters(new Criteria(),Connection)
733      * This method takes in the Connection also as input so that
734      * referenced objects can also be obtained using a Connection
735      * that is taken as input
736      */

737     public List JavaDoc getNewsletters(Connection JavaDoc con) throws TorqueException
738     {
739               if (collNewsletters == null)
740         {
741             collNewsletters = getNewsletters(new Criteria(10), con);
742         }
743         return collNewsletters;
744           }
745
746     /**
747      * If this collection has already been initialized with
748      * an identical criteria, it returns the collection.
749      * Otherwise if this Country has previously
750      * been saved, it will retrieve related Newsletters from storage.
751      * If this Country is new, it will return
752      * an empty collection or the current collection, the criteria
753      * is ignored on a new object.
754      * This method takes in the Connection also as input so that
755      * referenced objects can also be obtained using a Connection
756      * that is taken as input
757      */

758     public List JavaDoc getNewsletters(Criteria criteria, Connection JavaDoc con)
759             throws TorqueException
760     {
761               if (collNewsletters == null)
762         {
763             if (isNew())
764             {
765                collNewsletters = new ArrayList JavaDoc();
766             }
767             else
768             {
769                          criteria.add(NewsletterPeer.CUST_COUNTRY_ID, getCountryId());
770                          collNewsletters = NewsletterPeer.doSelect(criteria, con);
771              }
772          }
773          else
774          {
775              // criteria has no effect for a new object
776
if (!isNew())
777              {
778                  // the following code is to determine if a new query is
779
// called for. If the criteria is the same as the last
780
// one, just return the collection.
781
criteria.add(NewsletterPeer.CUST_COUNTRY_ID, getCountryId());
782                              if (!lastNewslettersCriteria.equals(criteria))
783                  {
784                      collNewsletters = NewsletterPeer.doSelect(criteria, con);
785                  }
786              }
787          }
788          lastNewslettersCriteria = criteria;
789
790          return collNewsletters;
791            }
792
793                                                             
794               
795                     
796                     
797                                 
798                                                               
799                                         
800                     
801                     
802           
803     /**
804      * If this collection has already been initialized with
805      * an identical criteria, it returns the collection.
806      * Otherwise if this Country is new, it will return
807      * an empty collection; or if this Country has previously
808      * been saved, it will retrieve related Newsletters from storage.
809      *
810      * This method is protected by default in order to keep the public
811      * api reasonable. You can provide public methods for those you
812      * actually need in Country.
813      */

814     protected List JavaDoc getNewslettersJoinCustomerCategory(Criteria criteria)
815         throws TorqueException
816     {
817                     if (collNewsletters == null)
818         {
819             if (isNew())
820             {
821                collNewsletters = new ArrayList JavaDoc();
822             }
823             else
824             {
825                               criteria.add(NewsletterPeer.CUST_COUNTRY_ID, getCountryId());
826                               collNewsletters = NewsletterPeer.doSelectJoinCustomerCategory(criteria);
827             }
828         }
829         else
830         {
831             // the following code is to determine if a new query is
832
// called for. If the criteria is the same as the last
833
// one, just return the collection.
834

835                         criteria.add(NewsletterPeer.CUST_COUNTRY_ID, getCountryId());
836                                     if (!lastNewslettersCriteria.equals(criteria))
837             {
838                 collNewsletters = NewsletterPeer.doSelectJoinCustomerCategory(criteria);
839             }
840         }
841         lastNewslettersCriteria = criteria;
842
843         return collNewsletters;
844                 }
845                   
846                     
847                     
848                                             
849                                                                           
850                                         
851                     
852                     
853           
854     /**
855      * If this collection has already been initialized with
856      * an identical criteria, it returns the collection.
857      * Otherwise if this Country is new, it will return
858      * an empty collection; or if this Country has previously
859      * been saved, it will retrieve related Newsletters from storage.
860      *
861      * This method is protected by default in order to keep the public
862      * api reasonable. You can provide public methods for those you
863      * actually need in Country.
864      */

865     protected List JavaDoc getNewslettersJoinProjectRelatedByProjectId(Criteria criteria)
866         throws TorqueException
867     {
868                     if (collNewsletters == null)
869         {
870             if (isNew())
871             {
872                collNewsletters = new ArrayList JavaDoc();
873             }
874             else
875             {
876                               criteria.add(NewsletterPeer.CUST_COUNTRY_ID, getCountryId());
877                               collNewsletters = NewsletterPeer.doSelectJoinProjectRelatedByProjectId(criteria);
878             }
879         }
880         else
881         {
882             // the following code is to determine if a new query is
883
// called for. If the criteria is the same as the last
884
// one, just return the collection.
885

886                         criteria.add(NewsletterPeer.CUST_COUNTRY_ID, getCountryId());
887                                     if (!lastNewslettersCriteria.equals(criteria))
888             {
889                 collNewsletters = NewsletterPeer.doSelectJoinProjectRelatedByProjectId(criteria);
890             }
891         }
892         lastNewslettersCriteria = criteria;
893
894         return collNewsletters;
895                 }
896                   
897                     
898                     
899                                             
900                                                                           
901                                         
902                     
903                     
904           
905     /**
906      * If this collection has already been initialized with
907      * an identical criteria, it returns the collection.
908      * Otherwise if this Country is new, it will return
909      * an empty collection; or if this Country has previously
910      * been saved, it will retrieve related Newsletters from storage.
911      *
912      * This method is protected by default in order to keep the public
913      * api reasonable. You can provide public methods for those you
914      * actually need in Country.
915      */

916     protected List JavaDoc getNewslettersJoinProductRelatedByProductId(Criteria criteria)
917         throws TorqueException
918     {
919                     if (collNewsletters == null)
920         {
921             if (isNew())
922             {
923                collNewsletters = new ArrayList JavaDoc();
924             }
925             else
926             {
927                               criteria.add(NewsletterPeer.CUST_COUNTRY_ID, getCountryId());
928                               collNewsletters = NewsletterPeer.doSelectJoinProductRelatedByProductId(criteria);
929             }
930         }
931         else
932         {
933             // the following code is to determine if a new query is
934
// called for. If the criteria is the same as the last
935
// one, just return the collection.
936

937                         criteria.add(NewsletterPeer.CUST_COUNTRY_ID, getCountryId());
938                                     if (!lastNewslettersCriteria.equals(criteria))
939             {
940                 collNewsletters = NewsletterPeer.doSelectJoinProductRelatedByProductId(criteria);
941             }
942         }
943         lastNewslettersCriteria = criteria;
944
945         return collNewsletters;
946                 }
947                   
948                     
949                     
950                                             
951                                                                           
952                                         
953                     
954                     
955           
956     /**
957      * If this collection has already been initialized with
958      * an identical criteria, it returns the collection.
959      * Otherwise if this Country is new, it will return
960      * an empty collection; or if this Country has previously
961      * been saved, it will retrieve related Newsletters from storage.
962      *
963      * This method is protected by default in order to keep the public
964      * api reasonable. You can provide public methods for those you
965      * actually need in Country.
966      */

967     protected List JavaDoc getNewslettersJoinProjectRelatedByRelProjectId(Criteria criteria)
968         throws TorqueException
969     {
970                     if (collNewsletters == null)
971         {
972             if (isNew())
973             {
974                collNewsletters = new ArrayList JavaDoc();
975             }
976             else
977             {
978                               criteria.add(NewsletterPeer.CUST_COUNTRY_ID, getCountryId());
979                               collNewsletters = NewsletterPeer.doSelectJoinProjectRelatedByRelProjectId(criteria);
980             }
981         }
982         else
983         {
984             // the following code is to determine if a new query is
985
// called for. If the criteria is the same as the last
986
// one, just return the collection.
987

988                         criteria.add(NewsletterPeer.CUST_COUNTRY_ID, getCountryId());
989                                     if (!lastNewslettersCriteria.equals(criteria))
990             {
991                 collNewsletters = NewsletterPeer.doSelectJoinProjectRelatedByRelProjectId(criteria);
992             }
993         }
994         lastNewslettersCriteria = criteria;
995
996         return collNewsletters;
997                 }
998                   
999                     
1000                    
1001                                            
1002                                                                          
1003                                        
1004                    
1005                    
1006          
1007    /**
1008     * If this collection has already been initialized with
1009     * an identical criteria, it returns the collection.
1010     * Otherwise if this Country is new, it will return
1011     * an empty collection; or if this Country has previously
1012     * been saved, it will retrieve related Newsletters from storage.
1013     *
1014     * This method is protected by default in order to keep the public
1015     * api reasonable. You can provide public methods for those you
1016     * actually need in Country.
1017     */

1018    protected List JavaDoc getNewslettersJoinProductRelatedByRelProductId(Criteria criteria)
1019        throws TorqueException
1020    {
1021                    if (collNewsletters == null)
1022        {
1023            if (isNew())
1024            {
1025               collNewsletters = new ArrayList JavaDoc();
1026            }
1027            else
1028            {
1029                              criteria.add(NewsletterPeer.CUST_COUNTRY_ID, getCountryId());
1030                              collNewsletters = NewsletterPeer.doSelectJoinProductRelatedByRelProductId(criteria);
1031            }
1032        }
1033        else
1034        {
1035            // the following code is to determine if a new query is
1036
// called for. If the criteria is the same as the last
1037
// one, just return the collection.
1038

1039                        criteria.add(NewsletterPeer.CUST_COUNTRY_ID, getCountryId());
1040                                    if (!lastNewslettersCriteria.equals(criteria))
1041            {
1042                collNewsletters = NewsletterPeer.doSelectJoinProductRelatedByRelProductId(criteria);
1043            }
1044        }
1045        lastNewslettersCriteria = criteria;
1046
1047        return collNewsletters;
1048                }
1049                  
1050                    
1051                              
1052                                
1053                                                              
1054                                        
1055                    
1056                    
1057          
1058    /**
1059     * If this collection has already been initialized with
1060     * an identical criteria, it returns the collection.
1061     * Otherwise if this Country is new, it will return
1062     * an empty collection; or if this Country has previously
1063     * been saved, it will retrieve related Newsletters from storage.
1064     *
1065     * This method is protected by default in order to keep the public
1066     * api reasonable. You can provide public methods for those you
1067     * actually need in Country.
1068     */

1069    protected List JavaDoc getNewslettersJoinCountry(Criteria criteria)
1070        throws TorqueException
1071    {
1072                    if (collNewsletters == null)
1073        {
1074            if (isNew())
1075            {
1076               collNewsletters = new ArrayList JavaDoc();
1077            }
1078            else
1079            {
1080                              criteria.add(NewsletterPeer.CUST_COUNTRY_ID, getCountryId());
1081                              collNewsletters = NewsletterPeer.doSelectJoinCountry(criteria);
1082            }
1083        }
1084        else
1085        {
1086            // the following code is to determine if a new query is
1087
// called for. If the criteria is the same as the last
1088
// one, just return the collection.
1089

1090                        criteria.add(NewsletterPeer.CUST_COUNTRY_ID, getCountryId());
1091                                    if (!lastNewslettersCriteria.equals(criteria))
1092            {
1093                collNewsletters = NewsletterPeer.doSelectJoinCountry(criteria);
1094            }
1095        }
1096        lastNewslettersCriteria = criteria;
1097
1098        return collNewsletters;
1099                }
1100                  
1101                    
1102                    
1103                                            
1104                                                                          
1105                                        
1106                    
1107                    
1108          
1109    /**
1110     * If this collection has already been initialized with
1111     * an identical criteria, it returns the collection.
1112     * Otherwise if this Country is new, it will return
1113     * an empty collection; or if this Country has previously
1114     * been saved, it will retrieve related Newsletters from storage.
1115     *
1116     * This method is protected by default in order to keep the public
1117     * api reasonable. You can provide public methods for those you
1118     * actually need in Country.
1119     */

1120    protected List JavaDoc getNewslettersJoinLanguageRelatedByCustLanguageId(Criteria criteria)
1121        throws TorqueException
1122    {
1123                    if (collNewsletters == null)
1124        {
1125            if (isNew())
1126            {
1127               collNewsletters = new ArrayList JavaDoc();
1128            }
1129            else
1130            {
1131                              criteria.add(NewsletterPeer.CUST_COUNTRY_ID, getCountryId());
1132                              collNewsletters = NewsletterPeer.doSelectJoinLanguageRelatedByCustLanguageId(criteria);
1133            }
1134        }
1135        else
1136        {
1137            // the following code is to determine if a new query is
1138
// called for. If the criteria is the same as the last
1139
// one, just return the collection.
1140

1141                        criteria.add(NewsletterPeer.CUST_COUNTRY_ID, getCountryId());
1142                                    if (!lastNewslettersCriteria.equals(criteria))
1143            {
1144                collNewsletters = NewsletterPeer.doSelectJoinLanguageRelatedByCustLanguageId(criteria);
1145            }
1146        }
1147        lastNewslettersCriteria = criteria;
1148
1149        return collNewsletters;
1150                }
1151                  
1152                    
1153                    
1154                                            
1155                                                                          
1156                                        
1157                    
1158                    
1159          
1160    /**
1161     * If this collection has already been initialized with
1162     * an identical criteria, it returns the collection.
1163     * Otherwise if this Country is new, it will return
1164     * an empty collection; or if this Country has previously
1165     * been saved, it will retrieve related Newsletters from storage.
1166     *
1167     * This method is protected by default in order to keep the public
1168     * api reasonable. You can provide public methods for those you
1169     * actually need in Country.
1170     */

1171    protected List JavaDoc getNewslettersJoinLanguageRelatedByLanguageId(Criteria criteria)
1172        throws TorqueException
1173    {
1174                    if (collNewsletters == null)
1175        {
1176            if (isNew())
1177            {
1178               collNewsletters = new ArrayList JavaDoc();
1179            }
1180            else
1181            {
1182                              criteria.add(NewsletterPeer.CUST_COUNTRY_ID, getCountryId());
1183                              collNewsletters = NewsletterPeer.doSelectJoinLanguageRelatedByLanguageId(criteria);
1184            }
1185        }
1186        else
1187        {
1188            // the following code is to determine if a new query is
1189
// called for. If the criteria is the same as the last
1190
// one, just return the collection.
1191

1192                        criteria.add(NewsletterPeer.CUST_COUNTRY_ID, getCountryId());
1193                                    if (!lastNewslettersCriteria.equals(criteria))
1194            {
1195                collNewsletters = NewsletterPeer.doSelectJoinLanguageRelatedByLanguageId(criteria);
1196            }
1197        }
1198        lastNewslettersCriteria = criteria;
1199
1200        return collNewsletters;
1201                }
1202                            
1203
1204
1205          
1206    private static List JavaDoc fieldNames = null;
1207
1208    /**
1209     * Generate a list of field names.
1210     *
1211     * @return a list of field names
1212     */

1213    public static synchronized List JavaDoc getFieldNames()
1214    {
1215        if (fieldNames == null)
1216        {
1217            fieldNames = new ArrayList JavaDoc();
1218              fieldNames.add("CountryId");
1219              fieldNames.add("CountryName");
1220              fieldNames.add("CountryCode");
1221              fieldNames = Collections.unmodifiableList(fieldNames);
1222        }
1223        return fieldNames;
1224    }
1225
1226    /**
1227     * Retrieves a field from the object by name passed in as a String.
1228     *
1229     * @param name field name
1230     * @return value
1231     */

1232    public Object JavaDoc getByName(String JavaDoc name)
1233    {
1234          if (name.equals("CountryId"))
1235        {
1236                return new Integer JavaDoc(getCountryId());
1237            }
1238          if (name.equals("CountryName"))
1239        {
1240                return getCountryName();
1241            }
1242          if (name.equals("CountryCode"))
1243        {
1244                return getCountryCode();
1245            }
1246          return null;
1247    }
1248    
1249    /**
1250     * Retrieves a field from the object by name passed in
1251     * as a String. The String must be one of the static
1252     * Strings defined in this Class' Peer.
1253     *
1254     * @param name peer name
1255     * @return value
1256     */

1257    public Object JavaDoc getByPeerName(String JavaDoc name)
1258    {
1259          if (name.equals(CountryPeer.COUNTRY_ID))
1260        {
1261                return new Integer JavaDoc(getCountryId());
1262            }
1263          if (name.equals(CountryPeer.COUNTRY_NAME))
1264        {
1265                return getCountryName();
1266            }
1267          if (name.equals(CountryPeer.COUNTRY_CODE))
1268        {
1269                return getCountryCode();
1270            }
1271          return null;
1272    }
1273
1274    /**
1275     * Retrieves a field from the object by Position as specified
1276     * in the xml schema. Zero-based.
1277     *
1278     * @param pos position in xml schema
1279     * @return value
1280     */

1281    public Object JavaDoc getByPosition(int pos)
1282    {
1283            if (pos == 0)
1284        {
1285                return new Integer JavaDoc(getCountryId());
1286            }
1287              if (pos == 1)
1288        {
1289                return getCountryName();
1290            }
1291              if (pos == 2)
1292        {
1293                return getCountryCode();
1294            }
1295              return null;
1296    }
1297     
1298    /**
1299     * Stores the object in the database. If the object is new,
1300     * it inserts it; otherwise an update is performed.
1301     *
1302     * @throws Exception
1303     */

1304    public void save() throws Exception JavaDoc
1305    {
1306          save(CountryPeer.getMapBuilder()
1307                .getDatabaseMap().getName());
1308      }
1309
1310    /**
1311     * Stores the object in the database. If the object is new,
1312     * it inserts it; otherwise an update is performed.
1313       * Note: this code is here because the method body is
1314     * auto-generated conditionally and therefore needs to be
1315     * in this file instead of in the super class, BaseObject.
1316       *
1317     * @param dbName
1318     * @throws TorqueException
1319     */

1320    public void save(String JavaDoc dbName) throws TorqueException
1321    {
1322        Connection JavaDoc con = null;
1323          try
1324        {
1325            con = Transaction.begin(dbName);
1326            save(con);
1327            Transaction.commit(con);
1328        }
1329        catch(TorqueException e)
1330        {
1331            Transaction.safeRollback(con);
1332            throw e;
1333        }
1334      }
1335
1336      /** flag to prevent endless save loop, if this object is referenced
1337        by another object which falls in this transaction. */

1338    private boolean alreadyInSave = false;
1339      /**
1340     * Stores the object in the database. If the object is new,
1341     * it inserts it; otherwise an update is performed. This method
1342     * is meant to be used as part of a transaction, otherwise use
1343     * the save() method and the connection details will be handled
1344     * internally
1345     *
1346     * @param con
1347     * @throws TorqueException
1348     */

1349    public void save(Connection JavaDoc con) throws TorqueException
1350    {
1351          if (!alreadyInSave)
1352        {
1353            alreadyInSave = true;
1354
1355
1356  
1357            // If this object has been modified, then save it to the database.
1358
if (isModified())
1359            {
1360                if (isNew())
1361                {
1362                    CountryPeer.doInsert((Country) this, con);
1363                    setNew(false);
1364                }
1365                else
1366                {
1367                    CountryPeer.doUpdate((Country) this, con);
1368                }
1369            }
1370
1371                                      
1372                
1373                    if (collCustomers != null)
1374            {
1375                for (int i = 0; i < collCustomers.size(); i++)
1376                {
1377                    ((Customer) collCustomers.get(i)).save(con);
1378                }
1379            }
1380                                                  
1381                
1382                    if (collNewsletters != null)
1383            {
1384                for (int i = 0; i < collNewsletters.size(); i++)
1385                {
1386                    ((Newsletter) collNewsletters.get(i)).save(con);
1387                }
1388            }
1389                                  alreadyInSave = false;
1390        }
1391      }
1392
1393                        
1394      /**
1395     * Set the PrimaryKey using ObjectKey.
1396     *
1397     * @param key countryId ObjectKey
1398     */

1399    public void setPrimaryKey(ObjectKey key)
1400        throws TorqueException
1401    {
1402            setCountryId(((NumberKey) key).intValue());
1403        }
1404
1405    /**
1406     * Set the PrimaryKey using a String.
1407     *
1408     * @param key
1409     */

1410    public void setPrimaryKey(String JavaDoc key) throws TorqueException
1411    {
1412            setCountryId(Integer.parseInt(key));
1413        }
1414
1415  
1416    /**
1417     * returns an id that differentiates this object from others
1418     * of its class.
1419     */

1420    public ObjectKey getPrimaryKey()
1421    {
1422          return SimpleKey.keyFor(getCountryId());
1423      }
1424 
1425    /**
1426     * get an id that differentiates this object from others
1427     * of its class.
1428     */

1429    public String JavaDoc getQueryKey()
1430    {
1431        if (getPrimaryKey() == null)
1432        {
1433            return "";
1434        }
1435        else
1436        {
1437            return getPrimaryKey().toString();
1438        }
1439    }
1440
1441    /**
1442     * set an id that differentiates this object from others
1443     * of its class.
1444     */

1445    public void setQueryKey(String JavaDoc key)
1446        throws TorqueException
1447    {
1448        setPrimaryKey(key);
1449    }
1450
1451    /**
1452     * Makes a copy of this object.
1453     * It creates a new object filling in the simple attributes.
1454       * It then fills all the association collections and sets the
1455     * related objects to isNew=true.
1456       */

1457      public Country copy() throws TorqueException
1458    {
1459        return copyInto(new Country());
1460    }
1461  
1462    protected Country copyInto(Country copyObj) throws TorqueException
1463    {
1464          copyObj.setCountryId(countryId);
1465          copyObj.setCountryName(countryName);
1466          copyObj.setCountryCode(countryCode);
1467  
1468                            copyObj.setCountryId( 0);
1469                        
1470                                      
1471                            
1472        List JavaDoc v = getCustomers();
1473        for (int i = 0; i < v.size(); i++)
1474        {
1475            Customer obj = (Customer) v.get(i);
1476            copyObj.addCustomer(obj.copy());
1477        }
1478                                                  
1479                            
1480        v = getNewsletters();
1481        for (int i = 0; i < v.size(); i++)
1482        {
1483            Newsletter obj = (Newsletter) v.get(i);
1484            copyObj.addNewsletter(obj.copy());
1485        }
1486                            return copyObj;
1487    }
1488
1489    /**
1490     * returns a peer instance associated with this om. Since Peer classes
1491     * are not to have any instance attributes, this method returns the
1492     * same instance for all member of this class. The method could therefore
1493     * be static, but this would prevent one from overriding the behavior.
1494     */

1495    public CountryPeer getPeer()
1496    {
1497        return peer;
1498    }
1499
1500    public String JavaDoc toString()
1501    {
1502        StringBuffer JavaDoc str = new StringBuffer JavaDoc();
1503        str.append("Country:\n");
1504        str.append("CountryId = ")
1505               .append(getCountryId())
1506             .append("\n");
1507        str.append("CountryName = ")
1508               .append(getCountryName())
1509             .append("\n");
1510        str.append("CountryCode = ")
1511               .append(getCountryCode())
1512             .append("\n");
1513        return(str.toString());
1514    }
1515}
1516
Popular Tags