package org.thdl.roster.om;


import java.math.BigDecimal;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Date;
import java.util.Collections;
import java.util.List;

import org.apache.commons.lang.ObjectUtils;
import org.apache.torque.TorqueException;
import org.apache.torque.om.BaseObject;
import org.apache.torque.om.ComboKey;
import org.apache.torque.om.DateKey;
import org.apache.torque.om.NumberKey;
import org.apache.torque.om.ObjectKey;
import org.apache.torque.om.SimpleKey;
import org.apache.torque.om.StringKey;
import org.apache.torque.om.Persistent;
import org.apache.torque.util.Criteria;
import org.apache.torque.util.Transaction;


/**
 * This class was autogenerated by Torque on:
 *
 * [Wed May 14 19:01:42 EDT 2003]
 *
 * You should not use this class directly.  It should not even be
 * extended all references should be to PersonData
 */
public abstract class BasePersonData extends BaseObject
{
    /** The Peer class */
    private static final PersonDataPeer peer =
        new PersonDataPeer();

                  
        /**
         * The value for the id field
         */
        private Integer id;
              
        /**
         * The value for the thdl_user_id field
         */
        private Integer thdl_user_id;
              
        /**
         * The value for the firstname field
         */
        private String firstname;
              
        /**
         * The value for the middlename field
         */
        private String middlename;
              
        /**
         * The value for the lastname field
         */
        private String lastname;
              
        /**
         * The value for the bio field
         */
        private String bio;
              
        /**
         * The value for the history field
         */
        private String history;
              
        /**
         * The value for the parent_organization field
         */
        private String parent_organization;
              
        /**
         * The value for the school field
         */
        private String school;
              
        /**
         * The value for the department field
         */
        private String department;
              
        /**
         * The value for the program field
         */
        private String program;
              
        /**
         * The value for the advisor field
         */
        private String advisor;
              
        /**
         * The value for the highest_degree field
         */
        private String highest_degree;
              
        /**
         * The value for the year_began field
         */
        private Integer year_began;
              
        /**
         * The value for the year_finished field
         */
        private Integer year_finished;
              
        /**
         * The value for the other_backgrounds field
         */
        private String other_backgrounds;
              
        /**
         * The value for the organization field
         */
        private String organization;
              
        /**
         * The value for the division field
         */
        private String division;
              
        /**
         * The value for the title field
         */
        private String title;
              
        /**
         * The value for the start_date field
         */
        private Integer start_date;
              
        /**
         * The value for the job_description field
         */
        private String job_description;
      
      
        /**
         * Get the Id
         *
         * @return Integer
         */
        public Integer getId()
        {
            return id;
        }

                                                                              
        /**
         * Set the value of Id
         *
         * @param v new value
         */
        public void setId(Integer v) throws TorqueException
        {
          


         if (!ObjectUtils.equals(this.id, v))
        {
             this.id = v;
            setModified(true);
        }

                  
                                                  
              // update associated Member
              if (collMembers != null)
              {
                  for (int i = 0; i < collMembers.size(); i++)
                  {
                      ((Member) collMembers.get(i))
                          .setPersonDataId(v);
                  }
              }
                                                              
              // update associated PersonPersonType
              if (collPersonPersonTypes != null)
              {
                  for (int i = 0; i < collPersonPersonTypes.size(); i++)
                  {
                      ((PersonPersonType) collPersonPersonTypes.get(i))
                          .setPersonDataId(v);
                  }
              }
                                   }


        /**
         * Get the ThdlUserId
         *
         * @return Integer
         */
        public Integer getThdlUserId()
        {
            return thdl_user_id;
        }

                                            
        /**
         * Set the value of ThdlUserId
         *
         * @param v new value
         */
        public void setThdlUserId(Integer v) 
        {
          


         if (!ObjectUtils.equals(this.thdl_user_id, v))
        {
             this.thdl_user_id = v;
            setModified(true);
        }

                  
                       }


        /**
         * Get the Firstname
         *
         * @return String
         */
        public String getFirstname()
        {
            return firstname;
        }

                                            
        /**
         * Set the value of Firstname
         *
         * @param v new value
         */
        public void setFirstname(String v) 
        {
          


         if (!ObjectUtils.equals(this.firstname, v))
        {
             this.firstname = v;
            setModified(true);
        }

                  
                       }


