diff --git a/src/Mapper/Dbal/Conventions/Conventions.php b/src/Mapper/Dbal/Conventions/Conventions.php index c7f30a95..d4514a51 100644 --- a/src/Mapper/Dbal/Conventions/Conventions.php +++ b/src/Mapper/Dbal/Conventions/Conventions.php @@ -389,6 +389,10 @@ protected function getDefaultMappings(): array $subMetadata = $property->args[EmbeddableContainer::class]['metadata']; assert($subMetadata instanceof EntityMetadata); + if ($property->isPrimary) { + unset($entityPrimaryKey[array_search($property->name, $entityPrimaryKey, true)]); + } + $baseTokens = $tokens; $baseTokens[] = $property->name; @@ -405,6 +409,10 @@ protected function getDefaultMappings(): array }, $propertyTokens), ); + if ($property->isPrimary) { + $entityPrimaryKey[] = $propertyKey; + } + $mappings[self::TO_ENTITY][$storageKey] = [$propertyKey]; $mappings[self::TO_STORAGE][$propertyKey] = [$storageKey]; $mappings[self::TO_STORAGE_FLATTENING][$propertyKey] = $propertyTokens; diff --git a/src/Repository/IdentityMap.php b/src/Repository/IdentityMap.php index 65fe5a1b..e421fdad 100644 --- a/src/Repository/IdentityMap.php +++ b/src/Repository/IdentityMap.php @@ -199,7 +199,7 @@ protected function getIdHash($id): string function ($id): string { return $id instanceof DateTimeImmutable ? $id->format('c.u') - : (string) $id; + : (is_array($id) ? $this->getIdHash($id) : (string) $id); }, $id )