title: Doctrine 2 Remove Entity Problem
body: <p>I am getting an odd bug when I am removing an entity using the entity manager. An exception is being thrown saying "<em>A new entity was found through a relationship that was not configured to cascade persist operations</em>" but I have no new entities. I think this may be a bug in Doctrine but figured I would ask around a bit first to make sure that I wasn't doing anything wrong before filling a report.</p>
  
  <p>The relevant code:</p>
  
  <pre><code>&lt;?php
  $em = Doctrine\ORM\EntityManager::create(array('driver' =&gt; 'pdo_sqlite', 'memory' =&gt; true), $config);
  
  $qb = $em
      -&gt;getRepository('Bar')
      -&gt;createQueryBuilder('bar1')
      -&gt;select('bar1, foo1, bar2')
      -&gt;join('bar1.foo', 'foo1')
      -&gt;join('foo1.bar', 'bar2')
  ;
  
  $qb-&gt;getQuery()-&gt;getResult();
  
  $bar = $em-&gt;getRepository('Bar')-&gt;findOneBy(array('id' =&gt; 20));
  
  $em-&gt;transactional(function($em) use ($bar) {
      $em-&gt;remove($bar);
      $em-&gt;flush();
  });
  </code></pre>
  
  <p>If I remove the <code>$em-&gt;transactional</code> that wraps the remove and flush operation the remove works. Also, if I remove <code>$qb-&gt;getQuery()-&gt;getResult();</code> for the previous query the remove and flush call works.</p>
  
  <p>The error I am getting is:</p>
  
  <pre>
  Fatal error: Uncaught exception 'InvalidArgumentException' with message 'A new entity was found through a relationship that was not configured to cascade persist operations: Bar@0000000049dcca970000000025d8d6f9. Explicitly persist the new entity or configure cascading persist operations on the relationship.' in doctrine2-orm/lib/Doctrine/ORM/UnitOfWork.php:576
  Stack trace:
    #0 doctrine2-orm/lib/Doctrine/ORM/UnitOfWork.php(495): Doctrine\ORM\UnitOfWork >computeAssociationChanges(Array, Object(Doctrine\ORM\PersistentCollection))
    #1 doctrine2-orm/lib/Doctrine/ORM/UnitOfWork.php(537): Doctrine\ORM\UnitOfWork->computeChangeSet(Object(Doctrine\ORM\Mapping\ClassMetadata), Object(Foo))
    #2 doctrine2-orm/lib/Doctrine/ORM/UnitOfWork.php(256): Doctrine\ORM\UnitOfWork->computeChangeSets()
    #3 doctrine2-orm/lib/Doctrine/ORM/EntityManager.php(334): Doctrine\ORM\UnitO in doctrine2-orm/lib/Doctrine/ORM/UnitOfWork.php on line 576
  </pre>
  
  <p>A complete working example can be found in this <a href="https://gist.github.com/959013" rel="nofollow">gist</a>.</p>