title: How to deal with association on composite key entities with Doctrine2?
body: <p>Say I have an Offer, which can have 1-n Range.
  Immediately you think, "put a offer_id inside Range".</p>
  
  <p>But my Offer has a composite primary key (composed of two fields). There is no AUTOINCREMENT id column. </p>
  
  <p>The Doctrine2 documentation doesn't say much about that particular case, here is my entities:</p>
  
  <pre><code>&lt;?php
  use Doctrine\ORM\Mapping as ORM;
  /**
   * @ORM\Table()
   * @ORM\Entity
   */
  class Offer
  {
      /**
       * @var Site $site
       * @ORM\Id
       * @ORM\ManyToOne(targetEntity="Site")
       * @ORM\JoinColumn(name="site_id", referencedColumnName="id")
       */
          private $site;
  
      /**
       * @var string $pouet
       * @ORM\Id
       * @ORM\Column(name="pouet", type="string", length=255)
       */
      private $pouet;
  }
  
  &lt;?php
  use Doctrine\ORM\Mapping as ORM;
  
  /**
   * @ORM\Table(name="RangeItem")
   * @ORM\Entity
   */
  class Range
  {
      /**
       * @todo This is test code only do not push me :-)
       * @var ArrayCollection
       * @ORM\ManyToOne(targetEntity="Offer")
       */
      private $offers;
  }
  </code></pre>
  
  <p>I obtaind this error:</p>
  
  <blockquote>
    <p>[Doctrine\ORM\ORMException]<br>
    Column name <code>id</code> referenced for relation from
    Pouet\MyBundle\Entity\Range towards Pouet\MyBundle\Entity\Offer does
    not exist.</p>
  </blockquote>
  
  <p>That make sense, but how can I deal with this issue? Is a Table with composite primary key forbidden to have associations on it?</p>