Reputation: 685
I'm having trouble self joining an entity on oneToMany. My entity looks like:
/*
* @ORM\ManyToOne(targetEntity="IntegritBundle\Entity\UserMessage", inversedBy="related", cascade={"persist", "remove"})
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
* @Serial\Expose
* @Serial\Groups({"all", "basic"})
*/
public $parent;
/**
* @var ArrayCollection
* @ORM\OneToMany(targetEntity="IntegritBundle\Entity\UserMessage", mappedBy="parent", cascade={"persist", "remove"})
* @Serial\Expose
* @Serial\Groups({"all", "basic"})
*/
public $related;
But when querying it I get the error Notice: Undefined index: parent
`
It’s the mappedBy
in the $related
property that’s causing the problem but I don’t see why
Upvotes: 0
Views: 163