diff --git a/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php index 8ca2c299b..da938d39f 100644 --- a/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php @@ -432,13 +432,20 @@ class BasicEntityPersister } if ($selfReferential) { - $otherKeys = array_keys($mapping['relationToSourceKeyColumns']); + foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) { + $otherKeys[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $relatedClass); + } } } else { - $keys = array_keys($mapping['relationToSourceKeyColumns']); + + foreach ($mapping['joinTable']['joinColumns'] as $joinColumn) { + $keys[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class); + } if ($selfReferential) { - $otherKeys = array_keys($mapping['relationToTargetKeyColumns']); + foreach ($mapping['joinTable']['inverseJoinColumns'] as $joinColumn) { + $otherKeys[] = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->_class); + } } }