title: Entity don't want to flush - Symfony 3.4 / Mongodb / Php
body: <p>When I try to flush an entity that all work well but nothing fill my database but 0 errors... There is my controller: </p>
  
  <pre><code>/**
  * @Security("is_anonymous() or is_authenticated()")
  * @Route("api")
  */
  class MessageUserController extends Controller
  {
  /**
   *
   * @Rest\Post(
   *     path = "/message/user/add",
   *     name = "api_message_add"
   * )
   */
  public function UserAddMessageAction(Request $request)
  {
      $em = $this-&gt;getDoctrine()-&gt;getManager();
  
      $content = ($request-&gt;get('content'));
      $user = $em-&gt;getRepository('AppBundle:User')-&gt;findOneBy(array('id' =&gt; ($request-&gt;get('id_user'))));
      $token = $request-&gt;get('token');
      $friend = $em-&gt;getRepository('AppBundle:User')-&gt;findOneBy(array('id' =&gt; ($request-&gt;get('id_friend'))));
  
  
      if (!isset($content)) {
          return new JsonResponse([
              'success' =&gt; "false",
              'message' =&gt; "Message non renseigné"
          ]);
      }
  
      if (!isset($token)) {
          return new JsonResponse([
              'success' =&gt; "false",
              'message' =&gt; "Token non renseigné"
          ]);
      }
  
      if ($user-&gt;getToken() != $token) {
          return new JsonResponse([
              'success' =&gt; "false",
              'message' =&gt; "Bad token",
          ]);
      }
  
      if (!isset($friend) or !isset($user)) {
          return new JsonResponse([
              'success' =&gt; "false",
              'message' =&gt; "Message sans propriétaire ou destinataire"
          ]);
      }
  
      $message = new MessageUser();
      $message-&gt;setRead('0');
      $message-&gt;setIdReceiver($friend-&gt;getId());
      $message-&gt;setIdTransmitter($user-&gt;getId());
      $message-&gt;setContent($content);
  
      $dm = $this-&gt;get('doctrine_mongodb')-&gt;getManager();
      $dm-&gt;persist($message);
      $dm-&gt;flush();
  
      return new JsonResponse([
          'messages' =&gt; $message,
          'success' =&gt; "true",
          'message' =&gt; "Message ajouté"
      ]);
  }
  
  /**
   *
   * @Rest\Post(
   *     path = "/message/user/list",
   *     name = "api_message_list"
   * )
   */
  public function UserSeeMessageAction()
  {
      $dm = $this-&gt;get('doctrine_mongodb')-&gt;getManager();
      $messages = $dm-&gt;getRepository('AppBundle:MessageUser')-&gt;find(1);
  
  
      return new JsonResponse([
          'messages' =&gt; $messages,
          'success' =&gt; "true",
          'message' =&gt; "Liste de messages"
      ]);
  }
  }
  </code></pre>
  
  <p>My entity: </p>
  
  <pre><code>&lt;?php
  
  namespace AppBundle\Document;
  
  use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
  
  /**
  * @MongoDB\Document()
  */
  class MessageUser
  {
  /**
   * @MongoDB\Id
   */
  protected $id;
  
  /**
   * @MongoDB\Field(type="string")
   */
  protected $content;
  
  /**
   * @MongoDB\Field(type="timestamp")
   */
  protected $sendAt;
  
  /**
   * @MongoDB\Field(type="boolean")
   */
  protected $read = '0';
  
   /**
   * @MongoDB\Field(type="integer")
   */
  protected $idTransmitter;
  
  /**
   * @MongoDB\Field(type="integer")
   */
  protected $idReceiver;
  
  /**
   * Get id
   *
   * @return id $id
   */
  public function getId()
  {
      return $this-&gt;id;
  }
  
  /**
   * Set content
   *
   * @param string $content
   * @return $this
   */
  public function setContent($content)
  {
      $this-&gt;content = $content;
      return $this;
  }
  
  /**
   * Get content
   *
   * @return string $content
   */
  public function getContent()
  {
      return $this-&gt;content;
  }
  
  /**
   * Set sendAt
   *
   * @param timestamp $sendAt
   * @return $this
   */
  public function setSendAt($sendAt)
  {
      $this-&gt;sendAt = $sendAt;
      return $this;
  }
  
  /**
   * Get sendAt
   *
   * @return timestamp $sendAt
   */
  public function getSendAt()
  {
      return $this-&gt;sendAt;
  }
  
  /**
   * Set read
   *
   * @param boolean $read
   * @return $this
   */
  public function setRead($read)
  {
      $this-&gt;read = $read;
      return $this;
  }
  
  /**
   * Get read
   *
   * @return boolean $read
   */
  public function getRead()
  {
      return $this-&gt;read;
  }
  
  /**
   * Set idTransmitter
   *
   * @param integer $idTransmitter
   * @return $this
   */
  public function setIdTransmitter($idTransmitter)
  {
      $this-&gt;idTransmitter = $idTransmitter;
      return $this;
  }
  
  /**
   * Get idTransmitter
   *
   * @return integer $idTransmitter
   */
  public function getIdTransmitter()
  {
      return $this-&gt;idTransmitter;
  }
  
  /**
   * Set idReceiver
   *
   * @param integer $idReceiver
   * @return $this
   */
  public function setIdReceiver($idReceiver)
  {
      $this-&gt;idReceiver = $idReceiver;
      return $this;
  }
  
  /**
   * Get idReceiver
   *
   * @return integer $idReceiver
   */
  public function getIdReceiver()
  {
      return $this-&gt;idReceiver;
  }
  }
  </code></pre>
  
  <p>Like if I do: <a href="http://localhost" rel="nofollow noreferrer">http://localhost</a>:****/api/message/user/add the response looks like this: </p>
  
  <blockquote>
    <p>{
        "messages": {},
        "success": "true",
        "message": "Message ajouté"
    }</p>
  </blockquote>
  
  <p>But if I look my database nothing if in there ... If I type "show dbs" in my terminal I can see my database to 0.0000GB</p>
  
  <p>What mistake did I?</p>