Doctrine cascade on OneToMany does not set the parent object?
问题 I have a User objects which has many Journal entries. The user class contains a $userJournals property and the required add/remove functions, as below: class User{ .... /** * @var \Doctrine\Common\Collections\ArrayCollection * * @ORM\OneToMany(targetEntity="models\UserJournal", mappedBy="user", cascade={"persist"}) */ protected $userJournals; .... public function addUserJournal(\models\UserJournal $userJournal) { $this->userJournals->add($userJournal); return $this; } } The UserJournal class