title: Doctrine Composite primary key foreign key
body: <p>I realize a web application with Symfony 2 from an existing database. </p>
  
  <p>I have set up an entity with a primary key consisting of two foreign keys. </p>
  
  <p>example: </p>
  
  <p>Entity1 with a composite primary key: property1 (PK), property2 (PK) 
  Entity2 primary key consists of two foreign keys: property1 (PK FK), property2 (PK FK), propriete3 (PK) </p>
  
  <p>I don't how to implement this association: </p>
  
  <p>In the entity2 i do :</p>
  
  <pre><code>/** 
   * @ORM\ManyToOne (targetEntity = "Entity1") 
   * @ORM\JoinColumns ({
   *    @ORM\JoinColumn (name = "property1" referencedColumnName = "property1") 
   *    @ORM\JoinColumn (name = "property2" referencedColumnName = "property2") 
   *    @ORM\Id 
   * @}) 
   */ 
  private $entity1; 
  </code></pre>
  
  <p>But I get an error: </p>
  
  <p>It is not possible to map entity 'ExempleBundle\Entity\Entite1' with a composite primary key as part of the primary key of another entity 'ExempleBundle\Entity\Entite2#entite1'.</p>
  
  <p>How to properly handle this kind of association with Doctrine </p>
  
  <p>I tried to follow this example but I do not understand : <a href="http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/tutorials/composite-primary-keys.html#use-case-1-dynamic-attributes" rel="nofollow noreferrer">http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/tutorials/composite-primary-keys.html#use-case-1-dynamic-attributes</a></p>
  
  <p>Can you give an example of two entities with a similar case and especially on how to make a joint in this case.</p>