title: ReferenceRepository strips related entities when calling getReference()
body: <p>I am writing a Symfony 2 unit test that relies heavily on data fixtures.  As a shortcut, I wired up a method that will give me access to the fixture loader's <code>ReferenceRepository</code> so that I can access shared entities in my tests.</p>
  
  <p>However, when I pull an object out of the <code>ReferenceRepository</code>, it has no relations, even though I persist them in the data fixture.</p>
  
  <p>The weird part is, there is some code in <code>ReferenceRepository</code> that appears to be stripping those relations out, and I don't understand why it is doing this (let alone how to prevent it).</p>
  
  <p>As an example, here is what a data fixture looks like:</p>
  
  <pre><code>public function load(ObjectManager $manager)
  {
      $project = new Project();
      // ... populate fields ...
  
      /* Add one detail field to the Project. */
      $detail = new ProjectDetail();
      // ... populate fields ...
      $project-&gt;addDetail($detail);
  
      $manager-&gt;persist($project);
      $manager-&gt;flush();
  
      $this-&gt;addReference('project-onedetail', $project);
  }
  </code></pre>
  
  <p>In my test case, I am doing something (more or less) like this:</p>
  
  <pre><code>$project =
      $this-&gt;fixtureLoader-&gt;getReferenceRepository()
          -&gt;getReference('project-onedetail');
  </code></pre>
  
  <p>When I call the method in the test case to grab this <code>Project</code> object, I notice some weird behavior:</p>
  
  <p>From <code>Doctrine\Common\DataFixtures\ReferenceRepository</code> (comments added):</p>
  
  <pre><code>public function getReference($name)
  {
      $reference = $this-&gt;references[$name];
  
      // At this point, $reference contains the Project object with related ProjectDetail.
      //  It would be awesome if the method would just return $reference...
  
      $meta = $this-&gt;manager-&gt;getClassMetadata(get_class($reference));
      $uow = $this-&gt;manager-&gt;getUnitOfWork();
  
      if (!$uow-&gt;isInIdentityMap($reference) &amp;&amp; isset($this-&gt;identities[$name])) {
          // ... but instead it goes into this conditional....
  
          $reference = $this-&gt;manager-&gt;getReference(
              $meta-&gt;name,
              $this-&gt;identities[$name]
          );
  
          // ... and now $reference-&gt;getDetails() is empty!  What just happened??
  
          $this-&gt;references[$name] = $reference; // already in identity map
      }
  
      return $reference;
  }
  </code></pre>
  
  <p>What's going on in <code>ReferenceRepository-&gt;getReference()</code>?  Why are the related objects getting removed from <code>$reference</code>, and how do I prevent that?</p>