title: How to fix: Semantical Error Annotation ORM\Column is not allowed to be declared on method
body: <p>When I try to create or edit a Game, I get this error:</p>
  
  <blockquote>
    <p>[Semantical Error] Annotation @ORM\Column is not allowed to be
    declared on method AppBundle\Entity\Game::setType(). You may only use
    this annotation on these code elements: PROPERTY, ANNOTATION.</p>
  </blockquote>
  
  <p>What's causing this and what can I do to fix this?</p>
  
  <p><strong>Game</strong></p>
  
  <pre><code>&lt;?php
  
  namespace AppBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use Doctrine\Common\Collections\ArrayCollection;
  use Symfony\Component\Validator\Constraints as Assert;
  
  /**
   * Game
   *
   * @ORM\Table(name="game")
   * @ORM\Entity(repositoryClass="AppBundle\Repository\GameRepository")
   */
  class Game
  {
  
      /**
       * @ORM\OneToMany(targetEntity="PlayLog", mappedBy="game")
       */
      private $playlogs;
      public function __construct()
      {
          $this-&gt;playlogs = new ArrayCollection();
      }
  
      /**
       * @ORM\ManyToOne(targetEntity="Type", inversedBy="games")
       * @ORM\JoinColumn(name="type_id", referencedColumnName="id")
       */
      private $type;
  
  
      /**
       * @var int
       *
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
  
      /**
       * @var string
       * @Assert\NotBlank()
       * @Assert\Length(
       *     min = "3",
       *  max = "100"
       * )
       * @ORM\Column(name="name", type="string", length=255, unique=true)
       */
      private $name;
  
  
      /**
       * Get id
       *
       * @return int
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
      /**
       * Set name
       *
       * @param string $name
       *
       * @return Game
       */
      public function setName($name)
      {
          $this-&gt;name = $name;
  
          return $this;
      }
  
      /**
       * Get name
       *
       * @return string
       */
      public function getName()
      {
          return $this-&gt;name;
      }
  
      /**
       * @return mixed
       */
      public function getType()
      {
          return $this-&gt;type;
      }
  
      /**
       * @ORM\Column (options={"default" = none})
       * @param mixed $type
       */
      public function setType($type)
      {
          $this-&gt;type = $type;
      }
  
  
      /**
       * @return mixed
       */
      public function getPlaylogs()
      {
          return $this-&gt;playlogs;
      }
  
      /**
       * @param mixed $playlogs
       */
      public function setPlaylogs($playlogs)
      {
          $this-&gt;playlogs = $playlogs;
      }
  
      public function addPlayLog(PlayLog $playlog)
      {
          $this-&gt;playlog-&gt;add($playlog);
          $playlog-&gt;setPlayLogs($this);
      }
  
  }
  </code></pre>
  
  <p><strong>GameController</strong></p>
  
  <pre><code>&lt;?php
  
  namespace AppBundle\Controller;
  
  use AppBundle\Entity\Game;
  use AppBundle\Entity\PlayLog;
  use AppBundle\Entity\Type;
  use AppBundle\Form\GameType;
  use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
  use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  use Symfony\Component\Form\Extension\Core\Type\DateType;
  use Symfony\Component\HttpFoundation\Request;
  /**
   * Game controller.
   *
   * @Route("game")
   */
  class GameController extends Controller
  {
      /**
       * Lists all game entities.
       *
       * @Route("/", name="game_index")
       * @Method("GET")
       */
      public function indexAction(Request $request)
      {
          $em = $this-&gt;getDoctrine()-&gt;getManager();
          $dql = "SELECT game FROM AppBundle:Game game JOIN game.type type ORDER BY game.name";
          $query = $em-&gt;createQuery($dql);
          /*
           * @var $paginator \Knp\Component\Pager\Paginator
           */
          $paginator = $this-&gt;get('knp_paginator');
          $result = $paginator-&gt;paginate(
               $query,
              $request-&gt;query-&gt;getInt('page', 1),
              $request-&gt;query-&gt;getInt('limit', 25)
          );
  //        dump(get_class($paginator));
  
          return $this-&gt;render('game/index.html.twig', array(
              'games' =&gt; $result,
              'max_limit_error' =&gt; 25
          ));
      }
  
      /**
       * Creates a new game entity.
       *
       * @Route("/new", name="game_new")
       * @Method({"GET", "POST"})
       */
      public function newAction(Request $request)
      {
  
          $game = new Game();
  
          $form = $this-&gt;createForm('AppBundle\Form\GameType', $game);
          $form-&gt;handleRequest($request);
  
          if ($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()) {
              $em = $this-&gt;getDoctrine()-&gt;getManager();
              $em-&gt;persist($game);
              $em-&gt;flush($game);
  
              return $this-&gt;redirectToRoute('game_show', array('id' =&gt; $game-&gt;getId()));
          }
  
          return $this-&gt;render('game/new.html.twig', array(
              'game' =&gt; $game,
              'form' =&gt; $form-&gt;createView(),
          ));
      }
  
      /**
       * Finds and displays a game entity.
       *
       * @Route("/{id}", name="game_show")
       * @Method("GET")
       */
      public function showAction(Game $game)
      {
          $deleteForm = $this-&gt;createDeleteForm($game);
  
  
          return $this-&gt;render('game/show.html.twig', array(
              'game' =&gt; $game,
              'delete_form' =&gt; $deleteForm-&gt;createView(),
          ));
      }
  
      /**
       * Displays a form to edit an existing game entity.
       *
       * @Route("/{id}/edit", name="game_edit")
       * @Method({"GET", "POST"})
       */
      public function editAction(Request $request, Game $game)
      {
          $deleteForm = $this-&gt;createDeleteForm($game);
          $editForm = $this-&gt;createForm('AppBundle\Form\GameType', $game);
          $editForm-&gt;handleRequest($request);
  
          if ($editForm-&gt;isSubmitted() &amp;&amp; $editForm-&gt;isValid()) {
              $this-&gt;getDoctrine()-&gt;getManager()-&gt;flush();
  
              return $this-&gt;redirectToRoute('game_show', array('id' =&gt; $game-&gt;getId()));
          }
  
          return $this-&gt;render('game/edit.html.twig', array(
              'game' =&gt; $game,
              'edit_form' =&gt; $editForm-&gt;createView(),
              'delete_form' =&gt; $deleteForm-&gt;createView(),
  
          ));
      }
  
      /**
       * Displays a form to edit an existing game entity.
       *
       * @Route("/{id}/log", name="game_log")
       * @Method({"GET", "POST"})
       */
      public function addLogAction(Request $request, Game $game)
      {
          $playlog = new PlayLog();
          $form = $this-&gt;createForm(GameType::class, $game);
          $form-&gt;handleRequest($request);
          if($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()) {
  
              //Save playLog
              $em = $this-&gt;getDoctrine()-&gt;getManager();
              $em-&gt;persist($playlog);
              $em-&gt;flush();
  
          }
          // Render / return view incl. formulier.
          return $this-&gt;render('game/log.html.twig', array(
              'game' =&gt; $game,
              'form' =&gt; $form-&gt;createView(),
          ));
      }
  
      /**
       * Deletes a game entity.
       *
       * @Route("/{id}", name="game_delete")
       * @Method("DELETE")
       */
      public function deleteAction(Request $request, Game $game)
      {
          $form = $this-&gt;createDeleteForm($game);
          $form-&gt;handleRequest($request);
  
          if ($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()) {
              $em = $this-&gt;getDoctrine()-&gt;getManager();
              $em-&gt;remove($game);
              $em-&gt;flush($game);
          }
  
          return $this-&gt;redirectToRoute('game_index');
      }
  
      /**
       * Creates a form to delete a game entity.
       *
       * @param Game $game The game entity
       *
       * @return \Symfony\Component\Form\Form The form
       */
      private function createDeleteForm(Game $game)
      {
          return $this-&gt;createFormBuilder()
              -&gt;setAction($this-&gt;generateUrl('game_delete', array('id' =&gt; $game-&gt;getId())))
              -&gt;setMethod('DELETE')
              -&gt;getForm()
          ;
      }
  }
  </code></pre>
  
  <p><strong>Type</strong></p>
  
  <pre><code>&lt;?php
  
  namespace AppBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use Doctrine\Common\Collections\ArrayCollection;
  
  
  /**
   * Type
   *
   * @ORM\Table(name="type")
   * @ORM\Entity(repositoryClass="AppBundle\Repository\TypeRepository")
   */
  class Type
  {
      /**
       * @ORM\OneToMany(targetEntity="Game", mappedBy="type")
       */
      private $games;
  
      public function __construct()
      {
          $this-&gt;games = new ArrayCollection();
      }
      /**
       * @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 Type
       */
      public function setName($name)
      {
          $this-&gt;name = $name;
  
          return $this;
      }
  
      /**
       * Get name
       *
       * @return string
       */
      public function getName()
      {
          return $this-&gt;name;
      }
  
      /**
       * @return mixed
       */
      public function getGames()
      {
          return $this-&gt;games;
      }
  
      /**
       * @param mixed $games
       */
      public function setGames($games)
      {
          $this-&gt;games = $games;
      }
  
      public function addGame(Game $game)
      {
          $this-&gt;games-&gt;add($game);
          $game-&gt;setType($this);
      }
      public function removeGame(Game $game)
      {
          $this-&gt;games-&gt;removeElement($game);
      }
  
  
  
  }
  </code></pre>
  
  <p><strong>TypeType</strong></p>
  
  <pre><code>&lt;?php
  
  namespace AppBundle\Form;
  
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Component\OptionsResolver\OptionsResolver;
  
  class TypeType extends AbstractType
  {
      /**
       * {@inheritdoc}
       */
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $builder-&gt;add('name')        ;
      }
  
      /**
       * {@inheritdoc}
       */
      public function configureOptions(OptionsResolver $resolver)
      {
          $resolver-&gt;setDefaults(array(
              'data_class' =&gt; 'AppBundle\Entity\Type'
          ));
      }
  
      /**
       * {@inheritdoc}
       */
      public function getBlockPrefix()
      {
          return 'appbundle_type';
      }
  
  
  }
  </code></pre>
  
  <p><strong>game/new.html.twig</strong></p>
  
  <pre><code>{% extends 'base.html.twig' %}
  {% import "macros.html.twig" as macro %}
  
  {% block content %}
      &lt;h1&gt;New Game&lt;/h1&gt;
  
      &lt;div class="col-md-4 col-md-offset-4"&gt;
          {{ form_start(form) }}
          &lt;table class="table table-bordered"&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      Name
                  &lt;/td&gt;
                  &lt;td&gt;
                      {{ form_widget(form.name) }}
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      Type
                  &lt;/td&gt;
                  &lt;td&gt;
                      {{ form_widget(form.type) }}
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/div&gt;
      &lt;div class="row"&gt;
          &lt;div class="col-md-4 col-md-offset-4"&gt;
              {{ macro.btnSubmitAndCancel() }}
          &lt;/div&gt;
      &lt;/div&gt;
  
      {{ form_end(form) }}
  </code></pre>