Reputation: 633
I have an entity Family, which has two fields, one dad, one mom, with a OneToOne relation to a Parent entity. The problem is that my Family has a Member field too, with a OneToMany bidirectional relation witch my Member entity (the children).
When i create a family and a member, no problem, it is persisted. But when i want my family back, under the Member field, I have my two Parents... And i dont understand why.
Here is the relation for Member
/**
* @ORM\ManyToOne(targetEntity="Interne\FichierBundle\Entity\Family", inversedBy="members")
* @ORM\JoinColumn(name="family_id", referencedColumnName="id")
*/
private $family;
and for Family :
/**
* @ORM\OneToMany(targetEntity="Interne\FichierBundle\Entity\Membre", mappedBy="famille", cascade={"persist", "remove"})
*/
private $membres;
The getters and setters are correct, I've done many generate:entities and clear:cache too Thanks for your help !
Upvotes: 0
Views: 82
Reputation: 2191
I am not sure if this is an issue from copying your code but there is a type:
you expect the property members on your family:
inversedBy="members")
but your property has actually the name "membres"
private $membres;
Upvotes: 2