DDC-446: Cached resultset do not add Entities in UnitOfWork #559

Closed
opened 2026-01-22 12:42:29 +01:00 by admin · 11 comments
Owner

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:

Notice:  Undefined index: 000000006f95482300000000384dffac in /srv/app/library/Doctrine/ORM/UnitOfWork.php on line 1901
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: ``` Notice: Undefined index: 000000006f95482300000000384dffac in /srv/app/library/Doctrine/ORM/UnitOfWork.php on line 1901 ```
admin added the Improvement label 2026-01-22 12:42:29 +01:00
admin closed this issue 2026-01-22 12:42:29 +01:00
Author
Owner

@doctrinebot commented on GitHub (Mar 19, 2010):

@doctrinebot commented on GitHub (Mar 19, 2010): - relates to [DDC-217: Result cache should cache the SQL result and not the final objects](http://www.doctrine-project.org/jira/browse/DDC-217)
Author
Owner

@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 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.
Author
Owner

@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 @guilhermeblanco: Test case attached. This is a situation where it should work smoothly IMHO.
Author
Owner

@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: 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.
Author
Owner

@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 romanb: You need to understand the difference between managed and detached. Its very important.
Author
Owner

@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 @guilhermeblanco: Adding merge doesn't work too.... same error. Juyst add $this->_em->merge($user); in line 52.
Author
Owner

@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:

$managedUser = $this->_em->merge($user);

...

$article->setUser($managedUser);

...
@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: ``` $managedUser = $this->_em->merge($user); ... $article->setUser($managedUser); ... ```
Author
Owner

@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 (Mar 20, 2010): Comment created by romanb: http://www.doctrine-project.org/documentation/manual/2_0/en/working-with-objects:merging-entities
Author
Owner

@doctrinebot commented on GitHub (Oct 30, 2011):

Comment created by @beberlei:

Implemented through DDC-217

@doctrinebot commented on GitHub (Oct 30, 2011): Comment created by @beberlei: Implemented through [DDC-217](http://www.doctrine-project.org/jira/browse/DDC-217)
Author
Owner

@doctrinebot commented on GitHub (Oct 30, 2011):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Oct 30, 2011): Issue was closed with resolution "Fixed"
Author
Owner

@doctrinebot commented on GitHub (Dec 13, 2015):

Imported 1 attachments from Jira into https://gist.github.com/366b6e5648140b32bc27

@doctrinebot commented on GitHub (Dec 13, 2015): Imported 1 attachments from Jira into https://gist.github.com/366b6e5648140b32bc27 - [10508_DDC446Test.php](https://gist.github.com/366b6e5648140b32bc27#file-10508_DDC446Test-php)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#559