我无法在oneToMany上加入实体。我的实体看起来像:
/*
* @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;
但在查询时我收到错误Notice: Undefined index: parent
`
mappedBy
属性中的$related
导致问题,但我不明白为什么
答案 0 :(得分:1)
问题是$ parent的docblock上缺少*:)