Reputation: 1364
Let's say you have
class EntityA {
private $id;
privated $sharedUniqueId;
}
class EntityB {
private $id;
private $sharedUniqueId;
}
//EntityA is in an OneToMany Relation with EntityB
How can one make a OneToMany Association without doctrine creating entityA_id
on EntityB and by using the $sharedUniqueId
attribute. I have been looking through the doc, but I still can't find this specific case. Note that, I do not want to create a primary key composed of {id,sharedUniqueId}
For further Information, the context is from the creation of a table through INSERT INTO ... SELECT ... ON DUPLICATE KEY
and the referencing of the table is done through this custom id which I know will not change if I ever Re-upate the original data hence changing the ids.
EDIT
Why did I get downvote ?
And here is the same question asked. Is it possible to reference a column other than 'id' for a JoinColumn?
Upvotes: 0
Views: 695
Reputation: 1364
For the legitimate people that will one day have this issue. This as described in their docs is a known limitation
It is not possible to use join columns pointing to non-primary keys. Doctrine will think these are the primary keys and create lazy-loading proxies with the data, which can lead to unexpected results. Doctrine can for performance reasons not validate the correctness of this settings at runtime but only through the Validate Schema command.
Upvotes: 2