diff --git a/lib/Doctrine/ORM/Id/AssignedGenerator.php b/lib/Doctrine/ORM/Id/AssignedGenerator.php index 3ad2cbff7..9bdaa0efc 100644 --- a/lib/Doctrine/ORM/Id/AssignedGenerator.php +++ b/lib/Doctrine/ORM/Id/AssignedGenerator.php @@ -55,12 +55,8 @@ class AssignedGenerator extends AbstractIdGenerator } if (isset($class->associationMappings[$idField])) { - if ( ! $em->getUnitOfWork()->isInIdentityMap($value)) { - throw ORMException::entityMissingForeignAssignedId($entity, $value); - } - // NOTE: Single Columns as associated identifiers only allowed - this constraint it is enforced. - $value = current($em->getUnitOfWork()->getEntityIdentifier($value)); + $value = $em->getUnitOfWork()->getSingleIdentifierValue($value); } $identifier[$idField] = $value; diff --git a/lib/Doctrine/ORM/Utility/IdentifierFlattener.php b/lib/Doctrine/ORM/Utility/IdentifierFlattener.php index bb84c6151..d16da3255 100644 --- a/lib/Doctrine/ORM/Utility/IdentifierFlattener.php +++ b/lib/Doctrine/ORM/Utility/IdentifierFlattener.php @@ -76,7 +76,9 @@ final class IdentifierFlattener $class->associationMappings[$idField]['targetEntity'] ); - $associatedId = $this->unitOfWork->getEntityIdentifier($idValue); + $associatedId = $this->unitOfWork->isInIdentityMap($idValue) + ? $this->unitOfWork->getEntityIdentifier($idValue) + : $targetClassMetadata->getIdentifierValues($idValue); $flatId[$idField] = $associatedId[$targetClassMetadata->identifier[0]]; } else {