title: Getting strange data after adding a foreign constraint in symfony 3.3
body: <p>I have 2 simple entities in my app:<strong>Product</strong> and <strong>Category</strong> which are related by the <em>ManyToOne</em> relation:</p>
  
  <pre><code>    &lt;?php
  
      namespace AppBundle\Entity;
  
      use Doctrine\ORM\Mapping as ORM;
  
      /**
       * Product
       *
       * @ORM\Table(name="product")
       * @ORM\Entity
       */
      class Product
      {
          /**
           * @var int
           *
           * @ORM\Column(name="id", type="integer")
           * @ORM\Id
           * @ORM\GeneratedValue(strategy="AUTO")
           */
          private $id;
  
          /**
           * @var string
           *
           * @ORM\Column(name="name", type="string", length=255)
           */
          private $name;
  
          /**
           * @var string
           *
           * @ORM\Column(name="description", type="text")
           */
          private $description;
  
          /**
           * @ORM\ManyToOne(targetEntity="Category", inversedBy="products")
           * @ORM\KoinColumn(onDelete="CASCADE")
           */
          private $category;
  
          /**
           * Get id
           *
           * @return int
           */
          public function getId()
          {
              return $this-&gt;id;
          }
  
          /**
           * Set name
           *
           * @param string $name
           *
           * @return Product
           */
          public function setName($name)
          {
              $this-&gt;name = $name;
  
              return $this;
          }
  
          /**
           * Get name
           *
           * @return string
           */
          public function getName()
          {
              return $this-&gt;name;
          }
  
          /**
           * Set description
           *
           * @param string $description
           *
           * @return Product
           */
          public function setDescription($description)
          {
              $this-&gt;description = $description;
  
              return $this;
          }
  
          /**
           * Get description
           *
           * @return string
           */
          public function getDescription()
          {
              return $this-&gt;description;
          }
  
          /**
           * @return int
           */
          public function getCategory()
          {
              return $this-&gt;category;
          }
  
          /**
           * @param int $category
           */
          public function setCategory($category)
          {
              $this-&gt;category = $category;
          }
      }
  
  /**
   * Category
   *
   * @ORM\Table(name="category")
   * @ORM\Entity
   */
  class Category
  {
      /**
       * @var int
       *
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
      /**
       * @var string
       *
       * @ORM\Column(name="name", type="string", length=255)
       */
      private $name;
  
  
      /**
       * Get id
       *
       * @return int
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
      /**
       * Set name
       *
       * @param string $name
       *
       * @return Category
       */
      public function setName($name)
      {
          $this-&gt;name = $name;
  
          return $this;
      }
  
      /**
       * Get name
       *
       * @return string
       */
      public function getName()
      {
          return $this-&gt;name;
      }
  }
  </code></pre>
  
  <p>The relation is working fine.But there is a problem.When i try to fetch my objects from DB by </p>
  
  <pre><code>public function indexAction(){
          $products = $this-&gt;getDoctrine()
              -&gt;getRepository('AppBundle:Product')
              -&gt;findAll();
  
          echo "&lt;pre&gt;";
          print_r($products);die;
      }
  </code></pre>
  
  <p>it returns a tone of code, like:</p>
  
  <pre><code>Array
  (
      [0] =&gt; AppBundle\Entity\Product Object
          (
              [id:AppBundle\Entity\Product:private] =&gt; 1
              [name:AppBundle\Entity\Product:private] =&gt; Samsung Galaxy S5
              [description:AppBundle\Entity\Product:private] =&gt; Stylish and elegant!
              [category:AppBundle\Entity\Product:private] =&gt; Proxies\__CG__\AppBundle\Entity\Category Object
                  (
                      [__initializer__] =&gt; Closure Object
                          (
                              [static] =&gt; Array
                                  (
                                      [entityPersister] =&gt; Doctrine\ORM\Persisters\Entity\BasicEntityPersister Object
                                          (
                                              [class:protected] =&gt; Doctrine\ORM\Mapping\ClassMetadata Object
                                                  (
                                                      [name] =&gt; AppBundle\Entity\Category
                                                      [namespace] =&gt; AppBundle\Entity
                                                      [rootEntityName] =&gt; AppBundle\Entity\Category
                                                      [customGeneratorDefinition] =&gt; 
                                                      [customRepositoryClassName] =&gt; 
                                                      [isMappedSuperclass] =&gt; 
                                                      [isEmbeddedClass] =&gt; 
                                                      [parentClasses] =&gt; Array
                                                          (
                                                          )
  
                                                      [subClasses] =&gt; Array
                                                          (
                                                          )
  
                                                      [embeddedClasses] =&gt; Array
                                                          (
                                                          )
  
                                                      [namedQueries] =&gt; Array
                                                          (
                                                          )
  
                                                      [namedNativeQueries] =&gt; Array
                                                          (
                                                          )
  
                                                      [sqlResultSetMappings] =&gt; Array
                                                          (
                                                          )
  </code></pre>
  
  <p>and a lot more, which is unpossible to present here entirely.
  I will very appreciate if someone suggests me how to get rid of all this unnecessary data and recieve only my object's properties.
  Thanks in advance. </p>