title: How to update row with unique column in Doctrine
body: <p>I have a row with <code>sku</code> column that must be unique. But when I try to update this row it doesn't happen because of this. How to avoid this with Doctrine ? Or I should write custom logic ?</p>
  <pre><code>if (!$this-&gt;uniqueSkuSpecification-&gt;isSatisfiedBy($request-&gt;getSku())) {
              return ErrorResponse::fromCustomError(
                  'Product sku must be unique',
                  'sku',
                  Response::HTTP_UNPROCESSABLE_ENTITY
              );
          }
  </code></pre>
  <p>The way I am populating the data from <code>$request</code> (its DTO)
  public function updateFields(UpdateProductCommand $request): Product
  {
  $reflection = new \ReflectionClass($this);</p>
  <pre><code>    foreach ($reflection-&gt;getProperties() as $property) {
          $field = ucfirst($property-&gt;getName());
          $getter = &quot;get{$field}&quot;;
          $setter = &quot;set{$field}&quot;;
          if (method_exists($this, $setter) &amp;&amp; !empty($request-&gt;$getter())) {
              $this-&gt;$setter($request-&gt;$getter());
          }
      }
  
      return $this;
  }
  </code></pre>
  <p><strong>EDIT</strong>:
  I am saving/updating this way:</p>
  <pre><code>$this-&gt;entityManager-&gt;persist($product);
  $this-&gt;entityManager-&gt;flush();
  </code></pre>