mirror of
https://github.com/doctrine/orm.git
synced 2026-04-27 00:18:04 +02:00
DDC-446: Cached resultset do not add Entities in UnitOfWork #559
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 (Mar 19, 2010).
Jira issue originally created by user @guilhermeblanco:
When using resultset cache, when you fetch for these object and attempt to manipulate them, they fail to work giving this message:
@doctrinebot commented on GitHub (Mar 19, 2010):
@doctrinebot commented on GitHub (Mar 20, 2010):
Comment created by romanb:
Objects coming from the result cache are all detached. The EM does not care about them unless you merge() them. But there should probably be a better exception instead of this notice. Please show the code that causes the notice.
PS: Result caching objects is inefficient.
@doctrinebot commented on GitHub (Mar 20, 2010):
Comment created by @guilhermeblanco:
Test case attached.
This is a situation where it should work smoothly IMHO.
@doctrinebot commented on GitHub (Mar 20, 2010):
Comment created by romanb:
No, it should not work smoothly because $user is a detached object. It should throw an exception but the problem is that its hard to detect whether an object is detached in _doPersist.
@doctrinebot commented on GitHub (Mar 20, 2010):
Comment created by romanb:
You need to understand the difference between managed and detached. Its very important.
@doctrinebot commented on GitHub (Mar 20, 2010):
Comment created by @guilhermeblanco:
Adding merge doesn't work too.... same error.
Juyst add $this->_em->merge($user); in line 52.
@doctrinebot commented on GitHub (Mar 20, 2010):
Comment created by romanb:
Of course it wouldnt because thats not how merge works. Merge returns a managed copy.
So you would do:
@doctrinebot commented on GitHub (Mar 20, 2010):
Comment created by romanb:
http://www.doctrine-project.org/documentation/manual/2_0/en/working-with-objects:merging-entities
@doctrinebot commented on GitHub (Oct 30, 2011):
Comment created by @beberlei:
Implemented through DDC-217
@doctrinebot commented on GitHub (Oct 30, 2011):
Issue was closed with resolution "Fixed"
@doctrinebot commented on GitHub (Dec 13, 2015):
Imported 1 attachments from Jira into https://gist.github.com/366b6e5648140b32bc27