title: Error on Doctrine Flush -> null var on Entity
body: <p>I have this error on Symfony 3, I´m using an entity into an entity for insert a row with FK into another table, in this case, $video contain $user(user_id):</p>
  
  <blockquote>
    <p>An exception occurred while executing 'INSERT INTO videos (title,
    description, status, image, video_path, created_at, updated_at,
    user_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?)' with params ["titulo del
    video1", null, null, null, null, "2017-05-06 08:10:16", "2017-05-06
    08:10:16", null]:</p>
    
    <p>SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'user_id'
    cannot be null</p>
  </blockquote>
  
  <p>I have a lot of null from $user data into the var $video... look the dump at the end of the post</p>
  
  <pre><code>            $user_id = ($identity-&gt;sub != null) ? $identity-&gt;sub : null;
  
              $title = (isset($params-&gt;title)) ? $params-&gt;title : null;
              $description = (isset($params-&gt;description)) ? $params-&gt;description : null;
              $status = (isset($params-&gt;status)) ? $params-&gt;status : null;
              if ($user_id != null &amp;&amp; $title != null) {
                  $em = $this-&gt;getDoctrine()-&gt;getManager();
                  $user = $em-&gt;getRepository("BackendBundle:User")-&gt;findOneBy(
                          array(
                              "id" =&gt; $user_id
                  ));
  
                  $video = new Video();
                  $video-&gt;setUser($user);
                  $video-&gt;setTitle($title);
                  $video-&gt;setDescription($description);
                  $video-&gt;setStatus($status);
                  $video-&gt;setCreatedAt($createdAt);
                  $video-&gt;setUpdatedAt($updatedAt);
                  var_dump($video);
                  $em-&gt;persist($video);
                  $em-&gt;flush();
  </code></pre>
  
  <p>var_dump of $video:</p>
  
  <pre><code>object(BackendBundle\Entity\Video)#313 (10) {
    ["id":"BackendBundle\Entity\Video":private]=&gt;
    NULL
    ["title":"BackendBundle\Entity\Video":private]=&gt;
    string(17) "titulo del video1"
    ["description":"BackendBundle\Entity\Video":private]=&gt;
    NULL
    ["status":"BackendBundle\Entity\Video":private]=&gt;
    NULL
    ["image":"BackendBundle\Entity\Video":private]=&gt;
    NULL
    ["videoPath":"BackendBundle\Entity\Video":private]=&gt;
    NULL
    ["createdAt":"BackendBundle\Entity\Video":private]=&gt;
    object(DateTime)#281 (3) {
      ["date"]=&gt;
      string(26) "2017-05-06 08:10:16.255330"
      ["timezone_type"]=&gt;
      int(3)
      ["timezone"]=&gt;
      string(12) "Europe/Paris"
    }
    ["updatedAt":"BackendBundle\Entity\Video":private]=&gt;
    object(DateTime)#282 (3) {
      ["date"]=&gt;
      string(26) "2017-05-06 08:10:16.255350"
      ["timezone_type"]=&gt;
      int(3)
      ["timezone"]=&gt;
      string(12) "Europe/Paris"
    }
    ["user":"BackendBundle\Entity\Video":private]=&gt;
    object(BackendBundle\Entity\User)#317 (8) {
      ["id":"BackendBundle\Entity\User":private]=&gt;
      int(8)
      ["role":"BackendBundle\Entity\User":private]=&gt;
      string(4) "user"
      ["name":"BackendBundle\Entity\User":private]=&gt;
      string(7) "Pruebas"
      ["surname":"BackendBundle\Entity\User":private]=&gt;
      string(7) "Pruebas"
      ["email":"BackendBundle\Entity\User":private]=&gt;
      string(19) "pruebas@pruebas.com"
      ["password":"BackendBundle\Entity\User":private]=&gt;
      string(64) "718e3978516d387924d91980a7e21af2f434de445731951a6585bda2eacef046"
      ["image":"BackendBundle\Entity\User":private]=&gt;
      string(14) "1494043934.png"
      ["createdAt":"BackendBundle\Entity\User":private]=&gt;
      object(DateTime)#314 (3) {
        ["date"]=&gt;
        string(26) "2017-05-05 10:05:36.000000"
        ["timezone_type"]=&gt;
        int(3)
        ["timezone"]=&gt;
        string(12) "Europe/Paris"
      }
    }
    ["User":"BackendBundle\Entity\Video":private]=&gt;
    NULL
  }
  </code></pre>
  
  <p>Look at $video["user"] it´s full, why i have the nulls on flush so?
  anyone knows why?</p>
  
  <p>Videos Entity setUser method</p>
  
  <pre><code>  public function setUser(\BackendBundle\Entity\User $user = null)
    {
      $this-&gt;user = $user;
  
      return $this;
    }
  </code></pre>
  
  <p>Relationship Videos to user DB</p>
  
  <pre><code>   manyToOne:
      User:
          targetEntity: User
          cascade: {  }
          fetch: LAZY
          mappedBy: null
          inversedBy: null
          joinColumns:
              user_id:
                  referencedColumnName: id
          orphanRemoval: false
  </code></pre>