title: Symfony Entity check for ArrayCollection if already exists, then do update
body: <p>For a Collection, I want to check if a new added Part already exists in the database. And if so, that it'll be overwritten with the new value.</p>
  
  <blockquote>
    <p>
  
  <pre><code>/**
   * Add Part
   */
  public function addPart(\MyBundle\Entity\FooTypePart $Part)
  {
      $part-&gt;setProduct($this);
      $this-&gt;part[] = $part;
  
      return $this;
  }
  
  /**
  */
  public function removePart(\MyBundle\Entity\FooTypePart $part)
  {
      $this-&gt;part-&gt;removeElement($part);
  }
  
  /**
   * Get Part
   * @return \Doctrine\Common\Collections\Collection 
   */
  public function getPart()
  {
      return $this-&gt;part;
  }
  
  /**
   * Set Part
   */
  public function setPart($part)
  {
      $this-&gt;part = $part;
      return $this;
  }
  </code></pre>
  </blockquote>
  
  <p>The Part Entity has: ID, Category_id (FK), Product_id (FK), Part (Collection)</p>
  
  <p>It is possible at the moment to add a new Part with the same name, also when there is already a Part with the same Product_id AND Category_id.
  Making Part unique isn't the fix, because Part can be used for many Products/Categories.</p>
  
  <p>The following example already exists in the database, with a different 'Part'. So it should do a update command.</p>
  
  <pre><code>&lt;?php
  $part = new FooTypePart();
  $part-&gt;setCategory($specification);
  $part-&gt;setProduct($product);
  $part-&gt;setPart('DifferentNamingThenCurrentOne');
  $xx-&gt;addSpecificationValue($part);
  </code></pre>
  
  <p>How? :-)</p>