title: Can't insert value to mapped column in Doctrine 2 in OneToOne relation
body: <p>I am quite new to Doctrine and need help in one situation. I have 2 simple tables Albums &amp; Genre. Please check the structures below:</p>
  
  <p>Albums</p>
  
  <pre><code>id | title   | genre_id | createdon
  1  | Album 1 | 1        | 21/05/2015
  2  | Album 2 | 2        | 21/05/2015
  </code></pre>
  
  <p>Genre</p>
  
  <pre><code>id | genre   | active
  1  | Pop     | 1
  2  | Blue    | 1
  3  | Rock    | 1
  4  | Country | 1
  </code></pre>
  
  <p><em>genre_id</em> from Albums table is mapped to <em>id</em> column of Genre table.</p>
  
  <p>In Albums entity I have mapped this by the below process:</p>
  
  <pre><code>/**
   * @ORM\OneToOne(targetEntity="Genre", mappedBy="albums")
   * @ORM\JoinColumn(name="genre_id", referencedColumnName="id")
   **/
  private $genre;
  
  public function getGenre(){
      return $this-&gt;genre;    
  }
  
  public function setGenre($value)
  {
      $this-&gt;genre = $value;
      return $this;
  }
  </code></pre>
  
  <p>I can fetch genre name flawlessly by <em>getGenre()</em> method but the problem is while inserting value into the database. I need to insert genre_id which is an integer value but after calling <em>setGenre()</em> method from controller I am getting the following error:</p>
  
  <blockquote>
    <p>Expected value of type "Album\Entity\Genre" for association field
    "Album\Entity\Albums#$genre", got "string" instead.</p>
  </blockquote>
  
  <p>I have also tried by specifying another private variable like the original column name i.e genre_id like below:</p>
  
  <pre><code>/** @ORM\Column(type="integer") */
  protected $genre_id;
  
  public function setGenre($value)
  {
     $this-&gt;genre_id = $value;
     return $this;
  }
  </code></pre>
  
  <p>But then I am getting the following error:</p>
  
  <blockquote>
    <p>An exception occurred while executing 'INSERT INTO Albums (title,
    createdon, genre_id) VALUES (?, ?, ?)' with params ["nfhgfh",
    "21/05/2015", null]:</p>
    
    <p>SQLSTATE[23000]: Integrity constraint violation: 1048 Column
    'genre_id' cannot be null</p>
  </blockquote>
  
  <p>I am calling the entity from controller like this:</p>
  
  <pre><code>$albums = new Albums();
  $albums-&gt;setTitle($postData['title']);
  $albums-&gt;setGenre($postData['genre_id']);
  $albums-&gt;setCreatedon(date('d/m/Y'));
  $this-&gt;em()-&gt;persist($albums);
  
  $this-&gt;em()-&gt;flush();
  </code></pre>
  
  <p>I am badly stuck in this problem and need your help. I am not having any clue how its getting a null value instead. Please help.</p>