View Javadoc

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