1
0
mirror of synced 2025-02-02 13:31:45 +03:00

#1169 DDC-3343 - one-to-many persister should only interact with the data when orphanRemoval and EXTRA_LAZY are combined

This commit is contained in:
Marco Pivetta 2015-02-05 00:11:53 +00:00
parent 4884183b95
commit 4bed15b984

View File

@ -223,6 +223,13 @@ class OneToManyPersister extends AbstractCollectionPersister
*/
public function removeElement(PersistentCollection $coll, $element)
{
$mapping = $coll->getMapping();
if ( ! $mapping['orphanRemoval']) {
// no-op: this is not the owning side, therefore no operations should be applied
return false;
}
$uow = $this->em->getUnitOfWork();
// shortcut for new entities
@ -238,9 +245,9 @@ class OneToManyPersister extends AbstractCollectionPersister
return false;
}
$mapping = $coll->getMapping();
$persister = $this->uow->getEntityPersister($mapping['targetEntity']);
$targetMetadata = $this->em->getClassMetadata($mapping['targetEntity']);
$class = $this->em->getClassMetadata($mapping['targetEntity']);
$sql = 'DELETE FROM ' . $this->quoteStrategy->getTableName($class, $this->platform)
. ' WHERE ' . implode('= ? AND ', $class->getIdentifierColumnNames()) . ' = ?';
if ($element instanceof Proxy && ! $element->__isInitialized()) {
$element->__load();