Reputation: 148
I once more need help from you. Is it possible to implement more than one oneToOne relationship to another Entity?
I have a Entity called Route: In this Entity I have a start-variable and a end-variable. I want that both of them are an oneToOne instance of my second Entity called Position.
Entity Position: In here I have an ID, name, latitude and a longitude.
This picture shows it better: http://s14.directupload.net/images/140324/36o8vyxm.jpg
Is that possible, and how would I implement this in Doctrine? I´ve tried to to give both, start and end, an oneToOne Annotion, but doctrine won´t notice any changes.
Thank you for your help!
Upvotes: 0
Views: 1171
Reputation: 1746
Simply define the fields; What the problems?
In Route entity
/**
* @var string
*
* @ORM\OneToOne(targetEntity="Position", cascade={"all"})
* @ORM\JoinColumn(name="start_position_id", referencedColumnName="id")
*/
private $answerRight;
/**
* @var string
*
* @ORM\OneToOne(targetEntity="Position", cascade={"all"})
* @ORM\JoinColumn(name="end_position_id", referencedColumnName="id")
*/
private $answerWrong;
And in Position entity:
/**
* @ORM\OneToOne(targetEntity="Route")
*/
private $route;
Upvotes: 1