[Solved] Doctrine2 - problem with composite foreign primary key

0 votes
asked Jun 9, 2013 in Solved by ludek.vodicka Skipper developer (140,450 points)

Received by email:

hi, i think i found another bug:
when adding an association that's also a pk, i get two properties generated

/** 
 * @ORM\Entity
 */
class PersonHasPerson

{
    /** 
     * @ORM\Id
     * @ORM\Column(type="integer")
     */
    private $first_person_id;


    /** 
     * @ORM\Id
     * @ORM\Column(type="integer")
     */
    private $second_person_id;


    /** 
     * @ORM\Id
     * @ORM\Column(type="integer")
     */
    private $type;

    /** 
     * @ORM\ManyToOne(targetEntity="Person")
     * @ORM\JoinColumn(name="first_person_id", referencedColumnName="id", nullable=false)
     */
    private $PersonFirst;

    /** 
     * @ORM\ManyToOne(targetEntity="Person")
     * @ORM\JoinColumn(name="second_person_id", referencedColumnName="id", nullable=false)
     */
    private $PersonSecond;
}

should be

/** 
 * @ORM\Entity
 */
class PersonHasPerson

{
    /** 
     * @ORM\Id
     * @ORM\Column(type="integer")
     */
    private $type;

    /** 
     * @ORM\Id
     * @ORM\ManyToOne(targetEntity="Person")
     * @ORM\JoinColumn(name="first_person_id", referencedColumnName="id", nullable=false)
     */
    private $PersonFirst;

    /** 
     * @ORM\Id
     * @ORM\ManyToOne(targetEntity="Person")
     * @ORM\JoinColumn(name="second_person_id", referencedColumnName="id", nullable=false)
     */
    private $PersonSecond;
}

1 Answer

0 votes
answered Jun 9, 2013 by ludek.vodicka Skipper developer (140,450 points)
selected Jul 30, 2014 by Martin Freki Stradej
 
Best answer

Fixed. This fix will be available in upcoming 2.2.0 version

...