Doctrine Multiple Foreign Key

I am trying to create an object with two composite foreign keys pointing to the same object, but they seem to have the same data, for example, make a connection in only one product_id column.

class PostpaidProduct extends Product {
    /**
     * @ManyToOne(targetEntity="Bundle", fetch="EAGER", cascade={"persist"})
     * @JoinColumn(name="bundle_voice_id", referencedColumnName="id")
     */
    private $bundleVoice;

    /**
     * @ManyToOne(targetEntity="Bundle", fetch="EAGER", cascade={"persist"})
     * @JoinColumn(name="bundle_data_id", referencedColumnName="id")
     */
    private $bundleData;

    /**
     * @OneToMany(targetEntity="BundlePromo", mappedBy="product", fetch="EAGER", cascade={"persist"})
     * @JoinColumns({
     *   @JoinColumn(name="id", referencedColumnName="product_id"),
     *   @JoinColumn(name="bundle_voice_id", referencedColumnName="bundle_id")
     * })
     */
    private $bundleVoicePromos;

    /**
     * @OneToMany(targetEntity="BundlePromo", mappedBy="product", fetch="EAGER", cascade={"persist"})
     * @JoinColumns({
     *   @JoinColumn(name="id", referencedColumnName="product_id"),
     *   @JoinColumn(name="bundle_data_id", referencedColumnName="bundle_id")
     * })
     */
    private $bundleDataPromos;

}

What would be wrong with my display? Is it possible to have composite foreign keys, but without primary keys?

+1
source share
1 answer

Doctrine, , @JoinColumns @OneToMany . , . , .

, OneToMany , . , , .

0

All Articles