diff --git a/lib/Doctrine/ODM/MongoDB/Proxy/ProxyFactory.php b/lib/Doctrine/ODM/MongoDB/Proxy/ProxyFactory.php
index ef2bc9190..145edaf53 100644
--- a/lib/Doctrine/ODM/MongoDB/Proxy/ProxyFactory.php
+++ b/lib/Doctrine/ODM/MongoDB/Proxy/ProxyFactory.php
@@ -17,7 +17,6 @@
use Symfony\Component\VarExporter\ProxyHelper;
use function array_combine;
-use function array_flip;
use function bin2hex;
use function chmod;
use function class_exists;
@@ -177,7 +176,7 @@ protected function skipClass(ClassMetadata $metadata): bool
private function createLazyInitializer(ClassMetadata $classMetadata, DocumentPersister $persister): Closure
{
return static function (InternalProxy $proxy, mixed $identifier) use ($persister, $classMetadata): void {
- $original = $persister->load(['_id' => $identifier]);
+ $original = $persister->load([$classMetadata->identifier => $identifier]);
if ($original === null) {
throw DocumentNotFoundException::documentNotFound(
@@ -214,7 +213,6 @@ private function getProxyFactory(string $className): Closure
{
$skippedProperties = [];
$class = $this->dm->getClassMetadata($className);
- $identifiers = array_flip($class->getIdentifierFieldNames());
$filter = ReflectionProperty::IS_PUBLIC | ReflectionProperty::IS_PROTECTED | ReflectionProperty::IS_PRIVATE;
$reflector = $class->getReflectionClass();
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index d438ddf75..0363b8b0b 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -164,6 +164,9 @@
+
+ identifier => $identifier]]]>
+