title: Symfony2 and Doctrine - Undefined index
body: <p>I have a Symfony 2.4.x project.</p>
  
  <p>In there, I have two entities that are mapped together: Conference and Paper.</p>
  
  <p>Each conference has papers and with a specific conference, I would like to get the number of papers.</p>
  
  <p>For that, in my conference entity, I have:</p>
  
  <pre><code>/**
   * @ORM\OneToMany(targetEntity="Paper", mappedBy="conference")
   */
  protected $papers;
  </code></pre>
  
  <p>In the entity Paper I have:</p>
  
  <pre><code>/**
   * @ORM\ManyToOne(targetEntity="Conference", inversedBy="papers")
   * @ORM\JoinColumn(name="conference_id", referencedColumnName="id")
   */
  protected $conference;
  </code></pre>
  
  <p>When I had this project on Symfony2.0, everything worked well, but now I migrated it in Symfony 2.4.x and I am getting the following error when trying to do:</p>
  
  <pre><code>count($conf-&gt;getPapers()); // In the controller
  {{ conf.papers | length }} // In the twig template
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>ContextErrorException: Notice: Undefined index: hash_key in /var/www/git/conference2.0-v2.4/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php line 121
  </code></pre>
  
  <p>EDIT: Here are the full classes of the two entities in pastebin:</p>
  
  <ul>
  <li>Paper: <a href="http://pastebin.com/Fv7m70VN" rel="noreferrer">http://pastebin.com/Fv7m70VN</a></li>
  <li>Conference: <a href="http://pastebin.com/dbCsH7Nh" rel="noreferrer">http://pastebin.com/dbCsH7Nh</a></li>
  </ul>
  
  <p>EDIT 2: Here are some news that I found by trying to solve the problem. Another classe is involved there: Submission.</p>
  
  <p>Here is the code: <a href="http://pastebin.com/bkdRtjdq" rel="noreferrer">http://pastebin.com/bkdRtjdq</a></p>
  
  <p>In the class Submission, I have the primary key that is hash_key and not the id.</p>