001    package org.apache.turbine.services.security.torque.om;
002    
003    
004    import java.math.BigDecimal;
005    import java.sql.Connection;
006    import java.util.ArrayList;
007    import java.util.Collections;
008    import java.util.Date;
009    import java.util.List;
010    
011    import org.apache.commons.lang.ObjectUtils;
012    import org.apache.torque.TorqueException;
013    import org.apache.torque.map.TableMap;
014    import org.apache.torque.om.BaseObject;
015    import org.apache.torque.om.ComboKey;
016    import org.apache.torque.om.DateKey;
017    import org.apache.torque.om.NumberKey;
018    import org.apache.torque.om.ObjectKey;
019    import org.apache.torque.om.SimpleKey;
020    import org.apache.torque.om.StringKey;
021    import org.apache.torque.om.Persistent;
022    import org.apache.torque.util.Criteria;
023    import org.apache.torque.util.Transaction;
024    
025    
026    
027    
028    
029    /**
030     * This class was autogenerated by Torque on:
031     *
032     * [Thu Jun 23 17:25:46 CEST 2011]
033     *
034     * You should not use this class directly.  It should not even be
035     * extended all references should be to TurbineRole
036     */
037    public abstract class BaseTurbineRole extends BaseObject
038    {
039        /** Serial version */
040        private static final long serialVersionUID = 1308842746584L;
041    
042        /** The Peer class */
043        private static final TurbineRolePeer peer =
044            new TurbineRolePeer();
045    
046    
047        /** The value for the roleId field */
048        private int roleId;
049    
050        /** The value for the name field */
051        private String name;
052    
053    
054        /**
055         * Get the RoleId
056         *
057         * @return int
058         */
059        public int getRoleId()
060        {
061            return roleId;
062        }
063    
064    
065        /**
066         * Set the value of RoleId
067         *
068         * @param v new value
069         */
070        public void setRoleId(int v) throws TorqueException
071        {
072    
073            if (this.roleId != v)
074            {
075                this.roleId = v;
076                setModified(true);
077            }
078    
079    
080    
081            // update associated TurbineRolePermission
082            if (collTurbineRolePermissions != null)
083            {
084                for (int i = 0; i < collTurbineRolePermissions.size(); i++)
085                {
086                    ((TurbineRolePermission) collTurbineRolePermissions.get(i))
087                            .setRoleId(v);
088                }
089            }
090    
091            // update associated TurbineUserGroupRole
092            if (collTurbineUserGroupRoles != null)
093            {
094                for (int i = 0; i < collTurbineUserGroupRoles.size(); i++)
095                {
096                    ((TurbineUserGroupRole) collTurbineUserGroupRoles.get(i))
097                            .setRoleId(v);
098                }
099            }
100        }
101    
102        /**
103         * Get the Name
104         *
105         * @return String
106         */
107        public String getName()
108        {
109            return name;
110        }
111    
112    
113        /**
114         * Set the value of Name
115         *
116         * @param v new value
117         */
118        public void setName(String v) 
119        {
120    
121            if (!ObjectUtils.equals(this.name, v))
122            {
123                this.name = v;
124                setModified(true);
125            }
126    
127    
128        }
129    
130           
131    
132    
133        /**
134         * Collection to store aggregation of collTurbineRolePermissions
135         */
136        protected List<TurbineRolePermission> collTurbineRolePermissions;
137    
138        /**
139         * Temporary storage of collTurbineRolePermissions to save a possible db hit in
140         * the event objects are add to the collection, but the
141         * complete collection is never requested.
142         */
143        protected void initTurbineRolePermissions()
144        {
145            if (collTurbineRolePermissions == null)
146            {
147                collTurbineRolePermissions = new ArrayList<TurbineRolePermission>();
148            }
149        }
150    
151    
152        /**
153         * Method called to associate a TurbineRolePermission object to this object
154         * through the TurbineRolePermission foreign key attribute
155         *
156         * @param l TurbineRolePermission
157         * @throws TorqueException
158         */
159        public void addTurbineRolePermission(TurbineRolePermission l) throws TorqueException
160        {
161            getTurbineRolePermissions().add(l);
162            l.setTurbineRole((TurbineRole) this);
163        }
164    
165        /**
166         * Method called to associate a TurbineRolePermission object to this object
167         * through the TurbineRolePermission foreign key attribute using connection.
168         *
169         * @param l TurbineRolePermission
170         * @throws TorqueException
171         */
172        public void addTurbineRolePermission(TurbineRolePermission l, Connection con) throws TorqueException
173        {
174            getTurbineRolePermissions(con).add(l);
175            l.setTurbineRole((TurbineRole) this);
176        }
177    
178        /**
179         * The criteria used to select the current contents of collTurbineRolePermissions
180         */
181        private Criteria lastTurbineRolePermissionsCriteria = null;
182    
183        /**
184         * If this collection has already been initialized, returns
185         * the collection. Otherwise returns the results of
186         * getTurbineRolePermissions(new Criteria())
187         *
188         * @return the collection of associated objects
189         * @throws TorqueException
190         */
191        public List<TurbineRolePermission> getTurbineRolePermissions()
192            throws TorqueException
193        {
194            if (collTurbineRolePermissions == null)
195            {
196                collTurbineRolePermissions = getTurbineRolePermissions(new Criteria(10));
197            }
198            return collTurbineRolePermissions;
199        }
200    
201        /**
202         * If this collection has already been initialized with
203         * an identical criteria, it returns the collection.
204         * Otherwise if this TurbineRole has previously
205         * been saved, it will retrieve related TurbineRolePermissions from storage.
206         * If this TurbineRole is new, it will return
207         * an empty collection or the current collection, the criteria
208         * is ignored on a new object.
209         *
210         * @throws TorqueException
211         */
212        public List<TurbineRolePermission> getTurbineRolePermissions(Criteria criteria) throws TorqueException
213        {
214            if (collTurbineRolePermissions == null)
215            {
216                if (isNew())
217                {
218                   collTurbineRolePermissions = new ArrayList<TurbineRolePermission>();
219                }
220                else
221                {
222                    criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId() );
223                    collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria);
224                }
225            }
226            else
227            {
228                // criteria has no effect for a new object
229                if (!isNew())
230                {
231                    // the following code is to determine if a new query is
232                    // called for.  If the criteria is the same as the last
233                    // one, just return the collection.
234                    criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
235                    if (!lastTurbineRolePermissionsCriteria.equals(criteria))
236                    {
237                        collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria);
238                    }
239                }
240            }
241            lastTurbineRolePermissionsCriteria = criteria;
242    
243            return collTurbineRolePermissions;
244        }
245    
246        /**
247         * If this collection has already been initialized, returns
248         * the collection. Otherwise returns the results of
249         * getTurbineRolePermissions(new Criteria(),Connection)
250         * This method takes in the Connection also as input so that
251         * referenced objects can also be obtained using a Connection
252         * that is taken as input
253         */
254        public List<TurbineRolePermission> getTurbineRolePermissions(Connection con) throws TorqueException
255        {
256            if (collTurbineRolePermissions == null)
257            {
258                collTurbineRolePermissions = getTurbineRolePermissions(new Criteria(10), con);
259            }
260            return collTurbineRolePermissions;
261        }
262    
263        /**
264         * If this collection has already been initialized with
265         * an identical criteria, it returns the collection.
266         * Otherwise if this TurbineRole has previously
267         * been saved, it will retrieve related TurbineRolePermissions from storage.
268         * If this TurbineRole is new, it will return
269         * an empty collection or the current collection, the criteria
270         * is ignored on a new object.
271         * This method takes in the Connection also as input so that
272         * referenced objects can also be obtained using a Connection
273         * that is taken as input
274         */
275        public List<TurbineRolePermission> getTurbineRolePermissions(Criteria criteria, Connection con)
276                throws TorqueException
277        {
278            if (collTurbineRolePermissions == null)
279            {
280                if (isNew())
281                {
282                   collTurbineRolePermissions = new ArrayList<TurbineRolePermission>();
283                }
284                else
285                {
286                     criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
287                     collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria, con);
288                 }
289             }
290             else
291             {
292                 // criteria has no effect for a new object
293                 if (!isNew())
294                 {
295                     // the following code is to determine if a new query is
296                     // called for.  If the criteria is the same as the last
297                     // one, just return the collection.
298                     criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
299                     if (!lastTurbineRolePermissionsCriteria.equals(criteria))
300                     {
301                         collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria, con);
302                     }
303                 }
304             }
305             lastTurbineRolePermissionsCriteria = criteria;
306    
307             return collTurbineRolePermissions;
308         }
309    
310    
311    
312    
313    
314    
315    
316    
317    
318    
319    
320        /**
321         * If this collection has already been initialized with
322         * an identical criteria, it returns the collection.
323         * Otherwise if this TurbineRole is new, it will return
324         * an empty collection; or if this TurbineRole has previously
325         * been saved, it will retrieve related TurbineRolePermissions from storage.
326         *
327         * This method is protected by default in order to keep the public
328         * api reasonable.  You can provide public methods for those you
329         * actually need in TurbineRole.
330         */
331        protected List<TurbineRolePermission> getTurbineRolePermissionsJoinTurbineRole(Criteria criteria)
332            throws TorqueException
333        {
334            if (collTurbineRolePermissions == null)
335            {
336                if (isNew())
337                {
338                   collTurbineRolePermissions = new ArrayList<TurbineRolePermission>();
339                }
340                else
341                {
342                    criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
343                    collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbineRole(criteria);
344                }
345            }
346            else
347            {
348                // the following code is to determine if a new query is
349                // called for.  If the criteria is the same as the last
350                // one, just return the collection.
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<TurbineRolePermission> getTurbineRolePermissionsJoinTurbinePermission(Criteria criteria)
382            throws TorqueException
383        {
384            if (collTurbineRolePermissions == null)
385            {
386                if (isNew())
387                {
388                   collTurbineRolePermissions = new ArrayList<TurbineRolePermission>();
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                criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
402                if (!lastTurbineRolePermissionsCriteria.equals(criteria))
403                {
404                    collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbinePermission(criteria);
405                }
406            }
407            lastTurbineRolePermissionsCriteria = criteria;
408    
409            return collTurbineRolePermissions;
410        }
411    
412    
413    
414    
415    
416        /**
417         * Collection to store aggregation of collTurbineUserGroupRoles
418         */
419        protected List<TurbineUserGroupRole> collTurbineUserGroupRoles;
420    
421        /**
422         * Temporary storage of collTurbineUserGroupRoles to save a possible db hit in
423         * the event objects are add to the collection, but the
424         * complete collection is never requested.
425         */
426        protected void initTurbineUserGroupRoles()
427        {
428            if (collTurbineUserGroupRoles == null)
429            {
430                collTurbineUserGroupRoles = new ArrayList<TurbineUserGroupRole>();
431            }
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         * Method called to associate a TurbineUserGroupRole object to this object
450         * through the TurbineUserGroupRole foreign key attribute using connection.
451         *
452         * @param l TurbineUserGroupRole
453         * @throws TorqueException
454         */
455        public void addTurbineUserGroupRole(TurbineUserGroupRole l, Connection con) throws TorqueException
456        {
457            getTurbineUserGroupRoles(con).add(l);
458            l.setTurbineRole((TurbineRole) this);
459        }
460    
461        /**
462         * The criteria used to select the current contents of collTurbineUserGroupRoles
463         */
464        private Criteria lastTurbineUserGroupRolesCriteria = null;
465    
466        /**
467         * If this collection has already been initialized, returns
468         * the collection. Otherwise returns the results of
469         * getTurbineUserGroupRoles(new Criteria())
470         *
471         * @return the collection of associated objects
472         * @throws TorqueException
473         */
474        public List<TurbineUserGroupRole> getTurbineUserGroupRoles()
475            throws TorqueException
476        {
477            if (collTurbineUserGroupRoles == null)
478            {
479                collTurbineUserGroupRoles = getTurbineUserGroupRoles(new Criteria(10));
480            }
481            return collTurbineUserGroupRoles;
482        }
483    
484        /**
485         * If this collection has already been initialized with
486         * an identical criteria, it returns the collection.
487         * Otherwise if this TurbineRole has previously
488         * been saved, it will retrieve related TurbineUserGroupRoles from storage.
489         * If this TurbineRole is new, it will return
490         * an empty collection or the current collection, the criteria
491         * is ignored on a new object.
492         *
493         * @throws TorqueException
494         */
495        public List<TurbineUserGroupRole> getTurbineUserGroupRoles(Criteria criteria) throws TorqueException
496        {
497            if (collTurbineUserGroupRoles == null)
498            {
499                if (isNew())
500                {
501                   collTurbineUserGroupRoles = new ArrayList<TurbineUserGroupRole>();
502                }
503                else
504                {
505                    criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId() );
506                    collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria);
507                }
508            }
509            else
510            {
511                // criteria has no effect for a new object
512                if (!isNew())
513                {
514                    // the following code is to determine if a new query is
515                    // called for.  If the criteria is the same as the last
516                    // one, just return the collection.
517                    criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
518                    if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
519                    {
520                        collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria);
521                    }
522                }
523            }
524            lastTurbineUserGroupRolesCriteria = criteria;
525    
526            return collTurbineUserGroupRoles;
527        }
528    
529        /**
530         * If this collection has already been initialized, returns
531         * the collection. Otherwise returns the results of
532         * getTurbineUserGroupRoles(new Criteria(),Connection)
533         * This method takes in the Connection also as input so that
534         * referenced objects can also be obtained using a Connection
535         * that is taken as input
536         */
537        public List<TurbineUserGroupRole> getTurbineUserGroupRoles(Connection con) throws TorqueException
538        {
539            if (collTurbineUserGroupRoles == null)
540            {
541                collTurbineUserGroupRoles = getTurbineUserGroupRoles(new Criteria(10), con);
542            }
543            return collTurbineUserGroupRoles;
544        }
545    
546        /**
547         * If this collection has already been initialized with
548         * an identical criteria, it returns the collection.
549         * Otherwise if this TurbineRole has previously
550         * been saved, it will retrieve related TurbineUserGroupRoles from storage.
551         * If this TurbineRole is new, it will return
552         * an empty collection or the current collection, the criteria
553         * is ignored on a new object.
554         * This method takes in the Connection also as input so that
555         * referenced objects can also be obtained using a Connection
556         * that is taken as input
557         */
558        public List<TurbineUserGroupRole> getTurbineUserGroupRoles(Criteria criteria, Connection con)
559                throws TorqueException
560        {
561            if (collTurbineUserGroupRoles == null)
562            {
563                if (isNew())
564                {
565                   collTurbineUserGroupRoles = new ArrayList<TurbineUserGroupRole>();
566                }
567                else
568                {
569                     criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
570                     collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria, con);
571                 }
572             }
573             else
574             {
575                 // criteria has no effect for a new object
576                 if (!isNew())
577                 {
578                     // the following code is to determine if a new query is
579                     // called for.  If the criteria is the same as the last
580                     // one, just return the collection.
581                     criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
582                     if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
583                     {
584                         collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria, con);
585                     }
586                 }
587             }
588             lastTurbineUserGroupRolesCriteria = criteria;
589    
590             return collTurbineUserGroupRoles;
591         }
592    
593    
594    
595    
596    
597    
598    
599    
600    
601    
602    
603        /**
604         * If this collection has already been initialized with
605         * an identical criteria, it returns the collection.
606         * Otherwise if this TurbineRole is new, it will return
607         * an empty collection; or if this TurbineRole has previously
608         * been saved, it will retrieve related TurbineUserGroupRoles from storage.
609         *
610         * This method is protected by default in order to keep the public
611         * api reasonable.  You can provide public methods for those you
612         * actually need in TurbineRole.
613         */
614        protected List<TurbineUserGroupRole> getTurbineUserGroupRolesJoinTurbineUser(Criteria criteria)
615            throws TorqueException
616        {
617            if (collTurbineUserGroupRoles == null)
618            {
619                if (isNew())
620                {
621                   collTurbineUserGroupRoles = new ArrayList<TurbineUserGroupRole>();
622                }
623                else
624                {
625                    criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
626                    collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineUser(criteria);
627                }
628            }
629            else
630            {
631                // the following code is to determine if a new query is
632                // called for.  If the criteria is the same as the last
633                // one, just return the collection.
634                criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
635                if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
636                {
637                    collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineUser(criteria);
638                }
639            }
640            lastTurbineUserGroupRolesCriteria = criteria;
641    
642            return collTurbineUserGroupRoles;
643        }
644    
645    
646    
647    
648    
649    
650    
651    
652    
653        /**
654         * If this collection has already been initialized with
655         * an identical criteria, it returns the collection.
656         * Otherwise if this TurbineRole is new, it will return
657         * an empty collection; or if this TurbineRole has previously
658         * been saved, it will retrieve related TurbineUserGroupRoles from storage.
659         *
660         * This method is protected by default in order to keep the public
661         * api reasonable.  You can provide public methods for those you
662         * actually need in TurbineRole.
663         */
664        protected List<TurbineUserGroupRole> getTurbineUserGroupRolesJoinTurbineGroup(Criteria criteria)
665            throws TorqueException
666        {
667            if (collTurbineUserGroupRoles == null)
668            {
669                if (isNew())
670                {
671                   collTurbineUserGroupRoles = new ArrayList<TurbineUserGroupRole>();
672                }
673                else
674                {
675                    criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
676                    collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria);
677                }
678            }
679            else
680            {
681                // the following code is to determine if a new query is
682                // called for.  If the criteria is the same as the last
683                // one, just return the collection.
684                criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
685                if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
686                {
687                    collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria);
688                }
689            }
690            lastTurbineUserGroupRolesCriteria = criteria;
691    
692            return collTurbineUserGroupRoles;
693        }
694    
695    
696    
697    
698    
699    
700    
701    
702    
703        /**
704         * If this collection has already been initialized with
705         * an identical criteria, it returns the collection.
706         * Otherwise if this TurbineRole is new, it will return
707         * an empty collection; or if this TurbineRole has previously
708         * been saved, it will retrieve related TurbineUserGroupRoles from storage.
709         *
710         * This method is protected by default in order to keep the public
711         * api reasonable.  You can provide public methods for those you
712         * actually need in TurbineRole.
713         */
714        protected List<TurbineUserGroupRole> getTurbineUserGroupRolesJoinTurbineRole(Criteria criteria)
715            throws TorqueException
716        {
717            if (collTurbineUserGroupRoles == null)
718            {
719                if (isNew())
720                {
721                   collTurbineUserGroupRoles = new ArrayList<TurbineUserGroupRole>();
722                }
723                else
724                {
725                    criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
726                    collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria);
727                }
728            }
729            else
730            {
731                // the following code is to determine if a new query is
732                // called for.  If the criteria is the same as the last
733                // one, just return the collection.
734                criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
735                if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
736                {
737                    collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria);
738                }
739            }
740            lastTurbineUserGroupRolesCriteria = criteria;
741    
742            return collTurbineUserGroupRoles;
743        }
744    
745    
746    
747            
748        private static List<String> fieldNames = null;
749    
750        /**
751         * Generate a list of field names.
752         *
753         * @return a list of field names
754         */
755        public static synchronized List<String> getFieldNames()
756        {
757            if (fieldNames == null)
758            {
759                fieldNames = new ArrayList<String>();
760                fieldNames.add("RoleId");
761                fieldNames.add("Name");
762                fieldNames = Collections.unmodifiableList(fieldNames);
763            }
764            return fieldNames;
765        }
766    
767        /**
768         * Retrieves a field from the object by field (Java) name passed in as a String.
769         *
770         * @param name field name
771         * @return value
772         */
773        public Object getByName(String name)
774        {
775            if (name.equals("RoleId"))
776            {
777                return new Integer(getRoleId());
778            }
779            if (name.equals("Name"))
780            {
781                return getName();
782            }
783            return null;
784        }
785    
786        /**
787         * Set a field in the object by field (Java) name.
788         *
789         * @param name field name
790         * @param value field value
791         * @return True if value was set, false if not (invalid name / protected field).
792         * @throws IllegalArgumentException if object type of value does not match field object type.
793         * @throws TorqueException If a problem occurs with the set[Field] method.
794         */
795        public boolean setByName(String name, Object value )
796            throws TorqueException, IllegalArgumentException
797        {
798            if (name.equals("RoleId"))
799            {
800                if (value == null || ! (Integer.class.isInstance(value)))
801                {
802                    throw new IllegalArgumentException("setByName: value parameter was null or not an Integer object.");
803                }
804                setRoleId(((Integer) value).intValue());
805                return true;
806            }
807            if (name.equals("Name"))
808            {
809                // Object fields can be null
810                if (value != null && ! String.class.isInstance(value))
811                {
812                    throw new IllegalArgumentException("Invalid type of object specified for value in setByName");
813                }
814                setName((String) value);
815                return true;
816            }
817            return false;
818        }
819    
820        /**
821         * Retrieves a field from the object by name passed in
822         * as a String.  The String must be one of the static
823         * Strings defined in this Class' Peer.
824         *
825         * @param name peer name
826         * @return value
827         */
828        public Object getByPeerName(String name)
829        {
830            if (name.equals(TurbineRolePeer.ROLE_ID))
831            {
832                return new Integer(getRoleId());
833            }
834            if (name.equals(TurbineRolePeer.ROLE_NAME))
835            {
836                return getName();
837            }
838            return null;
839        }
840    
841        /**
842         * Set field values by Peer Field Name
843         *
844         * @param name field name
845         * @param value field value
846         * @return True if value was set, false if not (invalid name / protected field).
847         * @throws IllegalArgumentException if object type of value does not match field object type.
848         * @throws TorqueException If a problem occurs with the set[Field] method.
849         */
850        public boolean setByPeerName(String name, Object value)
851            throws TorqueException, IllegalArgumentException
852        {
853          if (TurbineRolePeer.ROLE_ID.equals(name))
854            {
855                return setByName("RoleId", value);
856            }
857          if (TurbineRolePeer.ROLE_NAME.equals(name))
858            {
859                return setByName("Name", value);
860            }
861            return false;
862        }
863    
864        /**
865         * Retrieves a field from the object by Position as specified
866         * in the xml schema.  Zero-based.
867         *
868         * @param pos position in xml schema
869         * @return value
870         */
871        public Object getByPosition(int pos)
872        {
873            if (pos == 0)
874            {
875                return new Integer(getRoleId());
876            }
877            if (pos == 1)
878            {
879                return getName();
880            }
881            return null;
882        }
883    
884        /**
885         * Set field values by its position (zero based) in the XML schema.
886         *
887         * @param position The field position
888         * @param value field value
889         * @return True if value was set, false if not (invalid position / protected field).
890         * @throws IllegalArgumentException if object type of value does not match field object type.
891         * @throws TorqueException If a problem occurs with the set[Field] method.
892         */
893        public boolean setByPosition(int position, Object value)
894            throws TorqueException, IllegalArgumentException
895        {
896        if (position == 0)
897            {
898                return setByName("RoleId", value);
899            }
900        if (position == 1)
901            {
902                return setByName("Name", value);
903            }
904            return false;
905        }
906         
907        /**
908         * Stores the object in the database.  If the object is new,
909         * it inserts it; otherwise an update is performed.
910         *
911         * @throws Exception
912         */
913        public void save() throws Exception
914        {
915            save(TurbineRolePeer.DATABASE_NAME);
916        }
917    
918        /**
919         * Stores the object in the database.  If the object is new,
920         * it inserts it; otherwise an update is performed.
921         * Note: this code is here because the method body is
922         * auto-generated conditionally and therefore needs to be
923         * in this file instead of in the super class, BaseObject.
924         *
925         * @param dbName
926         * @throws TorqueException
927         */
928        public void save(String dbName) throws TorqueException
929        {
930            Connection con = null;
931            try
932            {
933                con = Transaction.begin(dbName);
934                save(con);
935                Transaction.commit(con);
936            }
937            catch(TorqueException e)
938            {
939                Transaction.safeRollback(con);
940                throw e;
941            }
942        }
943    
944        /** flag to prevent endless save loop, if this object is referenced
945            by another object which falls in this transaction. */
946        private boolean alreadyInSave = false;
947        /**
948         * Stores the object in the database.  If the object is new,
949         * it inserts it; otherwise an update is performed.  This method
950         * is meant to be used as part of a transaction, otherwise use
951         * the save() method and the connection details will be handled
952         * internally
953         *
954         * @param con
955         * @throws TorqueException
956         */
957        public void save(Connection con) throws TorqueException
958        {
959            if (!alreadyInSave)
960            {
961                alreadyInSave = true;
962    
963    
964    
965                // If this object has been modified, then save it to the database.
966                if (isModified())
967                {
968                    if (isNew())
969                    {
970                        TurbineRolePeer.doInsert((TurbineRole) this, con);
971                        setNew(false);
972                    }
973                    else
974                    {
975                        TurbineRolePeer.doUpdate((TurbineRole) this, con);
976                    }
977                }
978    
979    
980                if (collTurbineRolePermissions != null)
981                {
982                    for (int i = 0; i < collTurbineRolePermissions.size(); i++)
983                    {
984                        ((TurbineRolePermission) collTurbineRolePermissions.get(i)).save(con);
985                    }
986                }
987    
988                if (collTurbineUserGroupRoles != null)
989                {
990                    for (int i = 0; i < collTurbineUserGroupRoles.size(); i++)
991                    {
992                        ((TurbineUserGroupRole) collTurbineUserGroupRoles.get(i)).save(con);
993                    }
994                }
995                alreadyInSave = false;
996            }
997        }
998    
999    
1000        /**
1001         * Set the PrimaryKey using ObjectKey.
1002         *
1003         * @param key roleId ObjectKey
1004         */
1005        public void setPrimaryKey(ObjectKey key)
1006            throws TorqueException
1007        {
1008            setRoleId(((NumberKey) key).intValue());
1009        }
1010    
1011        /**
1012         * Set the PrimaryKey using a String.
1013         *
1014         * @param key
1015         */
1016        public void setPrimaryKey(String key) throws TorqueException
1017        {
1018            setRoleId(Integer.parseInt(key));
1019        }
1020    
1021    
1022        /**
1023         * returns an id that differentiates this object from others
1024         * of its class.
1025         */
1026        public ObjectKey getPrimaryKey()
1027        {
1028            return SimpleKey.keyFor(getRoleId());
1029        }
1030     
1031    
1032        /**
1033         * Makes a copy of this object.
1034         * It creates a new object filling in the simple attributes.
1035         * It then fills all the association collections and sets the
1036         * related objects to isNew=true.
1037         */
1038        public TurbineRole copy() throws TorqueException
1039        {
1040            return copy(true);
1041        }
1042    
1043        /**
1044         * Makes a copy of this object using connection.
1045         * It creates a new object filling in the simple attributes.
1046         * It then fills all the association collections and sets the
1047         * related objects to isNew=true.
1048         *
1049         * @param con the database connection to read associated objects.
1050         */
1051        public TurbineRole copy(Connection con) throws TorqueException
1052        {
1053            return copy(true, con);
1054        }
1055    
1056        /**
1057         * Makes a copy of this object.
1058         * It creates a new object filling in the simple attributes.
1059         * If the parameter deepcopy is true, it then fills all the
1060         * association collections and sets the related objects to
1061         * isNew=true.
1062         *
1063         * @param deepcopy whether to copy the associated objects.
1064         */
1065        public TurbineRole copy(boolean deepcopy) throws TorqueException
1066        {
1067            return copyInto(new TurbineRole(), deepcopy);
1068        }
1069    
1070        /**
1071         * Makes a copy of this object using connection.
1072         * It creates a new object filling in the simple attributes.
1073         * If the parameter deepcopy is true, it then fills all the
1074         * association collections and sets the related objects to
1075         * isNew=true.
1076         *
1077         * @param deepcopy whether to copy the associated objects.
1078         * @param con the database connection to read associated objects.
1079         */
1080        public TurbineRole copy(boolean deepcopy, Connection con) throws TorqueException
1081        {
1082            return copyInto(new TurbineRole(), deepcopy, con);
1083        }
1084      
1085        /**
1086         * Fills the copyObj with the contents of this object.
1087         * The associated objects are also copied and treated as new objects.
1088         *
1089         * @param copyObj the object to fill.
1090         */
1091        protected TurbineRole copyInto(TurbineRole copyObj) throws TorqueException
1092        {
1093            return copyInto(copyObj, true);
1094        }
1095    
1096      
1097        /**
1098         * Fills the copyObj with the contents of this object using connection.
1099         * The associated objects are also copied and treated as new objects.
1100         *
1101         * @param copyObj the object to fill.
1102         * @param con the database connection to read associated objects.
1103         */
1104        protected TurbineRole copyInto(TurbineRole copyObj, Connection con) throws TorqueException
1105        {
1106            return copyInto(copyObj, true, con);
1107        }
1108      
1109        /**
1110         * Fills the copyObj with the contents of this object.
1111         * If deepcopy is true, The associated objects are also copied
1112         * and treated as new objects.
1113         *
1114         * @param copyObj the object to fill.
1115         * @param deepcopy whether the associated objects should be copied.
1116         */
1117        protected TurbineRole copyInto(TurbineRole copyObj, boolean deepcopy) throws TorqueException
1118        {
1119            copyObj.setRoleId(roleId);
1120            copyObj.setName(name);
1121    
1122            copyObj.setRoleId( 0);
1123    
1124            if (deepcopy)
1125            {
1126    
1127    
1128            List<TurbineRolePermission> vTurbineRolePermissions = getTurbineRolePermissions();
1129            if (vTurbineRolePermissions != null)
1130            {
1131                for (int i = 0; i < vTurbineRolePermissions.size(); i++)
1132                {
1133                    TurbineRolePermission obj =  vTurbineRolePermissions.get(i);
1134                    copyObj.addTurbineRolePermission(obj.copy());
1135                }
1136            }
1137            else
1138            {
1139                copyObj.collTurbineRolePermissions = null;
1140            }
1141    
1142    
1143            List<TurbineUserGroupRole> vTurbineUserGroupRoles = getTurbineUserGroupRoles();
1144            if (vTurbineUserGroupRoles != null)
1145            {
1146                for (int i = 0; i < vTurbineUserGroupRoles.size(); i++)
1147                {
1148                    TurbineUserGroupRole obj =  vTurbineUserGroupRoles.get(i);
1149                    copyObj.addTurbineUserGroupRole(obj.copy());
1150                }
1151            }
1152            else
1153            {
1154                copyObj.collTurbineUserGroupRoles = null;
1155            }
1156            }
1157            return copyObj;
1158        }
1159            
1160        
1161        /**
1162         * Fills the copyObj with the contents of this object using connection.
1163         * If deepcopy is true, The associated objects are also copied
1164         * and treated as new objects.
1165         *
1166         * @param copyObj the object to fill.
1167         * @param deepcopy whether the associated objects should be copied.
1168         * @param con the database connection to read associated objects.
1169         */
1170        protected TurbineRole copyInto(TurbineRole copyObj, boolean deepcopy, Connection con) throws TorqueException
1171        {
1172            copyObj.setRoleId(roleId);
1173            copyObj.setName(name);
1174    
1175            copyObj.setRoleId( 0);
1176    
1177            if (deepcopy)
1178            {
1179    
1180    
1181            List<TurbineRolePermission> vTurbineRolePermissions = getTurbineRolePermissions(con);
1182            if (vTurbineRolePermissions != null)
1183            {
1184                for (int i = 0; i < vTurbineRolePermissions.size(); i++)
1185                {
1186                    TurbineRolePermission obj =  vTurbineRolePermissions.get(i);
1187                    copyObj.addTurbineRolePermission(obj.copy(con), con);
1188                }
1189            }
1190            else
1191            {
1192                copyObj.collTurbineRolePermissions = null;
1193            }
1194    
1195    
1196            List<TurbineUserGroupRole> vTurbineUserGroupRoles = getTurbineUserGroupRoles(con);
1197            if (vTurbineUserGroupRoles != null)
1198            {
1199                for (int i = 0; i < vTurbineUserGroupRoles.size(); i++)
1200                {
1201                    TurbineUserGroupRole obj =  vTurbineUserGroupRoles.get(i);
1202                    copyObj.addTurbineUserGroupRole(obj.copy(con), con);
1203                }
1204            }
1205            else
1206            {
1207                copyObj.collTurbineUserGroupRoles = null;
1208            }
1209            }
1210            return copyObj;
1211        }
1212        
1213        
1214    
1215        /**
1216         * returns a peer instance associated with this om.  Since Peer classes
1217         * are not to have any instance attributes, this method returns the
1218         * same instance for all member of this class. The method could therefore
1219         * be static, but this would prevent one from overriding the behavior.
1220         */
1221        public TurbineRolePeer getPeer()
1222        {
1223            return peer;
1224        }
1225    
1226        /**
1227         * Retrieves the TableMap object related to this Table data without
1228         * compiler warnings of using getPeer().getTableMap().
1229         *
1230         * @return The associated TableMap object.
1231         */
1232        public TableMap getTableMap() throws TorqueException
1233        {
1234            return TurbineRolePeer.getTableMap();
1235        }
1236    
1237    
1238        public String toString()
1239        {
1240            StringBuffer str = new StringBuffer();
1241            str.append("TurbineRole:\n");
1242            str.append("RoleId = ")
1243               .append(getRoleId())
1244               .append("\n");
1245            str.append("Name = ")
1246               .append(getName())
1247               .append("\n");
1248            return(str.toString());
1249        }
1250    }