mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Identity through foreign Entities - persist #5261
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Gorjunov on GitHub (Sep 19, 2016).
Originally assigned to: @lcobucci on GitHub.
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 getDoctrine\ORM\ORMInvalidArgumentException: The given entity of type ‘Address' (Address@0000000055b6ca6a000000001effbba7) has no identity/no id values set. It cannot be added to the identity mapIs 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\AssignedGeneratorby adding:This change has fixed my problem, but I'm afraid, that AssignedGenerator change is bad idea.