View Javadoc

1   package net.sourceforge.blogentis.om;
2   
3   
4   import java.sql.Connection;
5   import java.util.ArrayList;
6   import java.util.Collections;
7   import java.util.List;
8   
9   import org.apache.commons.lang.ObjectUtils;
10  import org.apache.torque.TorqueException;
11  import org.apache.torque.om.BaseObject;
12  import org.apache.torque.om.NumberKey;
13  import org.apache.torque.om.ObjectKey;
14  import org.apache.torque.om.SimpleKey;
15  import org.apache.torque.util.Criteria;
16  import org.apache.torque.util.Transaction;
17  
18  
19  /***
20   * You should not use this class directly.  It should not even be
21   * extended all references should be to TurbineRole
22   */
23  public abstract class BaseTurbineRole extends BaseObject
24      implements org.apache.turbine.om.Retrievable
25  {
26      /*** The Peer class */
27      private static final TurbineRolePeer peer =
28          new TurbineRolePeer();
29  
30          
31      /*** The value for the roleId field */
32      private int roleId;
33        
34      /*** The value for the name field */
35      private String name;
36        
37      /*** The value for the objectdata field */
38      private byte[] objectdata;
39    
40      
41      /***
42       * Get the RoleId
43       *
44       * @return int
45       */
46      public int getRoleId()
47      {
48          return roleId;
49      }
50  
51                                                
52      /***
53       * Set the value of RoleId
54       *
55       * @param v new value
56       */
57      public void setRoleId(int v) throws TorqueException
58      {
59      
60                    if (this.roleId != v)
61                {
62              this.roleId = v;
63              setModified(true);
64          }
65      
66            
67                                    
68                    // update associated TurbineRolePermission
69          if (collTurbineRolePermissions != null)
70          {
71              for (int i = 0; i < collTurbineRolePermissions.size(); i++)
72              {
73                  ((TurbineRolePermission) collTurbineRolePermissions.get(i))
74                      .setRoleId(v);
75              }
76          }
77                                                      
78                    // update associated TurbineUserGroupRole
79          if (collTurbineUserGroupRoles != null)
80          {
81              for (int i = 0; i < collTurbineUserGroupRoles.size(); i++)
82              {
83                  ((TurbineUserGroupRole) collTurbineUserGroupRoles.get(i))
84                      .setRoleId(v);
85              }
86          }
87                                  }
88    
89      /***
90       * Get the Name
91       *
92       * @return String
93       */
94      public String getName()
95      {
96          return name;
97      }
98  
99                          
100     /***
101      * Set the value of Name
102      *
103      * @param v new value
104      */
105     public void setName(String v) 
106     {
107     
108                   if (!ObjectUtils.equals(this.name, v))
109               {
110             this.name = v;
111             setModified(true);
112         }
113     
114           
115               }
116   
117     /***
118      * Get the Objectdata
119      *
120      * @return byte[]
121      */
122     public byte[] getObjectdata()
123     {
124         return objectdata;
125     }
126 
127                         
128     /***
129      * Set the value of Objectdata
130      *
131      * @param v new value
132      */
133     public void setObjectdata(byte[] v) 
134     {
135     
136                   if (!ObjectUtils.equals(this.objectdata, v))
137               {
138             this.objectdata = v;
139             setModified(true);
140         }
141     
142           
143               }
144   
145          
146                                 
147             
148           /***
149      * Collection to store aggregation of collTurbineRolePermissions
150      */
151     protected List collTurbineRolePermissions;
152 
153     /***
154      * Temporary storage of collTurbineRolePermissions to save a possible db hit in
155      * the event objects are add to the collection, but the
156      * complete collection is never requested.
157      */
158     protected void initTurbineRolePermissions()
159     {
160         if (collTurbineRolePermissions == null)
161         {
162             collTurbineRolePermissions = new ArrayList();
163         }
164     }
165 
166     /***
167      * Method called to associate a TurbineRolePermission object to this object
168      * through the TurbineRolePermission foreign key attribute
169      *
170      * @param l TurbineRolePermission
171      * @throws TorqueException
172      */
173     public void addTurbineRolePermission(TurbineRolePermission l) throws TorqueException
174     {
175         getTurbineRolePermissions().add(l);
176         l.setTurbineRole((TurbineRole) this);
177     }
178 
179     /***
180      * The criteria used to select the current contents of collTurbineRolePermissions
181      */
182     private Criteria lastTurbineRolePermissionsCriteria = null;
183       
184     /***
185      * If this collection has already been initialized, returns
186      * the collection. Otherwise returns the results of
187      * getTurbineRolePermissions(new Criteria())
188      *
189      * @throws TorqueException
190      */
191     public List getTurbineRolePermissions() throws TorqueException
192     {
193               if (collTurbineRolePermissions == null)
194         {
195             collTurbineRolePermissions = getTurbineRolePermissions(new Criteria(10));
196         }
197         return collTurbineRolePermissions;
198           }
199 
200     /***
201      * If this collection has already been initialized with
202      * an identical criteria, it returns the collection.
203      * Otherwise if this TurbineRole has previously
204      * been saved, it will retrieve related TurbineRolePermissions from storage.
205      * If this TurbineRole is new, it will return
206      * an empty collection or the current collection, the criteria
207      * is ignored on a new object.
208      *
209      * @throws TorqueException
210      */
211     public List getTurbineRolePermissions(Criteria criteria) throws TorqueException
212     {
213               if (collTurbineRolePermissions == null)
214         {
215             if (isNew())
216             {
217                collTurbineRolePermissions = new ArrayList();
218             }
219             else
220             {
221                         criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId() );
222                         collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria);
223             }
224         }
225         else
226         {
227             // criteria has no effect for a new object
228             if (!isNew())
229             {
230                 // the following code is to determine if a new query is
231                 // called for.  If the criteria is the same as the last
232                 // one, just return the collection.
233                             criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
234                             if (!lastTurbineRolePermissionsCriteria.equals(criteria))
235                 {
236                     collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria);
237                 }
238             }
239         }
240         lastTurbineRolePermissionsCriteria = criteria;
241 
242         return collTurbineRolePermissions;
243           }
244 
245     /***
246      * If this collection has already been initialized, returns
247      * the collection. Otherwise returns the results of
248      * getTurbineRolePermissions(new Criteria(),Connection)
249      * This method takes in the Connection also as input so that
250      * referenced objects can also be obtained using a Connection
251      * that is taken as input
252      */
253     public List getTurbineRolePermissions(Connection con) throws TorqueException
254     {
255               if (collTurbineRolePermissions == null)
256         {
257             collTurbineRolePermissions = getTurbineRolePermissions(new Criteria(10), con);
258         }
259         return collTurbineRolePermissions;
260           }
261 
262     /***
263      * If this collection has already been initialized with
264      * an identical criteria, it returns the collection.
265      * Otherwise if this TurbineRole has previously
266      * been saved, it will retrieve related TurbineRolePermissions from storage.
267      * If this TurbineRole is new, it will return
268      * an empty collection or the current collection, the criteria
269      * is ignored on a new object.
270      * This method takes in the Connection also as input so that
271      * referenced objects can also be obtained using a Connection
272      * that is taken as input
273      */
274     public List getTurbineRolePermissions(Criteria criteria, Connection con)
275             throws TorqueException
276     {
277               if (collTurbineRolePermissions == null)
278         {
279             if (isNew())
280             {
281                collTurbineRolePermissions = new ArrayList();
282             }
283             else
284             {
285                          criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
286                          collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria, con);
287              }
288          }
289          else
290          {
291              // criteria has no effect for a new object
292              if (!isNew())
293              {
294                  // the following code is to determine if a new query is
295                  // called for.  If the criteria is the same as the last
296                  // one, just return the collection.
297                               criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
298                              if (!lastTurbineRolePermissionsCriteria.equals(criteria))
299                  {
300                      collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria, con);
301                  }
302              }
303          }
304          lastTurbineRolePermissionsCriteria = criteria;
305 
306          return collTurbineRolePermissions;
307            }
308 
309                         
310               
311                     
312                               
313                                 
314                                                               
315                                         
316                     
317                     
318           
319     /***
320      * If this collection has already been initialized with
321      * an identical criteria, it returns the collection.
322      * Otherwise if this TurbineRole is new, it will return
323      * an empty collection; or if this TurbineRole has previously
324      * been saved, it will retrieve related TurbineRolePermissions from storage.
325      *
326      * This method is protected by default in order to keep the public
327      * api reasonable.  You can provide public methods for those you
328      * actually need in TurbineRole.
329      */
330     protected List getTurbineRolePermissionsJoinTurbineRole(Criteria criteria)
331         throws TorqueException
332     {
333                     if (collTurbineRolePermissions == null)
334         {
335             if (isNew())
336             {
337                collTurbineRolePermissions = new ArrayList();
338             }
339             else
340             {
341                               criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
342                               collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbineRole(criteria);
343             }
344         }
345         else
346         {
347             // the following code is to determine if a new query is
348             // called for.  If the criteria is the same as the last
349             // one, just return the collection.
350                         boolean newCriteria = true;
351                         criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
352                                     if (!lastTurbineRolePermissionsCriteria.equals(criteria))
353             {
354                 collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbineRole(criteria);
355             }
356         }
357         lastTurbineRolePermissionsCriteria = criteria;
358 
359         return collTurbineRolePermissions;
360                 }
361                   
362                     
363                     
364                                 
365                                                               
366                                         
367                     
368                     
369           
370     /***
371      * If this collection has already been initialized with
372      * an identical criteria, it returns the collection.
373      * Otherwise if this TurbineRole is new, it will return
374      * an empty collection; or if this TurbineRole has previously
375      * been saved, it will retrieve related TurbineRolePermissions from storage.
376      *
377      * This method is protected by default in order to keep the public
378      * api reasonable.  You can provide public methods for those you
379      * actually need in TurbineRole.
380      */
381     protected List getTurbineRolePermissionsJoinTurbinePermission(Criteria criteria)
382         throws TorqueException
383     {
384                     if (collTurbineRolePermissions == null)
385         {
386             if (isNew())
387             {
388                collTurbineRolePermissions = new ArrayList();
389             }
390             else
391             {
392                               criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
393                               collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbinePermission(criteria);
394             }
395         }
396         else
397         {
398             // the following code is to determine if a new query is
399             // called for.  If the criteria is the same as the last
400             // one, just return the collection.
401                         boolean newCriteria = true;
402                         criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
403                                     if (!lastTurbineRolePermissionsCriteria.equals(criteria))
404             {
405                 collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbinePermission(criteria);
406             }
407         }
408         lastTurbineRolePermissionsCriteria = criteria;
409 
410         return collTurbineRolePermissions;
411                 }
412                             
413 
414 
415                           
416             
417           /***
418      * Collection to store aggregation of collTurbineUserGroupRoles
419      */
420     protected List collTurbineUserGroupRoles;
421 
422     /***
423      * Temporary storage of collTurbineUserGroupRoles to save a possible db hit in
424      * the event objects are add to the collection, but the
425      * complete collection is never requested.
426      */
427     protected void initTurbineUserGroupRoles()
428     {
429         if (collTurbineUserGroupRoles == null)
430         {
431             collTurbineUserGroupRoles = new ArrayList();
432         }
433     }
434 
435     /***
436      * Method called to associate a TurbineUserGroupRole object to this object
437      * through the TurbineUserGroupRole foreign key attribute
438      *
439      * @param l TurbineUserGroupRole
440      * @throws TorqueException
441      */
442     public void addTurbineUserGroupRole(TurbineUserGroupRole l) throws TorqueException
443     {
444         getTurbineUserGroupRoles().add(l);
445         l.setTurbineRole((TurbineRole) this);
446     }
447 
448     /***
449      * The criteria used to select the current contents of collTurbineUserGroupRoles
450      */
451     private Criteria lastTurbineUserGroupRolesCriteria = null;
452       
453     /***
454      * If this collection has already been initialized, returns
455      * the collection. Otherwise returns the results of
456      * getTurbineUserGroupRoles(new Criteria())
457      *
458      * @throws TorqueException
459      */
460     public List getTurbineUserGroupRoles() throws TorqueException
461     {
462               if (collTurbineUserGroupRoles == null)
463         {
464             collTurbineUserGroupRoles = getTurbineUserGroupRoles(new Criteria(10));
465         }
466         return collTurbineUserGroupRoles;
467           }
468 
469     /***
470      * If this collection has already been initialized with
471      * an identical criteria, it returns the collection.
472      * Otherwise if this TurbineRole has previously
473      * been saved, it will retrieve related TurbineUserGroupRoles from storage.
474      * If this TurbineRole is new, it will return
475      * an empty collection or the current collection, the criteria
476      * is ignored on a new object.
477      *
478      * @throws TorqueException
479      */
480     public List getTurbineUserGroupRoles(Criteria criteria) throws TorqueException
481     {
482               if (collTurbineUserGroupRoles == null)
483         {
484             if (isNew())
485             {
486                collTurbineUserGroupRoles = new ArrayList();
487             }
488             else
489             {
490                         criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId() );
491                         collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria);
492             }
493         }
494         else
495         {
496             // criteria has no effect for a new object
497             if (!isNew())
498             {
499                 // the following code is to determine if a new query is
500                 // called for.  If the criteria is the same as the last
501                 // one, just return the collection.
502                             criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
503                             if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
504                 {
505                     collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria);
506                 }
507             }
508         }
509         lastTurbineUserGroupRolesCriteria = criteria;
510 
511         return collTurbineUserGroupRoles;
512           }
513 
514     /***
515      * If this collection has already been initialized, returns
516      * the collection. Otherwise returns the results of
517      * getTurbineUserGroupRoles(new Criteria(),Connection)
518      * This method takes in the Connection also as input so that
519      * referenced objects can also be obtained using a Connection
520      * that is taken as input
521      */
522     public List getTurbineUserGroupRoles(Connection con) throws TorqueException
523     {
524               if (collTurbineUserGroupRoles == null)
525         {
526             collTurbineUserGroupRoles = getTurbineUserGroupRoles(new Criteria(10), con);
527         }
528         return collTurbineUserGroupRoles;
529           }
530 
531     /***
532      * If this collection has already been initialized with
533      * an identical criteria, it returns the collection.
534      * Otherwise if this TurbineRole has previously
535      * been saved, it will retrieve related TurbineUserGroupRoles from storage.
536      * If this TurbineRole is new, it will return
537      * an empty collection or the current collection, the criteria
538      * is ignored on a new object.
539      * This method takes in the Connection also as input so that
540      * referenced objects can also be obtained using a Connection
541      * that is taken as input
542      */
543     public List getTurbineUserGroupRoles(Criteria criteria, Connection con)
544             throws TorqueException
545     {
546               if (collTurbineUserGroupRoles == null)
547         {
548             if (isNew())
549             {
550                collTurbineUserGroupRoles = new ArrayList();
551             }
552             else
553             {
554                          criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
555                          collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria, con);
556              }
557          }
558          else
559          {
560              // criteria has no effect for a new object
561              if (!isNew())
562              {
563                  // the following code is to determine if a new query is
564                  // called for.  If the criteria is the same as the last
565                  // one, just return the collection.
566                               criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
567                              if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
568                  {
569                      collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria, con);
570                  }
571              }
572          }
573          lastTurbineUserGroupRolesCriteria = criteria;
574 
575          return collTurbineUserGroupRoles;
576            }
577 
578                               
579               
580                     
581                     
582                                 
583                                                               
584                                         
585                     
586                     
587           
588     /***
589      * If this collection has already been initialized with
590      * an identical criteria, it returns the collection.
591      * Otherwise if this TurbineRole is new, it will return
592      * an empty collection; or if this TurbineRole has previously
593      * been saved, it will retrieve related TurbineUserGroupRoles from storage.
594      *
595      * This method is protected by default in order to keep the public
596      * api reasonable.  You can provide public methods for those you
597      * actually need in TurbineRole.
598      */
599     protected List getTurbineUserGroupRolesJoinTurbineUser(Criteria criteria)
600         throws TorqueException
601     {
602                     if (collTurbineUserGroupRoles == null)
603         {
604             if (isNew())
605             {
606                collTurbineUserGroupRoles = new ArrayList();
607             }
608             else
609             {
610                               criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
611                               collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineUser(criteria);
612             }
613         }
614         else
615         {
616             // the following code is to determine if a new query is
617             // called for.  If the criteria is the same as the last
618             // one, just return the collection.
619                         boolean newCriteria = true;
620                         criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
621                                     if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
622             {
623                 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineUser(criteria);
624             }
625         }
626         lastTurbineUserGroupRolesCriteria = criteria;
627 
628         return collTurbineUserGroupRoles;
629                 }
630                   
631                     
632                     
633                                 
634                                                               
635                                         
636                     
637                     
638           
639     /***
640      * If this collection has already been initialized with
641      * an identical criteria, it returns the collection.
642      * Otherwise if this TurbineRole is new, it will return
643      * an empty collection; or if this TurbineRole has previously
644      * been saved, it will retrieve related TurbineUserGroupRoles from storage.
645      *
646      * This method is protected by default in order to keep the public
647      * api reasonable.  You can provide public methods for those you
648      * actually need in TurbineRole.
649      */
650     protected List getTurbineUserGroupRolesJoinTurbineGroup(Criteria criteria)
651         throws TorqueException
652     {
653                     if (collTurbineUserGroupRoles == null)
654         {
655             if (isNew())
656             {
657                collTurbineUserGroupRoles = new ArrayList();
658             }
659             else
660             {
661                               criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
662                               collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria);
663             }
664         }
665         else
666         {
667             // the following code is to determine if a new query is
668             // called for.  If the criteria is the same as the last
669             // one, just return the collection.
670                         boolean newCriteria = true;
671                         criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
672                                     if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
673             {
674                 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria);
675             }
676         }
677         lastTurbineUserGroupRolesCriteria = criteria;
678 
679         return collTurbineUserGroupRoles;
680                 }
681                   
682                     
683                               
684                                 
685                                                               
686                                         
687                     
688                     
689           
690     /***
691      * If this collection has already been initialized with
692      * an identical criteria, it returns the collection.
693      * Otherwise if this TurbineRole is new, it will return
694      * an empty collection; or if this TurbineRole has previously
695      * been saved, it will retrieve related TurbineUserGroupRoles from storage.
696      *
697      * This method is protected by default in order to keep the public
698      * api reasonable.  You can provide public methods for those you
699      * actually need in TurbineRole.
700      */
701     protected List getTurbineUserGroupRolesJoinTurbineRole(Criteria criteria)
702         throws TorqueException
703     {
704                     if (collTurbineUserGroupRoles == null)
705         {
706             if (isNew())
707             {
708                collTurbineUserGroupRoles = new ArrayList();
709             }
710             else
711             {
712                               criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
713                               collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria);
714             }
715         }
716         else
717         {
718             // the following code is to determine if a new query is
719             // called for.  If the criteria is the same as the last
720             // one, just return the collection.
721                         boolean newCriteria = true;
722                         criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
723                                     if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
724             {
725                 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria);
726             }
727         }
728         lastTurbineUserGroupRolesCriteria = criteria;
729 
730         return collTurbineUserGroupRoles;
731                 }
732                             
733 
734 
735           
736     private static List fieldNames = null;
737 
738     /***
739      * Generate a list of field names.
740      *
741      * @return a list of field names
742      */
743     public static synchronized List getFieldNames()
744     {
745         if (fieldNames == null)
746         {
747             fieldNames = new ArrayList();
748               fieldNames.add("RoleId");
749               fieldNames.add("Name");
750               fieldNames.add("Objectdata");
751               fieldNames = Collections.unmodifiableList(fieldNames);
752         }
753         return fieldNames;
754     }
755 
756     /***
757      * Retrieves a field from the object by name passed in as a String.
758      *
759      * @param name field name
760      * @return value
761      */
762     public Object getByName(String name)
763     {
764           if (name.equals("RoleId"))
765         {
766                 return new Integer(getRoleId());
767             }
768           if (name.equals("Name"))
769         {
770                 return getName();
771             }
772           if (name.equals("Objectdata"))
773         {
774                 return getObjectdata();
775             }
776           return null;
777     }
778     
779     /***
780      * Retrieves a field from the object by name passed in
781      * as a String.  The String must be one of the static
782      * Strings defined in this Class' Peer.
783      *
784      * @param name peer name
785      * @return value
786      */
787     public Object getByPeerName(String name)
788     {
789           if (name.equals(TurbineRolePeer.ROLE_ID))
790         {
791                 return new Integer(getRoleId());
792             }
793           if (name.equals(TurbineRolePeer.ROLE_NAME))
794         {
795                 return getName();
796             }
797           if (name.equals(TurbineRolePeer.OBJECTDATA))
798         {
799                 return getObjectdata();
800             }
801           return null;
802     }
803 
804     /***
805      * Retrieves a field from the object by Position as specified
806      * in the xml schema.  Zero-based.
807      *
808      * @param pos position in xml schema
809      * @return value
810      */
811     public Object getByPosition(int pos)
812     {
813             if (pos == 0)
814         {
815                 return new Integer(getRoleId());
816             }
817               if (pos == 1)
818         {
819                 return getName();
820             }
821               if (pos == 2)
822         {
823                 return getObjectdata();
824             }
825               return null;
826     }
827      
828     /***
829      * Stores the object in the database.  If the object is new,
830      * it inserts it; otherwise an update is performed.
831      *
832      * @throws Exception
833      */
834     public void save() throws Exception
835     {
836           save(TurbineRolePeer.getMapBuilder()
837                 .getDatabaseMap().getName());
838       }
839 
840     /***
841      * Stores the object in the database.  If the object is new,
842      * it inserts it; otherwise an update is performed.
843        * Note: this code is here because the method body is
844      * auto-generated conditionally and therefore needs to be
845      * in this file instead of in the super class, BaseObject.
846        *
847      * @param dbName
848      * @throws TorqueException
849      */
850     public void save(String dbName) throws TorqueException
851     {
852         Connection con = null;
853           try
854         {
855             con = Transaction.begin(dbName);
856             save(con);
857             Transaction.commit(con);
858         }
859         catch(TorqueException e)
860         {
861             Transaction.safeRollback(con);
862             throw e;
863         }
864       }
865 
866       /*** flag to prevent endless save loop, if this object is referenced
867         by another object which falls in this transaction. */
868     private boolean alreadyInSave = false;
869       /***
870      * Stores the object in the database.  If the object is new,
871      * it inserts it; otherwise an update is performed.  This method
872      * is meant to be used as part of a transaction, otherwise use
873      * the save() method and the connection details will be handled
874      * internally
875      *
876      * @param con
877      * @throws TorqueException
878      */
879     public void save(Connection con) throws TorqueException
880     {
881           if (!alreadyInSave)
882         {
883             alreadyInSave = true;
884 
885 
886   
887             // If this object has been modified, then save it to the database.
888             if (isModified())
889             {
890                 if (isNew())
891                 {
892                     TurbineRolePeer.doInsert((TurbineRole) this, con);
893                     setNew(false);
894                 }
895                 else
896                 {
897                     TurbineRolePeer.doUpdate((TurbineRole) this, con);
898                 }
899             }
900 
901                                       
902                 
903                     if (collTurbineRolePermissions != null)
904             {
905                 for (int i = 0; i < collTurbineRolePermissions.size(); i++)
906                 {
907                     ((TurbineRolePermission) collTurbineRolePermissions.get(i)).save(con);
908                 }
909             }
910                                                   
911                 
912                     if (collTurbineUserGroupRoles != null)
913             {
914                 for (int i = 0; i < collTurbineUserGroupRoles.size(); i++)
915                 {
916                     ((TurbineUserGroupRole) collTurbineUserGroupRoles.get(i)).save(con);
917                 }
918             }
919                                   alreadyInSave = false;
920         }
921       }
922 
923                         
924       /***
925      * Set the PrimaryKey using ObjectKey.
926      *
927      * @param  roleId ObjectKey
928      */
929     public void setPrimaryKey(ObjectKey key)
930         throws TorqueException
931     {
932             setRoleId(((NumberKey) key).intValue());
933         }
934 
935     /***
936      * Set the PrimaryKey using a String.
937      *
938      * @param key
939      */
940     public void setPrimaryKey(String key) throws TorqueException
941     {
942             setRoleId(Integer.parseInt(key));
943         }
944 
945   
946     /***
947      * returns an id that differentiates this object from others
948      * of its class.
949      */
950     public ObjectKey getPrimaryKey()
951     {
952           return SimpleKey.keyFor(getRoleId());
953       }
954  
955     /***
956      * get an id that differentiates this object from others
957      * of its class.
958      */
959     public String getQueryKey()
960     {
961         if (getPrimaryKey() == null)
962         {
963             return "";
964         }
965         else
966         {
967             return getPrimaryKey().toString();
968         }
969     }
970 
971     /***
972      * set an id that differentiates this object from others
973      * of its class.
974      */
975     public void setQueryKey(String key)
976         throws TorqueException
977     {
978         setPrimaryKey(key);
979     }
980 
981     /***
982      * Makes a copy of this object.
983      * It creates a new object filling in the simple attributes.
984        * It then fills all the association collections and sets the
985      * related objects to isNew=true.
986        */
987       public TurbineRole copy() throws TorqueException
988     {
989         return copyInto(new TurbineRole());
990     }
991   
992     protected TurbineRole copyInto(TurbineRole copyObj) throws TorqueException
993     {
994           copyObj.setRoleId(roleId);
995           copyObj.setName(name);
996           copyObj.setObjectdata(objectdata);
997   
998                             copyObj.setRoleId( 0);
999                         
1000                                       
1001                             
1002         List v = getTurbineRolePermissions();
1003         for (int i = 0; i < v.size(); i++)
1004         {
1005             TurbineRolePermission obj = (TurbineRolePermission) v.get(i);
1006             copyObj.addTurbineRolePermission(obj.copy());
1007         }
1008                                                   
1009                             
1010         v = getTurbineUserGroupRoles();
1011         for (int i = 0; i < v.size(); i++)
1012         {
1013             TurbineUserGroupRole obj = (TurbineUserGroupRole) v.get(i);
1014             copyObj.addTurbineUserGroupRole(obj.copy());
1015         }
1016                             return copyObj;
1017     }
1018 
1019     /***
1020      * returns a peer instance associated with this om.  Since Peer classes
1021      * are not to have any instance attributes, this method returns the
1022      * same instance for all member of this class. The method could therefore
1023      * be static, but this would prevent one from overriding the behavior.
1024      */
1025     public TurbineRolePeer getPeer()
1026     {
1027         return peer;
1028     }
1029 
1030     public String toString()
1031     {
1032         StringBuffer str = new StringBuffer();
1033         str.append("TurbineRole:\n");
1034         str.append("RoleId = ")
1035            .append(getRoleId())
1036            .append("\n");
1037         str.append("Name = ")
1038            .append(getName())
1039            .append("\n");
1040         str.append("Objectdata = ")
1041            .append(getObjectdata())
1042            .append("\n");
1043         return(str.toString());
1044     }
1045 }