title: A circular reference has been detected in Symfony
body: <p>I run into problem tied to circular reference in Symfony, that I suspect to be
  caused by the serializer but I haven't found any answers yet. Here are the entities that I've created, the route and the controller. Any suggestions in this regard will be much appreciated.</p>
  
  <p><strong>User.php</strong></p>
  
  <pre><code>class User
  {
      /**
        * @var int
        *
        * @ORM\Column(name="id", type="integer")
        * @ORM\Id
        * @ORM\GeneratedValue(strategy="AUTO")
      */
      private $id;
  
      /**
        * @ORM\OneToMany(targetEntity="Dieta", mappedBy="user")
      */
      private $dietas;
      public function __construct()
      {
         $this-&gt;dietas = new ArrayCollection();
      }
     //...
     //...
  }
  </code></pre>
  
  <p><strong>Dieta.php</strong></p>
  
  <pre><code>    class Dieta
          {
              /**
               * @var int
               *
               * @ORM\Column(name="id", type="integer")
               * @ORM\Id
               * @ORM\GeneratedValue(strategy="AUTO")
               */
              private $id;
  
              /**
               * @ORM\ManyToOne(targetEntity="User", inversedBy="dietas")
               * @ORM\JoinColumn(name="users_id", referencedColumnName="id")
               */
              private $user;
              public function __construct()
              {
                  $this-&gt;user = new ArrayCollection();
              }
  
              //...
              //... 
          }
  </code></pre>
  
  <p><strong>Route</strong></p>
  
  <pre><code>/**
   * @Route("dietas/list/user/{id}", name="userDietas")
   */
  </code></pre>
  
  <p><strong>Method of DietaController.php</strong></p>
  
  <pre><code>public function userListAction($id)
      {
          $encoders = array(new XmlEncoder(), new JsonEncoder());
          $normalizers = array(new ObjectNormalizer());
          $serializer = new Serializer($normalizers, $encoders);
  
          $user = $this-&gt;getDoctrine()
              -&gt;getRepository('AppBundle:User')-&gt;find($id);
  
          $dietaDatas = $user-&gt;getDietas();
  
  
          if(!$dietaDatas) {
              throw $this-&gt;createNotFoundException(
                  'There is no data...'
              );
          }
  
          $jsonContent = $serializer-&gt;serialize($dietaDatas, 'json');
          return new Response($jsonContent);
      }
  </code></pre>