title: symfony2 createAction with OneToMany
body: <p>I have 2 entities. Entity Category with 2 columns: <code>id, caName</code>. Entity Service with 4 columns: <code>id, seName, sePrice, caId</code>. Column <code>caId</code> in the Service are contain <code>id</code> of Category.</p>
  
  <p>My goal is making a createAction, editAction and deleteAction for the Service. I have no problem with editAction and deleteAction. However, my createAction returns 500 (Internal Server Error).</p>
  
  <p>Log:</p>
  
  <p>Catchable Fatal Error: Argument 1 passed to AppBundle\Entity\Service::setCaId() must be an instance of AppBundle\Entity\Category, integer given, called in /Applications/MAMP/htdocs/symfony_luxurysalon/src/AppBundle/Controller/ServiceController.php on line 67 and defined</p>
  
  <p>Category entity:</p>
  
  <pre><code>class Category
  {
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     * @ORM\OneToMany(
     *   targetEntity="Service",
     *   mappedBy="caId"
     * )
     */
    private $id;
  
    ...
  
    public function __construct()
    {
      $this-&gt;id = new ArrayCollection();
    }
  
    /**
    * Get id
    *
    * @return Service
    */
    public function getId()
    {
       return $this-&gt;id;
    }
  
    ...
  }
  </code></pre>
  
  <p>Service entity:</p>
  
  <pre><code>class Service
  {
     ...
  
    /**
    * @var int
    *
    * @ORM\Column(name="ca_id", type="integer", length=2)
    * @ORM\ManyToOne(targetEntity="Category", inversedBy="id", cascade={"persist","remove"})
    * @ORM\JoinColumn(onDelete="CASCADE")
    */
    private $caId;
  
    ...
  
    /**
    * Set caId
    *
    * @param \AppBundle\Entity\Category $caId
    *
    * @return Service
    */
    public function setCaId(\AppBundle\Entity\Category $caId = null)
    {
        $this-&gt;caId = $caId;
        return $this;
    }
  
    /**
    * Get caId
    *
    * @return \AppBundle\Entity\Category
    */
    public function getCaId()
    {
      return $this-&gt;caId;
    }
  }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>$entity = new Service();
  $entity
    -&gt;setSeName("test")
    -&gt;setSePrice("200");
    -&gt;setCaId("2");
  
  $em = $this-&gt;getDoctrine()-&gt;getManager();
  $em-&gt;persist($entity);
  $em-&gt;flush();
  </code></pre>