diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php index 20865f10812..4c57154e411 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -281,9 +281,13 @@ private function getEntityFromIdentityMap(string $className, array $data) $idHash = ''; foreach ($class->identifier as $fieldName) { - $idHash .= ' ' . (isset($class->associationMappings[$fieldName]) - ? $data[$class->associationMappings[$fieldName]['joinColumns'][0]['name']] - : $data[$fieldName]); + if (isset($class->associationMappings[$fieldName])) { + $idHash .= ' ' . $data[$class->associationMappings[$fieldName]['joinColumns'][0]['name']]; + } elseif (class_exists('\BackedEnum') && is_a($data[$fieldName], '\BackedEnum')) { + $idHash .= ' ' . $data[$fieldName]->value; + } else { + $idHash .= ' ' . $data[$fieldName]; + } } return $this->_uow->tryGetByIdHash(ltrim($idHash), $class->rootEntityName);