I have following source:
class ‘ParameterWert’
/**
* @ManyToOne(targetEntity="Parameter", inversedBy="Werte")
* @JoinColumn(name="Parameter_histid", referencedColumnName="HistID")
*/
protected $Parameter;
class ‘Parameter’
/**
* @OneToMany(targetEntity="ParameterWert", mappedBy="Parameter")
* @var ParameterWert[]
*/
protected $Werte;
This works as long as the HistID is marked with ‘@Id’:
/**
* @Id @Column(type="integer")
* @var integer
*/
protected $HistID;
But I dont want to mark HistID with @Id because I have antoher ID and HistID is not unique without some other fields. How to make a ManyToOne-relation on a non-ID-Member? Are there other possibilities, maybe like ‘@Index1’, …?
Wait a second, what should logically be your ID?
If HistID is not unique by itself, maybe you can do a composite key with some other column to make it unique.
Just to note, composite keys are not recommended in Doctrine, although they are fully supported. Maybe you are better off with just using a dummy autoincremented id…
Anyway, never tried it, but I don’t believe that associations can work properly without specifying the ID