        /**
         * Get the Middlename
         *
         * @return String
         */
        public String getMiddlename()
        {
            return middlename;
        }

                                            
        /**
         * Set the value of Middlename
         *
         * @param v new value
         */
        public void setMiddlename(String v) 
        {
          


         if (!ObjectUtils.equals(this.middlename, v))
        {
             this.middlename = v;
            setModified(true);
        }

                  
                       }


        /**
         * Get the Lastname
         *
         * @return String
         */
        public String getLastname()
        {
            return lastname;
        }

                                            
        /**
         * Set the value of Lastname
         *
         * @param v new value
         */
        public void setLastname(String v) 
        {
          


         if (!ObjectUtils.equals(this.lastname, v))
        {
             this.lastname = v;
            setModified(true);
        }

                  
                       }


        /**
         * Get the Bio
         *
         * @return String
         */
        public String getBio()
        {
            return bio;
        }

                                            
        /**
         * Set the value of Bio
         *
         * @param v new value
         */
        public void setBio(String v) 
        {
          


         if (!ObjectUtils.equals(this.bio, v))
        {
             this.bio = v;
            setModified(true);
        }

                  
                       }


        /**
         * Get the History
         *
         * @return String
         */
        public String getHistory()
        {
            return history;
        }

                                            
        /**
         * Set the value of History
         *
         * @param v new value
         */
        public void setHistory(String v) 
        {
          


         if (!ObjectUtils.equals(this.history, v))
        {
             this.history = v;
            setModified(true);
        }

                  
                       }


        /**
         * Get the ParentOrganization
         *
         * @return String
         */
        public String getParentOrganization()
        {
            return parent_organization;
        }

                                            
        /**
         * Set the value of ParentOrganization
         *
         * @param v new value
         */
        public void setParentOrganization(String v) 
        {
          


         if (!ObjectUtils.equals(this.parent_organization, v))
        {
             this.parent_organization = v;
            setModified(true);
        }

                  
                       }


        /**
         * Get the School
         *
         * @return String
         */
        public String getSchool()
        {
            return school;
        }

                                            
        /**
         * Set the value of School
         *
         * @param v new value
         */
        public void setSchool(String v) 
        {
          


         if (!ObjectUtils.equals(this.school, v))
        {
             this.school = v;
            setModified(true);
        }

                  
                       }


        /**
         * Get the Department
         *
         * @return String
         */
        public String getDepartment()
        {
            return department;
        }

                                            
        /**
         * Set the value of Department
         *
         * @param v new value
         */
        public void setDepartment(String v) 
        {
          


         if (!ObjectUtils.equals(this.department, v))
        {
             this.department = v;
            setModified(true);
        }

                  
                       }


        /**
         * Get the Program
         *
         * @return String
         */
        public String getProgram()
        {
            return program;
        }

                                            
        /**
         * Set the value of Program
         *
         * @param v new value
         */
        public void setProgram(String v) 
        {
          


         if (!ObjectUtils.equals(this.program, v))
        {
             this.program = v;
            setModified(true);
        }

                  
                       }


        /**
         * Get the Advisor
         *
         * @return String
         */
        public String getAdvisor()
        {
            return advisor;
        }

                                            
        /**
         * Set the value of Advisor
         *
         * @param v new value
         */
        public void setAdvisor(String v) 
        {
          


         if (!ObjectUtils.equals(this.advisor, v))
        {
             this.advisor = v;
            setModified(true);
        }

                  
                       }


        /**
         * Get the HighestDegree
         *
         * @return String
         */
        public String getHighestDegree()
        {
            return highest_degree;
        }

                                            
        /**
         * Set the value of HighestDegree
         *
         * @param v new value
         */
        public void setHighestDegree(String v) 
        {
          


         if (!ObjectUtils.equals(this.highest_degree, v))
        {
             this.highest_degree = v;
            setModified(true);
        }

                  
                       }


        /**
         * Get the YearBegan
         *
         * @return Integer
         */
        public Integer getYearBegan()
        {
            return year_began;
        }

                                            
        /**
         * Set the value of YearBegan
         *
         * @param v new value
         */
        public void setYearBegan(Integer v) 
        {
          


         if (!ObjectUtils.equals(this.year_began, v))
        {
             this.year_began = v;
            setModified(true);
        }

                  
                       }


