mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-2909: different entity state after flush() #3624
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 @doctrinebot on GitHub (Jan 12, 2014).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user jack88:
Example 1:
I add a new address to the repository and remove it before flush
Output:
Address entity state before remove:1 (MANAGED)
Address entity state after remove:2 (NEW)
Address entity state after flush:2 (NEW)
everything ok, new address entity was not stored and has the state NEW
Example 2:
now i add the address entity to the user entity (the addresses-property in user entity has cascade={"persist"})
I change a line
Output:
Address entity state before remove:1 (MANAGED)
Address entity state after remove:2 (NEW)
Address entity state after flush:1 (MANAGED)
Oops, my removed address is after flush() stored and managed?
I think I know what happened, but I do not think that's right. If I check the state of an entity before flush and the entity is in NEW state than i think it will not be stored.
"An entity is in NEW state if has no persistent state and identity and is not associated with an EntityManager"
My User & Address code:
@doctrinebot commented on GitHub (Mar 23, 2014):
Comment created by @beberlei:
This is because you cascade persist. The feature is called "persist by reachability", which propagates managed state to related entities when cascade=persist is configured. Which it is in your case.
@doctrinebot commented on GitHub (Mar 23, 2014):
Issue was closed with resolution "Invalid"