(doctrine2 + symfony2) cascading remove : integrity constraint violation 1451

后端 未结 4 1314
忘了有多久
忘了有多久 2020-12-05 15:01

First, sorry for my poor English...

I got four entities : User, Application, Bundle & Entity. Here are their relations (with cascading persist & remove, see

4条回答
  •  青春惊慌失措
    2020-12-05 15:54

    orphanRemoval some times doesn't work because it depends on (gets schedulled in) PersistencCollection. And we might be calling ArrayCollection#removeElement().

    Following is a snippet of the PersistencCollection#remove()

        if ($this->association !== null &&
            $this->association['type'] & ClassMetadata::TO_MANY &&
            $this->owner &&
            $this->association['orphanRemoval']) {
            $this->em->getUnitOfWork()->scheduleOrphanRemoval($removed);
        }
    

    and ArrayCollection does not do that.

提交回复
热议问题