        /**
         * Get the YearFinished
         *
         * @return Integer
         */
        public Integer getYearFinished()
        {
            return year_finished;
        }

                                            
        /**
         * Set the value of YearFinished
         *
         * @param v new value
         */
        public void setYearFinished(Integer v) 
        {
          


         if (!ObjectUtils.equals(this.year_finished, v))
        {
             this.year_finished = v;
            setModified(true);
        }

                  
                       }


        /**
         * Get the OtherBackgrounds
         *
         * @return String
         */
        public String getOtherBackgrounds()
        {
            return other_backgrounds;
        }

                                            
        /**
         * Set the value of OtherBackgrounds
         *
         * @param v new value
         */
        public void setOtherBackgrounds(String v) 
        {
          


         if (!ObjectUtils.equals(this.other_backgrounds, v))
        {
             this.other_backgrounds = v;
            setModified(true);
        }

                  
                       }


        /**
         * Get the Organization
         *
         * @return String
         */
        public String getOrganization()
        {
            return organization;
        }

                                            
        /**
         * Set the value of Organization
         *
         * @param v new value
         */
        public void setOrganization(String v) 
        {
          


         if (!ObjectUtils.equals(this.organization, v))
        {
             this.organization = v;
            setModified(true);
        }

                  
                       }


        /**
         * Get the Division
         *
         * @return String
         */
        public String getDivision()
        {
            return division;
        }

                                            
        /**
         * Set the value of Division
         *
         * @param v new value
         */
        public void setDivision(String v) 
        {
          


         if (!ObjectUtils.equals(this.division, v))
        {
             this.division = v;
            setModified(true);
        }

                  
                       }


        /**
         * Get the Title
         *
         * @return String
         */
        public String getTitle()
        {
            return title;
        }

                                            
        /**
         * Set the value of Title
         *
         * @param v new value
         */
        public void setTitle(String v) 
        {
          


         if (!ObjectUtils.equals(this.title, v))
        {
             this.title = v;
            setModified(true);
        }

                  
                       }


        /**
         * Get the StartDate
         *
         * @return Integer
         */
        public Integer getStartDate()
        {
            return start_date;
        }

                                            
        /**
         * Set the value of StartDate
         *
         * @param v new value
         */
        public void setStartDate(Integer v) 
        {
          


         if (!ObjectUtils.equals(this.start_date, v))
        {
             this.start_date = v;
            setModified(true);
        }

                  
                       }


        /**
         * Get the JobDescription
         *
         * @return String
         */
        public String getJobDescription()
        {
            return job_description;
        }

                                            
        /**
         * Set the value of JobDescription
         *
         * @param v new value
         */
        public void setJobDescription(String v) 
        {
          


         if (!ObjectUtils.equals(this.job_description, v))
        {
             this.job_description = v;
            setModified(true);
        }

                  
                       }


 
        
                
      
    /**
     * Collection to store aggregation of collMembers
     */
    protected List collMembers;

    /**
     * Temporary storage of collMembers to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initMembers()
    {
        if (collMembers == null)
        {
            collMembers = new ArrayList();
        }
    }

    /**
     * Method called to associate a Member object to this object
     * through the Member foreign key attribute
     *
     * @param l Member
     * @throws TorqueException
     */
    public void addMember(Member l) throws TorqueException
    {
        getMembers().add(l);
        l.setPersonData((PersonData) this);
    }

