Home Documentation Download Pricing Buy Now

[Solved] Doctrine2 - problem with composite foreign primary key

0 votes

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;
}
asked Jun 9, 2013 in Solved by ludek.vodicka Skipper developer (140,530 points)

1 Answer

0 votes
 
Best answer

Fixed. This fix will be available in upcoming 2.2.0 version

answered Jun 9, 2013 by ludek.vodicka Skipper developer (140,530 points)
selected Jul 30, 2014 by Martin Freki Stradej
...