title: Doctrine 2 - Bidirectional Self-referencing One to Many relation not working
body: <p>I am using the code below on my Model</p>
  
  <pre><code>    /**
   * Many Categories have One Category
   * @ORM\ManyToOne(targetEntity="ItemCategory", inversedBy="children")
   * @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
   */
  public $parent;
  
  /**
   * One Category has many Categories
   * @ORM\OneToMany(targetEntity="ItemCategory", mappedBy="parent")
   */
  public $children;
  
  /**
   * ItemCategory constructor.
   */
  public function __construct()
  {
      $this-&gt;children = new \Doctrine\Common\Collections\ArrayCollection();
      $this-&gt;parent_id = 0;
  }
  
  /**
   * @return ItemCategory
   */
  public function getParent()
  {
      return $this-&gt;parent;
  }
  
  /**
   * @param mixed $parent
   */
  public function setParent($parent)
  {
      $this-&gt;parent = $parent;
  }
  
  /**
   * @return ArrayCollection
   */
  public function getChildren()
  {
      return $this-&gt;children;
  }
  </code></pre>
  
  <p>I am using this with Entity manager to get the repository and using findAll() to get all the results which are used on a controller that returns a json of the public properties.</p>
  
  <pre><code>    $em = $this-&gt;getDoctrine()-&gt;getManager();
      $repository = $em-&gt;getRepository("AppBundle:Item\ItemCategory");
      $categories = $repository-&gt;findAll();
      return new JsonResponse(array("item_categories" =&gt; $categories));
  </code></pre>
  
  <p>Symfony is not throwing any errors, and the ManyToOne side is working without issues and pupulates the parent property with a full object.</p>
  
  <p>The OneToMany side though remains empty no matter what I have tried.</p>
  
  <p>The resulting array contains objects that look like that</p>
  
  <p><code>{
      "id": 8,
      "parent": {
          "id": 3,
          "parent": null,
          "children": {},
          "name": "Ανταλλακτικά",
          "description": "",
          "meta_description": "",
          "icon": "cogs"
      },
      "children": {},
      "name": "Ποδηλάτων",
      "description": "",
      "meta_description": "",
      "icon": ""
  },</code></p>
  
  <p>I have searched a lot here on stackexchange and on the documentation, but I could find nothing that works.</p>
  
  <p>I would appreciate a second look at my code in case I am missing something obvious. Thanks for your time</p>
  
  <p>=========== UPDATE ==================</p>
  
  <p>After some more investigation, it appears that the object returned for children is a PersistentCollection.
  This means that I have to execute</p>
  
  <p>$item->getChildren()->GetValues();</p>
  
  <p>to get the actual children </p>
  
  <p>Any thoughts on how I can avoid this and get the values directly on the property? Something to do with fetch mode set to EAGER perhaps?</p>