    /**
     * The criteria used to select the current contents of collMembers
     */
    private Criteria lastMembersCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getMembers(new Criteria())
     *
     * @throws TorqueException
     */
    public List getMembers() throws TorqueException
    {
        if (collMembers == null)
        {
            collMembers = getMembers(new Criteria(10));
        }
        return collMembers;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this PersonData has previously
     * been saved, it will retrieve related Members from storage.
     * If this PersonData is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getMembers(Criteria criteria) throws TorqueException
    {
        if (collMembers == null)
        {
            if (isNew())
            {
               collMembers = new ArrayList();
            }
            else
            {
                   criteria.add(MemberPeer.PERSON_DATA_ID, getId() );
                   collMembers = MemberPeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                   criteria.add(MemberPeer.PERSON_DATA_ID, getId());
                   if (!lastMembersCriteria.equals(criteria))
                {
                    collMembers = MemberPeer.doSelect(criteria);
                }
            }
        }
        lastMembersCriteria = criteria;

        return collMembers;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getMembers(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getMembers(Connection con) throws TorqueException
    {
        if (collMembers == null)
        {
            collMembers = getMembers(new Criteria(10), con);
        }
        return collMembers;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this PersonData has previously
     * been saved, it will retrieve related Members from storage.
     * If this PersonData is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getMembers(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collMembers == null)
        {
            if (isNew())
            {
               collMembers = new ArrayList();
            }
            else
            {
                     criteria.add(MemberPeer.PERSON_DATA_ID, getId());
                     collMembers = MemberPeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                     criteria.add(MemberPeer.PERSON_DATA_ID, getId());
                     if (!lastMembersCriteria.equals(criteria))
                 {
                     collMembers = MemberPeer.doSelect(criteria, con);
                 }
             }
         }
         lastMembersCriteria = criteria;

         return collMembers;
     }

        

     
      
      
          
                    
                
        
        
    
      
      
          
                    
                
        
        
    
      
      
          
                    
                
        
        
    
      
         
          
                    
                
        
        
    
      
      
          
                    
                
        
        
    
      
      
          
                    
                
        
        
      



             
      
    /**
     * Collection to store aggregation of collPersonPersonTypes
     */
    protected List collPersonPersonTypes;

    /**
     * Temporary storage of collPersonPersonTypes to save a possible db hit in
     * the event objects are add to the collection, but the
     * complete collection is never requested.
     */
    protected void initPersonPersonTypes()
    {
        if (collPersonPersonTypes == null)
        {
            collPersonPersonTypes = new ArrayList();
        }
    }

    /**
     * Method called to associate a PersonPersonType object to this object
     * through the PersonPersonType foreign key attribute
     *
     * @param l PersonPersonType
     * @throws TorqueException
     */
    public void addPersonPersonType(PersonPersonType l) throws TorqueException
    {
        getPersonPersonTypes().add(l);
        l.setPersonData((PersonData) this);
    }

    /**
     * The criteria used to select the current contents of collPersonPersonTypes
     */
    private Criteria lastPersonPersonTypesCriteria = null;

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getPersonPersonTypes(new Criteria())
     *
     * @throws TorqueException
     */
    public List getPersonPersonTypes() throws TorqueException
    {
        if (collPersonPersonTypes == null)
        {
            collPersonPersonTypes = getPersonPersonTypes(new Criteria(10));
        }
        return collPersonPersonTypes;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this PersonData has previously
     * been saved, it will retrieve related PersonPersonTypes from storage.
     * If this PersonData is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     *
     * @throws TorqueException
     */
    public List getPersonPersonTypes(Criteria criteria) throws TorqueException
    {
        if (collPersonPersonTypes == null)
        {
            if (isNew())
            {
               collPersonPersonTypes = new ArrayList();
            }
            else
            {
                   criteria.add(PersonPersonTypePeer.PERSON_DATA_ID, getId() );
                   collPersonPersonTypes = PersonPersonTypePeer.doSelect(criteria);
            }
        }
        else
        {
            // criteria has no effect for a new object
            if (!isNew())
            {
                // the following code is to determine if a new query is
                // called for.  If the criteria is the same as the last
                // one, just return the collection.
                   criteria.add(PersonPersonTypePeer.PERSON_DATA_ID, getId());
                   if (!lastPersonPersonTypesCriteria.equals(criteria))
                {
                    collPersonPersonTypes = PersonPersonTypePeer.doSelect(criteria);
                }
            }
        }
        lastPersonPersonTypesCriteria = criteria;

        return collPersonPersonTypes;
    }

    /**
     * If this collection has already been initialized, returns
     * the collection. Otherwise returns the results of
     * getPersonPersonTypes(new Criteria(),Connection)
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getPersonPersonTypes(Connection con) throws TorqueException
    {
        if (collPersonPersonTypes == null)
        {
            collPersonPersonTypes = getPersonPersonTypes(new Criteria(10), con);
        }
        return collPersonPersonTypes;
    }

    /**
     * If this collection has already been initialized with
     * an identical criteria, it returns the collection.
     * Otherwise if this PersonData has previously
     * been saved, it will retrieve related PersonPersonTypes from storage.
     * If this PersonData is new, it will return
     * an empty collection or the current collection, the criteria
     * is ignored on a new object.
     * This method takes in the Connection also as input so that
     * referenced objects can also be obtained using a Connection
     * that is taken as input
     */
    public List getPersonPersonTypes(Criteria criteria, Connection con)
            throws TorqueException
    {
        if (collPersonPersonTypes == null)
        {
            if (isNew())
            {
               collPersonPersonTypes = new ArrayList();
            }
            else
            {
                     criteria.add(PersonPersonTypePeer.PERSON_DATA_ID, getId());
                     collPersonPersonTypes = PersonPersonTypePeer.doSelect(criteria, con);
             }
         }
         else
         {
             // criteria has no effect for a new object
             if (!isNew())
             {
                 // the following code is to determine if a new query is
                 // called for.  If the criteria is the same as the last
                 // one, just return the collection.
                     criteria.add(PersonPersonTypePeer.PERSON_DATA_ID, getId());
                     if (!lastPersonPersonTypesCriteria.equals(criteria))
                 {
                     collPersonPersonTypes = PersonPersonTypePeer.doSelect(criteria, con);
                 }
             }
         }
         lastPersonPersonTypesCriteria = criteria;

         return collPersonPersonTypes;
     }

    

     
      
         
          
                    
                
        
        
    
      
      
          
                    
                
        
        
      



     
    
    private static List fieldNames = null;

    /**
     * Generate a list of field names.
     *
     * @return a list of field names
     */
    public static synchronized List getFieldNames()
    {
      if (fieldNames == null)
      {
        fieldNames = new ArrayList();
            fieldNames.add("Id");
            fieldNames.add("ThdlUserId");
            fieldNames.add("Firstname");
            fieldNames.add("Middlename");
            fieldNames.add("Lastname");
            fieldNames.add("Bio");
            fieldNames.add("History");
            fieldNames.add("ParentOrganization");
            fieldNames.add("School");
            fieldNames.add("Department");
            fieldNames.add("Program");
            fieldNames.add("Advisor");
            fieldNames.add("HighestDegree");
            fieldNames.add("YearBegan");
            fieldNames.add("YearFinished");
            fieldNames.add("OtherBackgrounds");
            fieldNames.add("Organization");
            fieldNames.add("Division");
            fieldNames.add("Title");
            fieldNames.add("StartDate");
            fieldNames.add("JobDescription");
            fieldNames = Collections.unmodifiableList(fieldNames);
      }
      return fieldNames;
    }

    /**
     * Retrieves a field from the object by name passed in as a String.
     *
     * @param name field name
     * @return value
     */
    public Object getByName(String name)
    {
            if (name.equals("Id"))
    {
              return getId();
          }
            if (name.equals("ThdlUserId"))
    {
              return getThdlUserId();
          }
            if (name.equals("Firstname"))
    {
              return getFirstname();
          }
            if (name.equals("Middlename"))
    {
              return getMiddlename();
          }
            if (name.equals("Lastname"))
    {
              return getLastname();
          }
            if (name.equals("Bio"))
    {
              return getBio();
          }
            if (name.equals("History"))
    {
              return getHistory();
          }
            if (name.equals("ParentOrganization"))
    {
              return getParentOrganization();
          }
            if (name.equals("School"))
    {
              return getSchool();
          }
            if (name.equals("Department"))
    {
              return getDepartment();
          }
            if (name.equals("Program"))
    {
              return getProgram();
          }
            if (name.equals("Advisor"))
    {
              return getAdvisor();
          }
            if (name.equals("HighestDegree"))
    {
              return getHighestDegree();
          }
            if (name.equals("YearBegan"))
    {
              return getYearBegan();
          }
            if (name.equals("YearFinished"))
    {
              return getYearFinished();
          }
            if (name.equals("OtherBackgrounds"))
    {
              return getOtherBackgrounds();
          }
            if (name.equals("Organization"))
    {
              return getOrganization();
          }
            if (name.equals("Division"))
    {
              return getDivision();
          }
            if (name.equals("Title"))
    {
              return getTitle();
          }
            if (name.equals("StartDate"))
    {
              return getStartDate();
          }
            if (name.equals("JobDescription"))
    {
              return getJobDescription();
          }
            return null;
    }
    /**
     * Retrieves a field from the object by name passed in
     * as a String.  The String must be one of the static
     * Strings defined in this Class' Peer.
     *
     * @param name peer name
     * @return value
     */
    public Object getByPeerName(String name)
    {
            if (name.equals(PersonDataPeer.ID))
        {
              return getId();
          }
            if (name.equals(PersonDataPeer.THDL_USER_ID))
        {
              return getThdlUserId();
          }
            if (name.equals(PersonDataPeer.FIRSTNAME))
        {
              return getFirstname();
          }
            if (name.equals(PersonDataPeer.MIDDLENAME))
        {
              return getMiddlename();
          }
            if (name.equals(PersonDataPeer.LASTNAME))
        {
              return getLastname();
          }
            if (name.equals(PersonDataPeer.BIO))
        {
              return getBio();
          }
            if (name.equals(PersonDataPeer.HISTORY))
        {
              return getHistory();
          }
            if (name.equals(PersonDataPeer.PARENT_ORGANIZATION))
        {
              return getParentOrganization();
          }
            if (name.equals(PersonDataPeer.SCHOOL))
        {
              return getSchool();
          }
            if (name.equals(PersonDataPeer.DEPARTMENT))
        {
              return getDepartment();
          }
            if (name.equals(PersonDataPeer.PROGRAM))
        {
              return getProgram();
          }
            if (name.equals(PersonDataPeer.ADVISOR))
        {
              return getAdvisor();
          }
            if (name.equals(PersonDataPeer.HIGHEST_DEGREE))
        {
              return getHighestDegree();
          }
            if (name.equals(PersonDataPeer.YEAR_BEGAN))
        {
              return getYearBegan();
          }
            if (name.equals(PersonDataPeer.YEAR_FINISHED))
        {
              return getYearFinished();
          }
            if (name.equals(PersonDataPeer.OTHER_BACKGROUNDS))
        {
              return getOtherBackgrounds();
          }
            if (name.equals(PersonDataPeer.ORGANIZATION))
        {
              return getOrganization();
          }
            if (name.equals(PersonDataPeer.DIVISION))
        {
              return getDivision();
          }
            if (name.equals(PersonDataPeer.TITLE))
        {
              return getTitle();
          }
            if (name.equals(PersonDataPeer.START_DATE))
        {
              return getStartDate();
          }
            if (name.equals(PersonDataPeer.JOB_DESCRIPTION))
        {
              return getJobDescription();
          }
            return null;
    }

    /**
     * Retrieves a field from the object by Position as specified
     * in the xml schema.  Zero-based.
     *
     * @param pos position in xml schema
     * @return value
     */
    public Object getByPosition(int pos)
    {
            if (pos == 0)
    {
              return getId();
          }
            if (pos == 1)
    {
              return getThdlUserId();
          }
            if (pos == 2)
    {
              return getFirstname();
          }
            if (pos == 3)
    {
              return getMiddlename();
          }
            if (pos == 4)
    {
              return getLastname();
          }
            if (pos == 5)
    {
              return getBio();
          }
            if (pos == 6)
    {
              return getHistory();
          }
            if (pos == 7)
    {
              return getParentOrganization();
          }
            if (pos == 8)
    {
              return getSchool();
          }
            if (pos == 9)
    {
              return getDepartment();
          }
            if (pos == 10)
    {
              return getProgram();
          }
            if (pos == 11)
    {
              return getAdvisor();
          }
            if (pos == 12)
    {
              return getHighestDegree();
          }
            if (pos == 13)
    {
              return getYearBegan();
          }
            if (pos == 14)
    {
              return getYearFinished();
          }
            if (pos == 15)
    {
              return getOtherBackgrounds();
          }
            if (pos == 16)
    {
              return getOrganization();
          }
            if (pos == 17)
    {
              return getDivision();
          }
            if (pos == 18)
    {
              return getTitle();
          }
            if (pos == 19)
    {
              return getStartDate();
          }
            if (pos == 20)
    {
              return getJobDescription();
          }
                return null;
    }

     


    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.
     *
     * @throws Exception
     */
    public void save() throws Exception
    {
             save(PersonDataPeer.getMapBuilder()
                .getDatabaseMap().getName());
     }

    /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.
     * Note: this code is here because the method body is
     * auto-generated conditionally and therefore needs to be
     * in this file instead of in the super class, BaseObject.
     *
     * @param dbName
     * @throws TorqueException
     */
    public void save(String dbName) throws TorqueException
    {
        Connection con = null;
         try
        {
            con = Transaction.begin(dbName);
            save(con);
            Transaction.commit(con);
        }
        catch(TorqueException e)
        {
            Transaction.safeRollback(con);
            throw e;
        }

     }

      /** flag to prevent endless save loop, if this object is referenced
        by another object which falls in this transaction. */
    private boolean alreadyInSave = false;
      /**
     * Stores the object in the database.  If the object is new,
     * it inserts it; otherwise an update is performed.  This method
     * is meant to be used as part of a transaction, otherwise use
     * the save() method and the connection details will be handled
     * internally
     *
     * @param con
     * @throws TorqueException
     */
    public void save(Connection con) throws TorqueException
    {
        if (!alreadyInSave)
      {
        alreadyInSave = true;



  
        // If this object has been modified, then save it to the database.
        if (isModified())
        {
            if (isNew())
            {
                PersonDataPeer.doInsert((PersonData) this, con);
                setNew(false);
            }
            else
            {
                PersonDataPeer.doUpdate((PersonData) this, con);
            }
        }

                                    
                
          if (collMembers != null)
          {
              for (int i = 0; i < collMembers.size(); i++)
              {
                  ((Member) collMembers.get(i)).save(con);
              }
          }
                                        
                
          if (collPersonPersonTypes != null)
          {
              for (int i = 0; i < collPersonPersonTypes.size(); i++)
              {
                  ((PersonPersonType) collPersonPersonTypes.get(i)).save(con);
              }
          }
                  alreadyInSave = false;
      }
      }


                        
    
    

        /**
     * Set the PrimaryKey using ObjectKey.
     *
     * @param  id ObjectKey
     */
    public void setPrimaryKey(ObjectKey key)
        throws TorqueException
    {
                    setId(new Integer(((NumberKey) key).intValue()));
            }

    /**
     * Set the PrimaryKey using a String.
     *
     * @param key
     */
    public void setPrimaryKey(String key) throws TorqueException
    {
                    setId(new Integer(key));
            }


    /**
     * returns an id that differentiates this object from others
     * of its class.
     */
    public ObjectKey getPrimaryKey()
    {
        return SimpleKey.keyFor(getId());
    }

 

    /**
     * Makes a copy of this object.
     * It creates a new object filling in the simple attributes.
     * It then fills all the association collections and sets the
     * related objects to isNew=true.
     */
    public PersonData copy() throws TorqueException
    {
        return copyInto(new PersonData());
    }

    protected PersonData copyInto(PersonData copyObj) throws TorqueException
    {
        copyObj.setId(id);
        copyObj.setThdlUserId(thdl_user_id);
        copyObj.setFirstname(firstname);
        copyObj.setMiddlename(middlename);
        copyObj.setLastname(lastname);
        copyObj.setBio(bio);
        copyObj.setHistory(history);
        copyObj.setParentOrganization(parent_organization);
        copyObj.setSchool(school);
        copyObj.setDepartment(department);
        copyObj.setProgram(program);
        copyObj.setAdvisor(advisor);
        copyObj.setHighestDegree(highest_degree);
        copyObj.setYearBegan(year_began);
        copyObj.setYearFinished(year_finished);
        copyObj.setOtherBackgrounds(other_backgrounds);
        copyObj.setOrganization(organization);
        copyObj.setDivision(division);
        copyObj.setTitle(title);
        copyObj.setStartDate(start_date);
        copyObj.setJobDescription(job_description);

  copyObj.setNew(false);
                                    
                
        List v = getMembers();
        for (int i = 0; i < v.size(); i++)
        {
            Member obj = (Member) v.get(i);
            copyObj.addMember(obj.copy());
            ((Persistent) v.get(i)).setNew(true);
        }
                                              
                
        v = getPersonPersonTypes();
        for (int i = 0; i < v.size(); i++)
        {
            PersonPersonType obj = (PersonPersonType) v.get(i);
            copyObj.addPersonPersonType(obj.copy());
            ((Persistent) v.get(i)).setNew(true);
        }
                copyObj.setNew(true);

                      copyObj.setId((Integer)null);
                                                                                                    return copyObj;
    }

    /**
     * returns a peer instance associated with this om.  Since Peer classes
     * are not to have any instance attributes, this method returns the
     * same instance for all member of this class. The method could therefore
     * be static, but this would prevent one from overriding the behavior.
     */
    public PersonDataPeer getPeer()
    {
        return peer;
    }
}
