title: doctrine 2 persist tries to insert existing items instead of updating them
body: <p>I'm making the switch from doctrine 1.2 to 2.x and am running into a strange problem.</p>
  
  <p>I have an entity <em>CompositionRule</em> that has an attribute $buildingBlock, pointing to a <em>BuildingBlock</em> entity.</p>
  
  <p>I set this attribute, making it point to an existing BuildingBlock, which I fetch from the database.</p>
  
  <p>When I persist the main object (CompositionRule), the entitymanager tries to create a new BuildingBlock item and insert it in the database instead of just accepting that it already exists and ignoring it.</p>
  
  <p>I don't see what I'm missing here as in doctrine 1.2 when you executed $entity->save(); all the underlying objects were correctly handled.</p>
  
  <p>Here are some parts of my mappings / code:</p>
  
  <p><strong>CompositionRule:</strong></p>
  
  <pre><code>&lt;many-to-one field="buildingBlock" target-entity="BuildingBlock"&gt;
     &lt;cascade&gt;&lt;cascade-all /&gt;&lt;/cascade&gt;
  &lt;/many-to-one&gt;
  ..
  public function setBuildingBlock($buildingBlock) {
      $buildingBlock-&gt;addCompositionRule($this);
      $this-&gt;buildingBlock = $buildingBlock;
  }
  </code></pre>
  
  <p><strong>BuildingBlock</strong></p>
  
  <pre><code>&lt;one-to-many field="compositionRules" target-entity="CompositionRule" mapped-by="buildingBlock"&gt;
      &lt;cascade&gt;
          &lt;cascade-all /&gt;
      &lt;/cascade&gt;
  &lt;/one-to-many&gt;
  
  public function addCompositionRule($rule) {
      $this-&gt;compositionRules-&gt;add($rule);
  }
  </code></pre>