title: Generating Getters and setters Symfony2
body: <p>I firstly created the database and then generated the entities from it. After that I generated the getters and setters in the entities using:</p>
  
  <pre><code>php app/console doctrine:generate:entities DigitalManager
  </code></pre>
  
  <p>Later on I decided to create the association (One to Many) between the entities, so I added the respective commands in my Entities and what I got is this:</p>
  
  <p><strong>Party Entity</strong>:</p>
  
  <pre><code>&lt;?php
  
  namespace DigitalManager\Bundle\ERPBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  
  /**
  * Party
  *
  * @ORM\Table(name="party")
  * @ORM\Entity
  */
  class Party
  { 
  /**
   * @var string
   *
   * @ORM\Column(name="name", type="string", length=45, nullable=true)
   */
  private $name;
  
  /**
   * @ORM\ManyToOne(targetEntity="Account", inversedBy="parties")
   * @ORM\JoinColumn(name="account_id", referencedColumnName="aid")
   */
  public $account;
  
  /**
   * @var string
   *
   * @ORM\Column(name="address", type="string", length=45, nullable=true)
   */
  private $address;
  
  /**
   * @var string
   *
   * @ORM\Column(name="phone_fax", type="string", length=45, nullable=true)
   */
  private $phoneFax;
  
  /**
   * @var string
   *
   * @ORM\Column(name="fax", type="string", length=45, nullable=true)
   */
  private $fax;
  
  /**
   * @var string
   *
   * @ORM\Column(name="email", type="string", length=45, nullable=true)
   */
  private $email;
  
  /**
   * @var string
   *
   * @ORM\Column(name="mobile", type="string", length=45, nullable=true)
   */
  private $mobile;
  
  /**
   * @var string
   *
   * @ORM\Column(name="country", type="string", length=45, nullable=true)
   */
  private $country;
  
  /**
   * @var string
   *
   * @ORM\Column(name="city", type="string", length=45, nullable=true)
   */
  private $city;
  
  /**
   * @var string
   *
   * @ORM\Column(name="phone_res", type="string", length=45, nullable=true)
   */
  private $phoneRes;
  
  /**
   * @var string
   *
   * @ORM\Column(name="remarks", type="string", length=45, nullable=true)
   */
  private $remarks;
  
  /**
   * @var boolean
   *
   * @ORM\Column(name="active", type="boolean", nullable=true)
   */
  private $active;
  
  /**
   * @var integer
   *
   * @ORM\Column(name="limit", type="integer", nullable=true)
   */
  private $limit;
  
  /**
   * @var integer
   *
   * @ORM\Column(name="term", type="integer", nullable=true)
   */
  private $term;
  
  /**
   * @var string
   *
   * @ORM\Column(name="officer_id", type="string", length=45, nullable=true)
   */
  private $officerId;
  
  /**
   * @var \DateTime
   *
   * @ORM\Column(name="date", type="datetime", nullable=true)
   */
  private $date;
  
  /**
   * @var string
   *
   * @ORM\Column(name="cnic", type="string", length=45, nullable=true)
   */
  private $cnic;
  
  /**
   * @var string
   *
   * @ORM\Column(name="ntn", type="string", length=45, nullable=true)
   */
  private $ntn;
  
  /**
   * @var boolean
   *
   * @ORM\Column(name="L_O", type="boolean", nullable=true)
   */
  private $lO;
  
  /**
   * @var string
   *
   * @ORM\Column(name="type", type="string", length=45, nullable=true)
   */
  private $type;
  
  /**
   * @var integer
   *
   * @ORM\Column(name="acc_id", type="integer", nullable=true)
   */
  private $accId;
  
  /**
   * @var integer
   *
   * @ORM\Column(name="party_id", type="integer")
   * @ORM\Id
   * @ORM\GeneratedValue(strategy="IDENTITY")
   */
  private $partyId;
  
  
  
  /**
   * Set name
   *
   * @param string $name
   * @return Party
   */
  public function setName($name)
  {
      $this-&gt;name = $name;
  
      return $this;
  }
  
  /**
   * Get name
   *
   * @return string 
   */
  public function getName()
  {
      return $this-&gt;name;
  }
  
  /**
   * Set address
   *
   * @param string $address
   * @return Party
   */
  public function setAddress($address)
  {
      $this-&gt;address = $address;
  
      return $this;
  }
  
  /**
   * Get address
   *
   * @return string 
   */
  public function getAddress()
  {
      return $this-&gt;address;
  }
  
  /**
   * Set phoneFax
   *
   * @param string $phoneFax
   * @return Party
   */
  public function setPhoneFax($phoneFax)
  {
      $this-&gt;phoneFax = $phoneFax;
  
      return $this;
  }
  
  /**
   * Get phoneFax
   *
   * @return string 
   */
  public function getPhoneFax()
  {
      return $this-&gt;phoneFax;
  }
  
  /**
   * Set fax
   *
   * @param string $fax
   * @return Party
   */
  public function setFax($fax)
  {
      $this-&gt;fax = $fax;
  
      return $this;
  }
  
  /**
   * Get fax
   *
   * @return string 
   */
  public function getFax()
  {
      return $this-&gt;fax;
  }
  
  /**
   * Set email
   *
   * @param string $email
   * @return Party
   */
  public function setEmail($email)
  {
      $this-&gt;email = $email;
  
      return $this;
  }
  
  /**
   * Get email
   *
   * @return string 
   */
  public function getEmail()
  {
      return $this-&gt;email;
  }
  
  /**
   * Set mobile
   *
   * @param string $mobile
   * @return Party
   */
  public function setMobile($mobile)
  {
      $this-&gt;mobile = $mobile;
  
      return $this;
  }
  
  /**
   * Get mobile
   *
   * @return string 
   */
  public function getMobile()
  {
      return $this-&gt;mobile;
  }
  
  /**
   * Set country
   *
   * @param string $country
   * @return Party
   */
  public function setCountry($country)
  {
      $this-&gt;country = $country;
  
      return $this;
  }
  
  /**
   * Get country
   *
   * @return string 
   */
  public function getCountry()
  {
      return $this-&gt;country;
  }
  
  /**
   * Set city
   *
   * @param string $city
   * @return Party
   */
  public function setCity($city)
  {
      $this-&gt;city = $city;
  
      return $this;
  }
  
  /**
   * Get city
   *
   * @return string 
   */
  public function getCity()
  {
      return $this-&gt;city;
  }
  
  /**
   * Set phoneRes
   *
   * @param string $phoneRes
   * @return Party
   */
  public function setPhoneRes($phoneRes)
  {
      $this-&gt;phoneRes = $phoneRes;
  
      return $this;
  }
  
  /**
   * Get phoneRes
   *
   * @return string 
   */
  public function getPhoneRes()
  {
      return $this-&gt;phoneRes;
  }
  
  /**
   * Set remarks
   *
   * @param string $remarks
   * @return Party
   */
  public function setRemarks($remarks)
  {
      $this-&gt;remarks = $remarks;
  
      return $this;
  }
  
  /**
   * Get remarks
   *
   * @return string 
   */
  public function getRemarks()
  {
      return $this-&gt;remarks;
  }
  
  /**
   * Set active
   *
   * @param boolean $active
   * @return Party
   */
  public function setActive($active)
  {
      $this-&gt;active = $active;
  
      return $this;
  }
  
  /**
   * Get active
   *
   * @return boolean 
   */
  public function getActive()
  {
      return $this-&gt;active;
  }
  
  /**
   * Set limit
   *
   * @param integer $limit
   * @return Party
   */
  public function setLimit($limit)
  {
      $this-&gt;limit = $limit;
  
      return $this;
  }
  
  /**
   * Get limit
   *
   * @return integer 
   */
  public function getLimit()
  {
      return $this-&gt;limit;
  }
  
  /**
   * Set term
   *
   * @param integer $term
   * @return Party
   */
  public function setTerm($term)
  {
      $this-&gt;term = $term;
  
      return $this;
  }
  
  /**
   * Get term
   *
   * @return integer 
   */
  public function getTerm()
  {
      return $this-&gt;term;
  }
  
  /**
   * Set officerId
   *
   * @param string $officerId
   * @return Party
   */
  public function setOfficerId($officerId)
  {
      $this-&gt;officerId = $officerId;
  
      return $this;
  }
  
  /**
   * Get officerId
   *
   * @return string 
   */
  public function getOfficerId()
  {
      return $this-&gt;officerId;
  }
  
  /**
   * Set date
   *
   * @param \DateTime $date
   * @return Party
   */
  public function setDate($date)
  {
      $this-&gt;date = $date;
  
      return $this;
  }
  
  /**
   * Get date
   *
   * @return \DateTime 
   */
  public function getDate()
  {
      return $this-&gt;date;
  }
  
  /**
   * Set cnic
   *
   * @param string $cnic
   * @return Party
   */
  public function setCnic($cnic)
  {
      $this-&gt;cnic = $cnic;
  
      return $this;
  }
  
  /**
   * Get cnic
   *
   * @return string 
   */
  public function getCnic()
  {
      return $this-&gt;cnic;
  }
  
  /**
   * Set ntn
   *
   * @param string $ntn
   * @return Party
   */
  public function setNtn($ntn)
  {
      $this-&gt;ntn = $ntn;
  
      return $this;
  }
  
  /**
   * Get ntn
   *
   * @return string 
   */
  public function getNtn()
  {
      return $this-&gt;ntn;
  }
  
  /**
   * Set lO
   *
   * @param boolean $lO
   * @return Party
   */
  public function setLO($lO)
  {
      $this-&gt;lO = $lO;
  
      return $this;
  }
  
  /**
   * Get lO
   *
   * @return boolean 
   */
  public function getLO()
  {
      return $this-&gt;lO;
  }
  
  /**
   * Set type
   *
   * @param string $type
   * @return Party
   */
  public function setType($type)
  {
      $this-&gt;type = $type;
  
      return $this;
  }
  
  /**
   * Get type
   *
   * @return string 
   */
  public function getType()
  {
      return $this-&gt;type;
  }
  
  /**
   * Set accId
   *
   * @param integer $accId
   * @return Party
   */
  public function setAccId($accId)
  {
      $this-&gt;accId = $accId;
  
      return $this;
  }
  
  /**
   * Get accId
   *
   * @return integer 
   */
  public function getAccId()
  {
      return $this-&gt;accId;
  }
  
  /**
   * Get partyId
   *
   * @return integer 
   */
  public function getPartyId()
  {
      return $this-&gt;partyId;
  }
  }
  </code></pre>
  
  <p><strong>Account Entity</strong></p>
  
  <pre><code>&lt;?php
  
  namespace DigitalManager\Bundle\ERPBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use Doctrine\Common\Collections\ArrayCollection;
  
  /**
   * Account
   *
   * @ORM\Table(name="account")
   * @ORM\Entity
   */
  class Account
  {
  
      public function __construct()
      {
          parent::__construct();
  
          // The line below must be here as a single category is to be mapped to many products, so an ArrayCollection is required instead of Array.
          $this-&gt;parties = new ArrayCollection();
      }
  
      /**
       * @var string
       *
       * @ORM\Column(name="name", type="string", length=45, nullable=true)
       */
      private $name;
  
      // The metadata above the $products property of the Category object is less important, and simply tells
      // Doctrine to look at the Product.category property to figure out how the relationship is mapped.
  
      /**
       * @ORM\OneToMany(targetEntity="Party", mappedBy="account")
       */
      protected $parties;
  
      /**
       * @var string
       *
       * @ORM\Column(name="address", type="string", length=200, nullable=true)
       */
      private $address;
  
      /**
       * @var string
       *
       * @ORM\Column(name="level1", type="string", length=45, nullable=true)
       */
      private $level1;
  
      /**
       * @var string
       *
       * @ORM\Column(name="level2", type="string", length=45, nullable=true)
       */
      private $level2;
  
      /**
       * @var string
       *
       * @ORM\Column(name="level3", type="string", length=45, nullable=true)
       */
      private $level3;
  
      /**
       * @var string
       *
       * @ORM\Column(name="contact", type="string", length=45, nullable=true)
       */
      private $contact;
  
      /**
       * @var integer
       *
       * @ORM\Column(name="aid", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="IDENTITY")
       */
      private $aid;
  
  
  
      /**
       * Set name
       *
       * @param string $name
       * @return Account
       */
      public function setName($name)
      {
          $this-&gt;name = $name;
  
          return $this;
      }
  
      /**
       * Get name
       *
       * @return string 
       */
      public function getName()
      {
          return $this-&gt;name;
      }
  
      /**
       * Set address
       *
       * @param string $address
       * @return Account
       */
      public function setAddress($address)
      {
          $this-&gt;address = $address;
  
          return $this;
      }
  
      /**
       * Get address
       *
       * @return string 
       */
      public function getAddress()
      {
          return $this-&gt;address;
      }
  
      /**
       * Set level1
       *
       * @param string $level1
       * @return Account
       */
      public function setLevel1($level1)
      {
          $this-&gt;level1 = $level1;
  
          return $this;
      }
  
      /**
       * Get level1
       *
       * @return string 
       */
      public function getLevel1()
      {
          return $this-&gt;level1;
      }
  
      /**
       * Set level2
       *
       * @param string $level2
       * @return Account
       */
      public function setLevel2($level2)
      {
          $this-&gt;level2 = $level2;
  
          return $this;
      }
  
      /**
       * Get level2
       *
       * @return string 
       */
      public function getLevel2()
      {
          return $this-&gt;level2;
      }
  
      /**
       * Set level3
       *
       * @param string $level3
       * @return Account
       */
      public function setLevel3($level3)
      {
          $this-&gt;level3 = $level3;
  
          return $this;
      }
  
      /**
       * Get level3
       *
       * @return string 
       */
      public function getLevel3()
      {
          return $this-&gt;level3;
      }
  
      /**
       * Set contact
       *
       * @param string $contact
       * @return Account
       */
      public function setContact($contact)
      {
          $this-&gt;contact = $contact;
  
          return $this;
      }
  
      /**
       * Get contact
       *
       * @return string 
       */
      public function getContact()
      {
          return $this-&gt;contact;
      }
  
      /**
       * Get aid
       *
       * @return integer 
       */
      public function getAid()
      {
          return $this-&gt;aid;
      }
  }
  </code></pre>
  
  <p>After adding these association commands, I tried to generate the getters and setters for these using:</p>
  
  <blockquote>
    <p>php app/console doctrine:generate:entities DigitalManager</p>
  </blockquote>
  
  <p>But it doesn't seem to generate the getters and setters for these associated attributes. I have looked up the syntax through the Symfony2 documentation and it was the same for creating associations. Can anyone please tell me what's wrong here, why does it not generate the getters and setters, although the attributes are there?</p>