title: Symfony 4 Serializer: deserializing request and merging it with entity including relation that is not completely passed by client
body: <p>Let's say I have a entity called User:</p>
  
  <pre><code>class User implements UserInterface
      /**
       * @ORM\Id()
       * @ORM\GeneratedValue()
       * @ORM\Column(type="integer")
       */
       private $id;
  
      /**
       * @ORM\Column(type="string", length=255, nullable=false)
       */
       private $username;
  
       /**
       * @ORM\OneToOne(targetEntity="App\Entity\Address", cascade={"persist", "remove"})
       * @ORM\JoinColumn(nullable=false)
       */
      private $address;
  </code></pre>
  
  <p>The address field is a OneToOne relation to the address entity:</p>
  
  <pre><code>class Address
  {
      /**
       * @ORM\Id()
       * @ORM\GeneratedValue()
       * @ORM\Column(type="integer")
       */
      private $id;
  
      /**
       * @ORM\Column(type="string", length=255)
       */
      private $street;
  
      /**
       * @ORM\Column(type="string", length=255)
       */
      private $name;
  </code></pre>
  
  <p>And I have a Controller for updating the user and his address:</p>
  
  <pre><code>...
   public function putUserSelf(Request $request)
      {
          $em = $this-&gt;getDoctrine()-&gt;getManager();
          $user = $this-&gt;getUser();
  
          $encoders = array(new JsonEncoder());
          $normalizers = array(new ObjectNormalizer(null, null, null, new ReflectionExtractor()));
  
          $serializer = new Serializer($normalizers, $encoders);
          $user = $serializer-&gt;deserialize($request-&gt;getContent(), User::class, "json", ['deep_object_to_populate' =&gt; $user]);
          $em-&gt;persist($user);
          $em-&gt;flush();
  </code></pre>
  
  <p>In theory I should now be possible to pass a json like this:</p>
  
  <pre><code>{
      "username": "foo",
      "address": {"name": "bar"}
  }
  </code></pre>
  
  <p>to update my entity. But the problem is, that I get a sql error:</p>
  
  <pre><code>An exception occurred while executing 'INSERT INTO address (street, name) VALUES (?, ?)' with params [null, "bar"]:
  
  SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'street' cannot be null
  </code></pre>
  
  <p>It seems like the entity merge did not work.</p>