Description
I try to implement schema from http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/tutorials/composite-primary-keys.html#use-case-2-simple-derived-identity (OneToOne relation between models and second model's primary key is also foreign key to first model)
When I try to create both entities at same time and persist them ($entityManager->persist($address)
) I get Doctrine\ORM\ORMInvalidArgumentException: The given entity of type ‘Address' (Address@0000000055b6ca6a000000001effbba7) has no identity/no id values set. It cannot be added to the identity map
Is there any solution (except saving User, adding it to address and then saving address) to realize it.
P.S.
I've tried to change Doctrine\ORM\Id\AssignedGenerator
by adding:
public function isPostInsertGenerator()
{
return true;
}
This change has fixed my problem, but I'm afraid, that AssignedGenerator change is bad idea.