I am trying to construct an object with two composite foreign keys pointing out to the same object, but they seem to have the same data, like doing the join only on one column, product_id.
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 mapping? Is it possible to have composite foreign keys but without being primary keys?