title: Doctrine 2 - Insert new item in database
body: <p>I'm trying to make something very simple.. but I do wrong, and I don't know what is the problem. Just I'm trying to insert new item to database with Doctrine 2:</p>
  
  <pre><code>$favouriteBook = new UserFavouriteBook;
  $favouriteBook-&gt;user_id = 5;
  $favouriteBook-&gt;book_id = 8;
  $favouriteBook-&gt;created_at = new DateTime("now");
  
  $this-&gt;_em-&gt;persist($favouriteBook);
  $this-&gt;_em-&gt;flush();
  </code></pre>
  
  <p>As you can see.. is very simple, but that, give me next error:</p>
  
  <pre><code>Error: Message: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'user_id' cannot be null
  </code></pre>
  
  <p>Obviosly, if I make a "dump" before "persist" and "flush" of $favouriteBook, all looks be correct..</p>
  
  <p>This is my "favouriteBook" entity:</p>
  
  <pre><code>/** @Column(type="integer")
   * @Id
   */
  private $user_id;
  
  /** @Column(type="integer")
   * @Id
   */
  private $book_id;
  
  /**
   * @ManyToOne(targetEntity="Book", inversedBy="usersFavourite")
   * @JoinColumn(name="book_id", referencedColumnName="id")
   */
  private $book;
  
  /**
   * @ManyToOne(targetEntity="User", inversedBy="favouriteBooks")
   * @JoinColumn(name="user_id", referencedColumnName="id")
   */
  private $user;
  
  /** @Column(type="datetime") */
  private $created_at;
  
  public function __get($property) {
      return $this-&gt;$property;
  }
  
  public function __set($property, $value) {
      $this-&gt;$property = $value;
  }  
  </code></pre>
  
  <p>Anyone can image what is the problem? .. I don't know what else try.. Thanks</p>