title: Symfony doctrine - Parent Child not working
body: <p>I have a table "nodes", with the columns id, parent_id and so on...</p>
  
  <pre><code>/**
   * Node
   *
   * @ORM\Table(name="nodes", indexes={@ORM\Index(name="parent", columns={"parent_id"}), @ORM\Index(name="path", columns={"path"})})
   * @ORM\Entity
   */
  class Node
  {
      /**
       * @var integer
       *
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="IDENTITY")
       */
      private $id;
  
      /**
       * @var integer
       *
       * @ORM\Column(name="parent_id", type="integer", nullable=true)
       */
      private $parentId;
  
      ...
  }
  </code></pre>
  
  <p>Now I want to build the parent-child relationsship (parent_id is a foreign key to the same table's id). Based on the symfony cookbook example for Relations (<a href="http://symfony.com/doc/current/book/doctrine.html#entity-relationships-associations" rel="nofollow">http://symfony.com/doc/current/book/doctrine.html#entity-relationships-associations</a>) I tried to create it:</p>
  
  <pre><code>/**
   * @ORM\OneToMany(targetEntity="Node", mappedBy="parent")
   */
  protected $children;
  
  
  /**
   * @ORM\ManyToOne(targetEntity="Node", inversedBy="children")
   * @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
   */
  protected $parent;
  
  
  public function __construct()
  {
      $this-&gt;children = new ArrayCollection();
  }
  </code></pre>
  
  <p>My first problem is, that the command:</p>
  
  <pre><code>php app/console doctrine:generate:entities AppBundle
  </code></pre>
  
  <p>Didn't create the getters and setters for parent and child (no error message, just the normal "generating..." message)</p>
  
  <p>So I created the getters and setters by myself:</p>
  
  <pre><code>/**
   * @return mixed
   */
  public function getParent() {
      return $this-&gt;parent;
  }
  
  /**
   * @param mixed $parent
   */
  public function setParent( $parent ) {
      $this-&gt;parent = $parent;
  }
  
  /**
   * @return mixed
   */
  public function getChildren() {
      return $this-&gt;children;
  }
  
  /**
   * @param mixed $children
   */
  public function setChildren( $children ) {
      $this-&gt;children = $children;
  }
  </code></pre>
  
  <p>But this seems not to work. I can't fetch for example the parent of a node or the children with:</p>
  
  <pre><code>$node-&gt;getParent();
  $node-&gt;getChildren();
  </code></pre>
  
  <p>Both commands retun null, but the data is correct. The code even didn't try to query for parent or children.</p>