    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 TurbineUser
    036     */
    037    public abstract class BaseTurbineUser extends BaseObject
    038    {
    039        /** Serial version */
    040        private static final long serialVersionUID = 1308842746584L;
    041
    042        /** The Peer class */
    043        private static final TurbineUserPeer peer =
    044            new TurbineUserPeer();
    045
    046
    047        /** The value for the userId field */
    048        private int userId;
    049
    050        /** The value for the userName field */
    051        private String userName;
    052
    053        /** The value for the password field */
    054        private String password;
    055
    056        /** The value for the firstName field */
    057        private String firstName;
    058
    059        /** The value for the lastName field */
    060        private String lastName;
    061
    062        /** The value for the email field */
    063        private String email;
    064
    065        /** The value for the confirmed field */
    066        private String confirmed;
    067
    068        /** The value for the modified field */
    069        private Date modified;
    070
    071        /** The value for the createDate field */
    072        private Date createDate;
    073
    074        /** The value for the lastLogin field */
    075        private Date lastLogin;
    076
    077        /** The value for the objectdata field */
    078        private byte[] objectdata;
    079
    080
    081        /**
    082         * Get the UserId
    083         *
    084         * @return int
    085         */
    086        public int getUserId()
    087        {
    088            return userId;
    089        }
    090
    091
    092        /**
    093         * Set the value of UserId
    094         *
    095         * @param v new value
    096         */
    097        public void setUserId(int v) throws TorqueException
    098        {
    099
    100            if (this.userId != v)
    101            {
    102                this.userId = v;
    103                setModified(true);
    104            }
    105
    106
    107
    108            // update associated TurbineUserGroupRole
    109            if (collTurbineUserGroupRoles != null)
    110            {
    111                for (int i = 0; i < collTurbineUserGroupRoles.size(); i++)
    112                {
    113                    ((TurbineUserGroupRole) collTurbineUserGroupRoles.get(i))
    114                            .setUserId(v);
    115                }
    116            }
    117        }
    118
    119        /**
    120         * Get the UserName
    121         *
    122         * @return String
    123         */
    124        public String getUserName()
    125        {
    126            return userName;
    127        }
    128
    129
    130        /**
    131         * Set the value of UserName
    132         *
    133         * @param v new value
    134         */
    135        public void setUserName(String v)
    136        {
    137
    138            if (!ObjectUtils.equals(this.userName, v))
    139            {
    140                this.userName = v;
    141                setModified(true);
    142            }
    143
    144
    145        }
    146
    147        /**
    148         * Get the Password
    149         *
    150         * @return String
    151         */
    152        public String getPassword()
    153        {
    154            return password;
    155        }
    156
    157
    158        /**
    159         * Set the value of Password
    160         *
    161         * @param v new value
    162         */
    163        public void setPassword(String v)
    164        {
    165
    166            if (!ObjectUtils.equals(this.password, v))
    167            {
    168                this.password = v;
    169                setModified(true);
    170            }
    171
    172
    173        }
    174
    175        /**
    176         * Get the FirstName
    177         *
    178         * @return String
    179         */
    180        public String getFirstName()
    181        {
    182            return firstName;
    183        }
    184
    185
    186        /**
    187         * Set the value of FirstName
    188         *
    189         * @param v new value
    190         */
    191        public void setFirstName(String v)
    192        {
    193
    194            if (!ObjectUtils.equals(this.firstName, v))
    195            {
    196                this.firstName = v;
    197                setModified(true);
    198            }
    199
    200
    201        }
    202
    203        /**
    204         * Get the LastName
    205         *
    206         * @return String
    207         */
    208        public String getLastName()
    209        {
    210            return lastName;
    211        }
    212
    213
    214        /**
    215         * Set the value of LastName
    216         *
    217         * @param v new value
    218         */
    219        public void setLastName(String v)
    220        {
    221
    222            if (!ObjectUtils.equals(this.lastName, v))
    223            {
    224                this.lastName = v;
    225                setModified(true);
    226            }
    227
    228
    229        }
    230
    231        /**
    232         * Get the Email
    233         *
    234         * @return String
    235         */
    236        public String getEmail()
    237        {
    238            return email;
    239        }
    240
    241
    242        /**
    243         * Set the value of Email
    244         *
    245         * @param v new value
    246         */
    247        public void setEmail(String v)
    248        {
    249
    250            if (!ObjectUtils.equals(this.email, v))
    251            {
    252                this.email = v;
    253                setModified(true);
    254            }
    255
    256
    257        }
    258
    259        /**
    260         * Get the Confirmed
    261         *
    262         * @return String
    263         */
    264        public String getConfirmed()
    265        {
    266            return confirmed;
    267        }
    268
    269
    270        /**
    271         * Set the value of Confirmed
    272         *
    273         * @param v new value
    274         */
    275        public void setConfirmed(String v)
    276        {
    277
    278            if (!ObjectUtils.equals(this.confirmed, v))
    279            {
    280                this.confirmed = v;
    281                setModified(true);
    282            }
    283
    284
    285        }
    286
    287        /**
    288         * Get the Modified
    289         *
    290         * @return Date
    291         */
    292        public Date getModified()
    293        {
    294            return modified;
    295        }
    296
    297
    298        /**
    299         * Set the value of Modified
    300         *
    301         * @param v new value
    302         */
    303        public void setModified(Date v)
    304        {
    305
    306            if (!ObjectUtils.equals(this.modified, v))
    307            {
    308                this.modified = v;
    309                setModified(true);
    310            }
    311
    312
    313        }
    314
    315        /**
    316         * Get the CreateDate
    317         *
    318         * @return Date
    319         */
    320        public Date getCreateDate()
    321        {
    322            return createDate;
    323        }
    324
    325
    326        /**
    327         * Set the value of CreateDate
    328         *
    329         * @param v new value
    330         */
    331        public void setCreateDate(Date v)
    332        {
    333
    334            if (!ObjectUtils.equals(this.createDate, v))
    335            {
    336                this.createDate = v;
    337                setModified(true);
    338            }
    339
    340
    341        }
    342
    343        /**
    344         * Get the LastLogin
    345         *
    346         * @return Date
    347         */
    348        public Date getLastLogin()
    349        {
    350            return lastLogin;
    351        }
    352
    353
    354        /**
    355         * Set the value of LastLogin
    356         *
    357         * @param v new value
    358         */
    359        public void setLastLogin(Date v)
    360        {
    361
    362            if (!ObjectUtils.equals(this.lastLogin, v))
    363            {
    364                this.lastLogin = v;
    365                setModified(true);
    366            }
    367
    368
    369        }
    370
    371        /**
    372         * Get the Objectdata
    373         *
    374         * @return byte[]
    375         */
    376        public byte[] getObjectdata()
    377        {
    378            return objectdata;
    379        }
    380
    381
    382        /**
    383         * Set the value of Objectdata
    384         *
    385         * @param v new value
    386         */
    387        public void setObjectdata(byte[] v)
    388        {
    389
    390            if (!ObjectUtils.equals(this.objectdata, v))
    391            {
    392                this.objectdata = v;
    393                setModified(true);
    394            }
    395
    396
    397        }
    398
    399
    400
    401
    402        /**
    403         * Collection to store aggregation of collTurbineUserGroupRoles
    404         */
    405        protected List<TurbineUserGroupRole> collTurbineUserGroupRoles;
    406
    407        /**
    408         * Temporary storage of collTurbineUserGroupRoles to save a possible db hit in
    409         * the event objects are add to the collection, but the
    410         * complete collection is never requested.
    411         */
    412        protected void initTurbineUserGroupRoles()
    413        {
    414            if (collTurbineUserGroupRoles == null)
    415            {
    416                collTurbineUserGroupRoles = new ArrayList<TurbineUserGroupRole>();
    417            }
    418        }
    419
    420
    421        /**
    422         * Method called to associate a TurbineUserGroupRole object to this object
    423         * through the TurbineUserGroupRole foreign key attribute
    424         *
    425         * @param l TurbineUserGroupRole
    426         * @throws TorqueException
    427         */
    428        public void addTurbineUserGroupRole(TurbineUserGroupRole l) throws TorqueException
    429        {
    430            getTurbineUserGroupRoles().add(l);
    431            l.setTurbineUser((TurbineUser) this);
    432        }
    433
    434        /**
    435         * Method called to associate a TurbineUserGroupRole object to this object
    436         * through the TurbineUserGroupRole foreign key attribute using connection.
    437         *
    438         * @param l TurbineUserGroupRole
    439         * @throws TorqueException
    440         */
    441        public void addTurbineUserGroupRole(TurbineUserGroupRole l, Connection con) throws TorqueException
    442        {
    443            getTurbineUserGroupRoles(con).add(l);
    444            l.setTurbineUser((TurbineUser) this);
    445        }
    446
    447        /**
    448         * The criteria used to select the current contents of collTurbineUserGroupRoles
    449         */
    450        private Criteria lastTurbineUserGroupRolesCriteria = null;
    451
    452        /**
    453         * If this collection has already been initialized, returns
    454         * the collection. Otherwise returns the results of
    455         * getTurbineUserGroupRoles(new Criteria())
    456         *
    457         * @return the collection of associated objects
    458         * @throws TorqueException
    459         */
    460        public List<TurbineUserGroupRole> getTurbineUserGroupRoles()
    461            throws TorqueException
    462        {
    463            if (collTurbineUserGroupRoles == null)
    464            {
    465                collTurbineUserGroupRoles = getTurbineUserGroupRoles(new Criteria(10));
    466            }
    467            return collTurbineUserGroupRoles;
    468        }
    469
    470        /**
    471         * If this collection has already been initialized with
    472         * an identical criteria, it returns the collection.
    473         * Otherwise if this TurbineUser has previously
    474         * been saved, it will retrieve related TurbineUserGroupRoles from storage.
    475         * If this TurbineUser is new, it will return
    476         * an empty collection or the current collection, the criteria
    477         * is ignored on a new object.
    478         *
    479         * @throws TorqueException
    480         */
    481        public List<TurbineUserGroupRole> getTurbineUserGroupRoles(Criteria criteria) throws TorqueException
    482        {
    483            if (collTurbineUserGroupRoles == null)
    484            {
    485                if (isNew())
    486                {
    487                   collTurbineUserGroupRoles = new ArrayList<TurbineUserGroupRole>();
    488                }
    489                else
    490                {
    491                    criteria.add(TurbineUserGroupRolePeer.USER_ID, getUserId() );
    492                    collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria);
    493                }
    494            }
    495            else
    496            {
    497                // criteria has no effect for a new object
    498                if (!isNew())
    499                {
    500                    // the following code is to determine if a new query is
    501                    // called for.  If the criteria is the same as the last
    502                    // one, just return the collection.
    503                    criteria.add(TurbineUserGroupRolePeer.USER_ID, getUserId());
    504                    if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
    505                    {
    506                        collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria);
    507                    }
    508                }
    509            }
    510            lastTurbineUserGroupRolesCriteria = criteria;
    511
    512            return collTurbineUserGroupRoles;
    513        }
    514
    515        /**
    516         * If this collection has already been initialized, returns
    517         * the collection. Otherwise returns the results of
    518         * getTurbineUserGroupRoles(new Criteria(),Connection)
    519         * This method takes in the Connection also as input so that
    520         * referenced objects can also be obtained using a Connection
    521         * that is taken as input
    522         */
    523        public List<TurbineUserGroupRole> getTurbineUserGroupRoles(Connection con) throws TorqueException
    524        {
    525            if (collTurbineUserGroupRoles == null)
    526            {
    527                collTurbineUserGroupRoles = getTurbineUserGroupRoles(new Criteria(10), con);
    528            }
    529            return collTurbineUserGroupRoles;
    530        }
    531
    532        /**
    533         * If this collection has already been initialized with
    534         * an identical criteria, it returns the collection.
    535         * Otherwise if this TurbineUser has previously
    536         * been saved, it will retrieve related TurbineUserGroupRoles from storage.
    537         * If this TurbineUser is new, it will return
    538         * an empty collection or the current collection, the criteria
    539         * is ignored on a new object.
    540         * This method takes in the Connection also as input so that
    541         * referenced objects can also be obtained using a Connection
    542         * that is taken as input
    543         */
    544        public List<TurbineUserGroupRole> getTurbineUserGroupRoles(Criteria criteria, Connection con)
    545                throws TorqueException
    546        {
    547            if (collTurbineUserGroupRoles == null)
    548            {
    549                if (isNew())
    550                {
    551                   collTurbineUserGroupRoles = new ArrayList<TurbineUserGroupRole>();
    552                }
    553                else
    554                {
    555                     criteria.add(TurbineUserGroupRolePeer.USER_ID, getUserId());
    556                     collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria, con);
    557                 }
    558             }
    559             else
    560             {
    561                 // criteria has no effect for a new object
    562                 if (!isNew())
    563                 {
    564                     // the following code is to determine if a new query is
    565                     // called for.  If the criteria is the same as the last
    566                     // one, just return the collection.
    567                     criteria.add(TurbineUserGroupRolePeer.USER_ID, getUserId());
    568                     if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
    569                     {
    570                         collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria, con);
    571                     }
    572                 }
    573             }
    574             lastTurbineUserGroupRolesCriteria = criteria;
    575
    576             return collTurbineUserGroupRoles;
    577         }
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589        /**
    590         * If this collection has already been initialized with
    591         * an identical criteria, it returns the collection.
    592         * Otherwise if this TurbineUser is new, it will return
    593         * an empty collection; or if this TurbineUser has previously
    594         * been saved, it will retrieve related TurbineUserGroupRoles from storage.
    595         *
    596         * This method is protected by default in order to keep the public
    597         * api reasonable.  You can provide public methods for those you
    598         * actually need in TurbineUser.
    599         */
    600        protected List<TurbineUserGroupRole> getTurbineUserGroupRolesJoinTurbineUser(Criteria criteria)
    601            throws TorqueException
    602        {
    603            if (collTurbineUserGroupRoles == null)
    604            {
    605                if (isNew())
    606                {
    607                   collTurbineUserGroupRoles = new ArrayList<TurbineUserGroupRole>();
    608                }
    609                else
    610                {
    611                    criteria.add(TurbineUserGroupRolePeer.USER_ID, getUserId());
    612                    collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineUser(criteria);
    613                }
    614            }
    615            else
    616            {
    617                // the following code is to determine if a new query is
    618                // called for.  If the criteria is the same as the last
    619                // one, just return the collection.
    620                criteria.add(TurbineUserGroupRolePeer.USER_ID, getUserId());
    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 TurbineUser is new, it will return
    643         * an empty collection; or if this TurbineUser 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 TurbineUser.
    649         */
    650        protected List<TurbineUserGroupRole> getTurbineUserGroupRolesJoinTurbineGroup(Criteria criteria)
    651            throws TorqueException
    652        {
    653            if (collTurbineUserGroupRoles == null)
    654            {
    655                if (isNew())
    656                {
    657                   collTurbineUserGroupRoles = new ArrayList<TurbineUserGroupRole>();
    658                }
    659                else
    660                {
    661                    criteria.add(TurbineUserGroupRolePeer.USER_ID, getUserId());
    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                criteria.add(TurbineUserGroupRolePeer.USER_ID, getUserId());
    671                if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
    672                {
    673                    collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria);
    674                }
    675            }
    676            lastTurbineUserGroupRolesCriteria = criteria;
    677
    678            return collTurbineUserGroupRoles;
    679        }
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689        /**
    690         * If this collection has already been initialized with
    691         * an identical criteria, it returns the collection.
    692         * Otherwise if this TurbineUser is new, it will return
    693         * an empty collection; or if this TurbineUser has previously
    694         * been saved, it will retrieve related TurbineUserGroupRoles from storage.
    695         *
    696         * This method is protected by default in order to keep the public
    697         * api reasonable.  You can provide public methods for those you
    698         * actually need in TurbineUser.
    699         */
    700        protected List<TurbineUserGroupRole> getTurbineUserGroupRolesJoinTurbineRole(Criteria criteria)
    701            throws TorqueException
    702        {
    703            if (collTurbineUserGroupRoles == null)
    704            {
    705                if (isNew())
    706                {
    707                   collTurbineUserGroupRoles = new ArrayList<TurbineUserGroupRole>();
    708                }
    709                else
    710                {
    711                    criteria.add(TurbineUserGroupRolePeer.USER_ID, getUserId());
    712                    collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria);
    713                }
    714            }
    715            else
    716            {
    717                // the following code is to determine if a new query is
    718                // called for.  If the criteria is the same as the last
    719                // one, just return the collection.
    720                criteria.add(TurbineUserGroupRolePeer.USER_ID, getUserId());
    721                if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
    722                {
    723                    collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria);
    724                }
    725            }
    726            lastTurbineUserGroupRolesCriteria = criteria;
    727
    728            return collTurbineUserGroupRoles;
    729        }
    730
    731
    732
    733
    734        private static List<String> fieldNames = null;
    735
    736        /**
    737         * Generate a list of field names.
    738         *
    739         * @return a list of field names
    740         */
    741        public static synchronized List<String> getFieldNames()
    742        {
    743            if (fieldNames == null)
    744            {
    745                fieldNames = new ArrayList<String>();
    746                fieldNames.add("UserId");
    747                fieldNames.add("UserName");
    748                fieldNames.add("Password");
    749                fieldNames.add("FirstName");
    750                fieldNames.add("LastName");
    751                fieldNames.add("Email");
    752                fieldNames.add("Confirmed");
    753                fieldNames.add("Modified");
    754                fieldNames.add("CreateDate");
    755                fieldNames.add("LastLogin");
    756                fieldNames.add("Objectdata");
    757                fieldNames = Collections.unmodifiableList(fieldNames);
    758            }
    759            return fieldNames;
    760        }
    761
    762        /**
    763         * Retrieves a field from the object by field (Java) name passed in as a String.
    764         *
    765         * @param name field name
    766         * @return value
    767         */
    768        public Object getByName(String name)
    769        {
    770            if (name.equals("UserId"))
    771            {
    772                return new Integer(getUserId());
    773            }
    774            if (name.equals("UserName"))
    775            {
    776                return getUserName();
    777            }
    778            if (name.equals("Password"))
    779            {
    780                return getPassword();
    781            }
    782            if (name.equals("FirstName"))
    783            {
    784                return getFirstName();
    785            }
    786            if (name.equals("LastName"))
    787            {
    788                return getLastName();
    789            }
    790            if (name.equals("Email"))
    791            {
    792                return getEmail();
    793            }
    794            if (name.equals("Confirmed"))
    795            {
    796                return getConfirmed();
    797            }
    798            if (name.equals("Modified"))
    799            {
    800                return getModified();
    801            }
    802            if (name.equals("CreateDate"))
    803            {
    804                return getCreateDate();
    805            }
    806            if (name.equals("LastLogin"))
    807            {
    808                return getLastLogin();
    809            }
    810            if (name.equals("Objectdata"))
    811            {
    812                return getObjectdata();
    813            }
    814            return null;
    815        }
    816
    817        /**
    818         * Set a field in the object by field (Java) name.
    819         *
    820         * @param name field name
    821         * @param value field value
    822         * @return True if value was set, false if not (invalid name / protected field).
    823         * @throws IllegalArgumentException if object type of value does not match field object type.
    824         * @throws TorqueException If a problem occurs with the set[Field] method.
    825         */
    826        public boolean setByName(String name, Object value )
    827            throws TorqueException, IllegalArgumentException
    828        {
    829            if (name.equals("UserId"))
    830            {
    831                if (value == null || ! (Integer.class.isInstance(value)))
    832                {
    833                    throw new IllegalArgumentException("setByName: value parameter was null or not an Integer object.");
    834                }
    835                setUserId(((Integer) value).intValue());
    836                return true;
    837            }
    838            if (name.equals("UserName"))
    839            {
    840                // Object fields can be null
    841                if (value != null && ! String.class.isInstance(value))
    842                {
    843                    throw new IllegalArgumentException("Invalid type of object specified for value in setByName");
    844                }
    845                setUserName((String) value);
    846                return true;
    847            }
    848            if (name.equals("Password"))
    849            {
    850                // Object fields can be null
    851                if (value != null && ! String.class.isInstance(value))
    852                {
    853                    throw new IllegalArgumentException("Invalid type of object specified for value in setByName");
    854                }
    855                setPassword((String) value);
    856                return true;
    857            }
    858            if (name.equals("FirstName"))
    859            {
    860                // Object fields can be null
    861                if (value != null && ! String.class.isInstance(value))
    862                {
    863                    throw new IllegalArgumentException("Invalid type of object specified for value in setByName");
    864                }
    865                setFirstName((String) value);
    866                return true;
    867            }
    868            if (name.equals("LastName"))
    869            {
    870                // Object fields can be null
    871                if (value != null && ! String.class.isInstance(value))
    872                {
    873                    throw new IllegalArgumentException("Invalid type of object specified for value in setByName");
    874                }
    875                setLastName((String) value);
    876                return true;
    877            }
    878            if (name.equals("Email"))
    879            {
    880                // Object fields can be null
    881                if (value != null && ! String.class.isInstance(value))
    882                {
    883                    throw new IllegalArgumentException("Invalid type of object specified for value in setByName");
    884                }
    885                setEmail((String) value);
    886                return true;
    887            }
    888            if (name.equals("Confirmed"))
    889            {
    890                // Object fields can be null
    891                if (value != null && ! String.class.isInstance(value))
    892                {
    893                    throw new IllegalArgumentException("Invalid type of object specified for value in setByName");
    894                }
    895                setConfirmed((String) value);
    896                return true;
    897            }
    898            if (name.equals("Modified"))
    899            {
    900                // Object fields can be null
    901                if (value != null && ! Date.class.isInstance(value))
    902                {
    903                    throw new IllegalArgumentException("Invalid type of object specified for value in setByName");
    904                }
    905                setModified((Date) value);
    906                return true;
    907            }
    908            if (name.equals("CreateDate"))
    909            {
    910                // Object fields can be null
    911                if (value != null && ! Date.class.isInstance(value))
    912                {
    913                    throw new IllegalArgumentException("Invalid type of object specified for value in setByName");
    914                }
    915                setCreateDate((Date) value);
    916                return true;
    917            }
    918            if (name.equals("LastLogin"))
    919            {
    920                // Object fields can be null
    921                if (value != null && ! Date.class.isInstance(value))
    922                {
    923                    throw new IllegalArgumentException("Invalid type of object specified for value in setByName");
    924                }
    925                setLastLogin((Date) value);
    926                return true;
    927            }
    928            if (name.equals("Objectdata"))
    929            {
    930                // Object fields can be null
    931                if (value != null && ! byte[].class.isInstance(value))
    932                {
    933                    throw new IllegalArgumentException("Invalid type of object specified for value in setByName");
    934                }
    935                setObjectdata((byte[]) value);
    936                return true;
    937            }
    938            return false;
    939        }
    940
    941        /**
    942         * Retrieves a field from the object by name passed in
    943         * as a String.  The String must be one of the static
    944         * Strings defined in this Class' Peer.
    945         *
    946         * @param name peer name
    947         * @return value
    948         */
    949        public Object getByPeerName(String name)
    950        {
    951            if (name.equals(TurbineUserPeer.USER_ID))
    952            {
    953                return new Integer(getUserId());
    954            }
    955            if (name.equals(TurbineUserPeer.LOGIN_NAME))
    956            {
    957                return getUserName();
    958            }
    959            if (name.equals(TurbineUserPeer.PASSWORD_VALUE))
    960            {
    961                return getPassword();
    962            }
    963            if (name.equals(TurbineUserPeer.FIRST_NAME))
    964            {
    965                return getFirstName();
    966            }
    967            if (name.equals(TurbineUserPeer.LAST_NAME))
    968            {
    969                return getLastName();
    970            }
    971            if (name.equals(TurbineUserPeer.EMAIL))
    972            {
    973                return getEmail();
    974            }
    975            if (name.equals(TurbineUserPeer.CONFIRM_VALUE))
    976            {
    977                return getConfirmed();
    978            }
    979            if (name.equals(TurbineUserPeer.MODIFIED))
    980            {
    981                return getModified();
    982            }
    983            if (name.equals(TurbineUserPeer.CREATED))
    984            {
    985                return getCreateDate();
    986            }
    987            if (name.equals(TurbineUserPeer.LAST_LOGIN))
    988            {
    989                return getLastLogin();
    990            }
    991            if (name.equals(TurbineUserPeer.OBJECTDATA))
    992            {
    993                return getObjectdata();
    994            }
    995            return null;
    996        }
    997
    998        /**
    999         * Set field values by Peer Field Name
    1000         *
    1001         * @param name field name
    1002         * @param value field value
    1003         * @return True if value was set, false if not (invalid name / protected field).
    1004         * @throws IllegalArgumentException if object type of value does not match field object type.
    1005         * @throws TorqueException If a problem occurs with the set[Field] method.
    1006         */
    1007        public boolean setByPeerName(String name, Object value)
    1008            throws TorqueException, IllegalArgumentException
    1009        {
    1010          if (TurbineUserPeer.USER_ID.equals(name))
    1011            {
    1012                return setByName("UserId", value);
    1013            }
    1014          if (TurbineUserPeer.LOGIN_NAME.equals(name))
    1015            {
    1016                return setByName("UserName", value);
    1017            }
    1018          if (TurbineUserPeer.PASSWORD_VALUE.equals(name))
    1019            {
    1020                return setByName("Password", value);
    1021            }
    1022          if (TurbineUserPeer.FIRST_NAME.equals(name))
    1023            {
    1024                return setByName("FirstName", value);
    1025            }
    1026          if (TurbineUserPeer.LAST_NAME.equals(name))
    1027            {
    1028                return setByName("LastName", value);
    1029            }
    1030          if (TurbineUserPeer.EMAIL.equals(name))
    1031            {
    1032                return setByName("Email", value);
    1033            }
    1034          if (TurbineUserPeer.CONFIRM_VALUE.equals(name))
    1035            {
    1036                return setByName("Confirmed", value);
    1037            }
    1038          if (TurbineUserPeer.MODIFIED.equals(name))
    1039            {
    1040                return setByName("Modified", value);
    1041            }
    1042          if (TurbineUserPeer.CREATED.equals(name))
    1043            {
    1044                return setByName("CreateDate", value);
    1045            }
    1046          if (TurbineUserPeer.LAST_LOGIN.equals(name))
    1047            {
    1048                return setByName("LastLogin", value);
    1049            }
    1050          if (TurbineUserPeer.OBJECTDATA.equals(name))
    1051            {
    1052                return setByName("Objectdata", value);
    1053            }
    1054            return false;
    1055        }
    1056
    1057        /**
    1058         * Retrieves a field from the object by Position as specified
    1059         * in the xml schema.  Zero-based.
    1060         *
    1061         * @param pos position in xml schema
    1062         * @return value
    1063         */
    1064        public Object getByPosition(int pos)
    1065        {
    1066            if (pos == 0)
    1067            {
    1068                return new Integer(getUserId());
    1069            }
    1070            if (pos == 1)
    1071            {
    1072                return getUserName();
    1073            }
    1074            if (pos == 2)
    1075            {
    1076                return getPassword();
    1077            }
    1078            if (pos == 3)
    1079            {
    1080                return getFirstName();
    1081            }
    1082            if (pos == 4)
    1083            {
    1084                return getLastName();
    1085            }
    1086            if (pos == 5)
    1087            {
    1088                return getEmail();
    1089            }
    1090            if (pos == 6)
    1091            {
    1092                return getConfirmed();
    1093            }
    1094            if (pos == 7)
    1095            {
    1096                return getModified();
    1097            }
    1098            if (pos == 8)
    1099            {
    1100                return getCreateDate();
    1101            }
    1102            if (pos == 9)
    1103            {
    1104                return getLastLogin();
    1105            }
    1106            if (pos == 10)
    1107            {
    1108                return getObjectdata();
    1109            }
    1110            return null;
    1111        }
    1112
    1113        /**
    1114         * Set field values by its position (zero based) in the XML schema.
    1115         *
    1116         * @param position The field position
    1117         * @param value field value
    1118         * @return True if value was set, false if not (invalid position / protected field).
    1119         * @throws IllegalArgumentException if object type of value does not match field object type.
    1120         * @throws TorqueException If a problem occurs with the set[Field] method.
    1121         */
    1122        public boolean setByPosition(int position, Object value)
    1123            throws TorqueException, IllegalArgumentException
    1124        {
    1125        if (position == 0)
    1126            {
    1127                return setByName("UserId", value);
    1128            }
    1129        if (position == 1)
    1130            {
    1131                return setByName("UserName", value);
    1132            }
    1133        if (position == 2)
    1134            {
    1135                return setByName("Password", value);
    1136            }
    1137        if (position == 3)
    1138            {
    1139                return setByName("FirstName", value);
    1140            }
    1141        if (position == 4)
    1142            {
    1143                return setByName("LastName", value);
    1144            }
    1145        if (position == 5)
    1146            {
    1147                return setByName("Email", value);
    1148            }
    1149        if (position == 6)
    1150            {
    1151                return setByName("Confirmed", value);
    1152            }
    1153        if (position == 7)
    1154            {
    1155                return setByName("Modified", value);
    1156            }
    1157        if (position == 8)
    1158            {
    1159                return setByName("CreateDate", value);
    1160            }
    1161        if (position == 9)
    1162            {
    1163                return setByName("LastLogin", value);
    1164            }
    1165        if (position == 10)
    1166            {
    1167                return setByName("Objectdata", value);
    1168            }
    1169            return false;
    1170        }
    1171
    1172        /**
    1173         * Stores the object in the database.  If the object is new,
    1174         * it inserts it; otherwise an update is performed.
    1175         *
    1176         * @throws Exception
    1177         */
    1178        public void save() throws Exception
    1179        {
    1180            save(TurbineUserPeer.DATABASE_NAME);
    1181        }
    1182
    1183        /**
    1184         * Stores the object in the database.  If the object is new,
    1185         * it inserts it; otherwise an update is performed.
    1186         * Note: this code is here because the method body is
    1187         * auto-generated conditionally and therefore needs to be
    1188         * in this file instead of in the super class, BaseObject.
    1189         *
    1190         * @param dbName
    1191         * @throws TorqueException
    1192         */
    1193        public void save(String dbName) throws TorqueException
    1194        {
    1195            Connection con = null;
    1196            try
    1197            {
    1198                con = Transaction.begin(dbName);
    1199                save(con);
    1200                Transaction.commit(con);
    1201            }
    1202            catch(TorqueException e)
    1203            {
    1204                Transaction.safeRollback(con);
    1205                throw e;
    1206            }
    1207        }
    1208
    1209        /** flag to prevent endless save loop, if this object is referenced
    1210            by another object which falls in this transaction. */
    1211        private boolean alreadyInSave = false;
    1212        /**
    1213         * Stores the object in the database.  If the object is new,
    1214         * it inserts it; otherwise an update is performed.  This method
    1215         * is meant to be used as part of a transaction, otherwise use
    1216         * the save() method and the connection details will be handled
    1217         * internally
    1218         *
    1219         * @param con
    1220         * @throws TorqueException
    1221         */
    1222        public void save(Connection con) throws TorqueException
    1223        {
    1224            if (!alreadyInSave)
    1225            {
    1226                alreadyInSave = true;
    1227
    1228
    1229
    1230                // If this object has been modified, then save it to the database.
    1231                if (isModified())
    1232                {
    1233                    if (isNew())
    1234                    {
    1235                        TurbineUserPeer.doInsert((TurbineUser) this, con);
    1236                        setNew(false);
    1237                    }
    1238                    else
    1239                    {
    1240                        TurbineUserPeer.doUpdate((TurbineUser) this, con);
    1241                    }
    1242                }
    1243
    1244
    1245                if (collTurbineUserGroupRoles != null)
    1246                {
    1247                    for (int i = 0; i < collTurbineUserGroupRoles.size(); i++)
    1248                    {
    1249                        ((TurbineUserGroupRole) collTurbineUserGroupRoles.get(i)).save(con);
    1250                    }
    1251                }
    1252                alreadyInSave = false;
    1253            }
    1254        }
    1255
    1256
    1257        /**
    1258         * Set the PrimaryKey using ObjectKey.
    1259         *
    1260         * @param key userId ObjectKey
    1261         */
    1262        public void setPrimaryKey(ObjectKey key)
    1263            throws TorqueException
    1264        {
    1265            setUserId(((NumberKey) key).intValue());
    1266        }
    1267
    1268        /**
    1269         * Set the PrimaryKey using a String.
    1270         *
    1271         * @param key
    1272         */
    1273        public void setPrimaryKey(String key) throws TorqueException
    1274        {
    1275            setUserId(Integer.parseInt(key));
    1276        }
    1277
    1278
    1279        /**
    1280         * returns an id that differentiates this object from others
    1281         * of its class.
    1282         */
    1283        public ObjectKey getPrimaryKey()
    1284        {
    1285            return SimpleKey.keyFor(getUserId());
    1286        }
    1287
    1288
    1289        /**
    1290         * Makes a copy of this object.
    1291         * It creates a new object filling in the simple attributes.
    1292         * It then fills all the association collections and sets the
    1293         * related objects to isNew=true.
    1294         */
    1295        public TurbineUser copy() throws TorqueException
    1296        {
    1297            return copy(true);
    1298        }
    1299
    1300        /**
    1301         * Makes a copy of this object using connection.
    1302         * It creates a new object filling in the simple attributes.
    1303         * It then fills all the association collections and sets the
    1304         * related objects to isNew=true.
    1305         *
    1306         * @param con the database connection to read associated objects.
    1307         */
    1308        public TurbineUser copy(Connection con) throws TorqueException
    1309        {
    1310            return copy(true, con);
    1311        }
    1312
    1313        /**
    1314         * Makes a copy of this object.
    1315         * It creates a new object filling in the simple attributes.
    1316         * If the parameter deepcopy is true, it then fills all the
    1317         * association collections and sets the related objects to
    1318         * isNew=true.
    1319         *
    1320         * @param deepcopy whether to copy the associated objects.
    1321         */
    1322        public TurbineUser copy(boolean deepcopy) throws TorqueException
    1323        {
    1324            return copyInto(new TurbineUser(), deepcopy);
    1325        }
    1326
    1327        /**
    1328         * Makes a copy of this object using connection.
    1329         * It creates a new object filling in the simple attributes.
    1330         * If the parameter deepcopy is true, it then fills all the
    1331         * association collections and sets the related objects to
    1332         * isNew=true.
    1333         *
    1334         * @param deepcopy whether to copy the associated objects.
    1335         * @param con the database connection to read associated objects.
    1336         */
    1337        public TurbineUser copy(boolean deepcopy, Connection con) throws TorqueException
    1338        {
    1339            return copyInto(new TurbineUser(), deepcopy, con);
    1340        }
    1341
    1342        /**
    1343         * Fills the copyObj with the contents of this object.
    1344         * The associated objects are also copied and treated as new objects.
    1345         *
    1346         * @param copyObj the object to fill.
    1347         */
    1348        protected TurbineUser copyInto(TurbineUser copyObj) throws TorqueException
    1349        {
    1350            return copyInto(copyObj, true);
    1351        }
    1352
    1353
    1354        /**
    1355         * Fills the copyObj with the contents of this object using connection.
    1356         * The associated objects are also copied and treated as new objects.
    1357         *
    1358         * @param copyObj the object to fill.
    1359         * @param con the database connection to read associated objects.
    1360         */
    1361        protected TurbineUser copyInto(TurbineUser copyObj, Connection con) throws TorqueException
    1362        {
    1363            return copyInto(copyObj, true, con);
    1364        }
    1365
    1366        /**
    1367         * Fills the copyObj with the contents of this object.
    1368         * If deepcopy is true, The associated objects are also copied
    1369         * and treated as new objects.
    1370         *
    1371         * @param copyObj the object to fill.
    1372         * @param deepcopy whether the associated objects should be copied.
    1373         */
    1374        protected TurbineUser copyInto(TurbineUser copyObj, boolean deepcopy) throws TorqueException
    1375        {
    1376            copyObj.setUserId(userId);
    1377            copyObj.setUserName(userName);
    1378            copyObj.setPassword(password);
    1379            copyObj.setFirstName(firstName);
    1380            copyObj.setLastName(lastName);
    1381            copyObj.setEmail(email);
    1382            copyObj.setConfirmed(confirmed);
    1383            copyObj.setModified(modified);
    1384            copyObj.setCreateDate(createDate);
    1385            copyObj.setLastLogin(lastLogin);
    1386            copyObj.setObjectdata(objectdata);
    1387
    1388            copyObj.setUserId( 0);
    1389
    1390            if (deepcopy)
    1391            {
    1392
    1393
    1394            List<TurbineUserGroupRole> vTurbineUserGroupRoles = getTurbineUserGroupRoles();
    1395            if (vTurbineUserGroupRoles != null)
    1396            {
    1397                for (int i = 0; i < vTurbineUserGroupRoles.size(); i++)
    1398                {
    1399                    TurbineUserGroupRole obj =  vTurbineUserGroupRoles.get(i);
    1400                    copyObj.addTurbineUserGroupRole(obj.copy());
    1401                }
    1402            }
    1403            else
    1404            {
    1405                copyObj.collTurbineUserGroupRoles = null;
    1406            }
    1407            }
    1408            return copyObj;
    1409        }
    1410
    1411
    1412        /**
    1413         * Fills the copyObj with the contents of this object using connection.
    1414         * If deepcopy is true, The associated objects are also copied
    1415         * and treated as new objects.
    1416         *
    1417         * @param copyObj the object to fill.
    1418         * @param deepcopy whether the associated objects should be copied.
    1419         * @param con the database connection to read associated objects.
    1420         */
    1421        protected TurbineUser copyInto(TurbineUser copyObj, boolean deepcopy, Connection con) throws TorqueException
    1422        {
    1423            copyObj.setUserId(userId);
    1424            copyObj.setUserName(userName);
    1425            copyObj.setPassword(password);
    1426            copyObj.setFirstName(firstName);
    1427            copyObj.setLastName(lastName);
    1428            copyObj.setEmail(email);
    1429            copyObj.setConfirmed(confirmed);
    1430            copyObj.setModified(modified);
    1431            copyObj.setCreateDate(createDate);
    1432            copyObj.setLastLogin(lastLogin);
    1433            copyObj.setObjectdata(objectdata);
    1434
    1435            copyObj.setUserId( 0);
    1436
    1437            if (deepcopy)
    1438            {
    1439
    1440
    1441            List<TurbineUserGroupRole> vTurbineUserGroupRoles = getTurbineUserGroupRoles(con);
    1442            if (vTurbineUserGroupRoles != null)
    1443            {
    1444                for (int i = 0; i < vTurbineUserGroupRoles.size(); i++)
    1445                {
    1446                    TurbineUserGroupRole obj =  vTurbineUserGroupRoles.get(i);
    1447                    copyObj.addTurbineUserGroupRole(obj.copy(con), con);
    1448                }
    1449            }
    1450            else
    1451            {
    1452                copyObj.collTurbineUserGroupRoles = null;
    1453            }
    1454            }
    1455            return copyObj;
    1456        }
    1457
    1458
    1459
    1460        /**
    1461         * returns a peer instance associated with this om.  Since Peer classes
    1462         * are not to have any instance attributes, this method returns the
    1463         * same instance for all member of this class. The method could therefore
    1464         * be static, but this would prevent one from overriding the behavior.
    1465         */
    1466        public TurbineUserPeer getPeer()
    1467        {
    1468            return peer;
    1469        }
    1470
    1471        /**
    1472         * Retrieves the TableMap object related to this Table data without
    1473         * compiler warnings of using getPeer().getTableMap().
    1474         *
    1475         * @return The associated TableMap object.
    1476         */
    1477        public TableMap getTableMap() throws TorqueException
    1478        {
    1479            return TurbineUserPeer.getTableMap();
    1480        }
    1481
    1482
    1483        public String toString()
    1484        {
    1485            StringBuffer str = new StringBuffer();
    1486            str.append("TurbineUser:\n");
    1487            str.append("UserId = ")
    1488               .append(getUserId())
    1489               .append("\n");
    1490            str.append("UserName = ")
    1491               .append(getUserName())
    1492               .append("\n");
    1493            str.append("Password = ")
    1494               .append(getPassword())
    1495               .append("\n");
    1496            str.append("FirstName = ")
    1497               .append(getFirstName())
    1498               .append("\n");
    1499            str.append("LastName = ")
    1500               .append(getLastName())
    1501               .append("\n");
    1502            str.append("Email = ")
    1503               .append(getEmail())
    1504               .append("\n");
    1505            str.append("Confirmed = ")
    1506               .append(getConfirmed())
    1507               .append("\n");
    1508            str.append("Modified = ")
    1509               .append(getModified())
    1510               .append("\n");
    1511            str.append("CreateDate = ")
    1512               .append(getCreateDate())
    1513               .append("\n");
    1514            str.append("LastLogin = ")
    1515               .append(getLastLogin())
    1516               .append("\n");
    1517            str.append("Objectdata = ")
    1518               .append("<binary>")
    1519               .append("\n");
    1520            return(str.toString());
    1521        }
    1522    }