title: Doctrine 2 ManyToOne with Join Table
body: <p>I'm looking for a suggestion on how to map a OneToMany/ManyToOne relationship that uses a join table. The mapping I have is not taking, and I get an error that article_id is not set in the media table. </p>
  
  
  
  <pre class="lang-php prettyprint-override"><code>class Media
  {
      // ...
  
      /**
       * @ManyToOne(targetEntity="Document", inversedBy="media")
       * @JoinTable(name="articles_x_media", referencedColumnName="id")
       * joinColumns={@JoinColumn(name="media_id", referencedColumnName="id")},
       * inverseJoinColumns={@JoinColumn(name="bid_id", referencedColumnName="id")})
       * )
       */
      protected $document;
  }
  
  class Document
  {
      // ...
  
      /**
       * @OneToMany(targetEntity="Media", mappedBy="document"))
       * @JoinTable(name="articles_x_media", referencedColumnName="id")
       * joinColumns={@JoinColumn(name="article_id", referencedColumnName="id")},
       * inverseJoinColumns={@JoinColumn(name="media_id", referencedColumnName="id")}
       * )
       */
      protected $media;
  }
  </code></pre>