[DDC-446] Cached resultset do not add Entities in UnitOfWork Created: 19/Mar/10  Updated: 30/Oct/11  Resolved: 30/Oct/11

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: 2.2
Security Level: All

Type: Improvement Priority: Major
Reporter: Guilherme Blanco Assignee: Roman S. Borschel
Resolution: Fixed Votes: 1
Labels: None

Attachments: File DDC446Test.php    
Issue Links:
relates to DDC-217 Result cache should cache the SQL res... Resolved


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

Comment by Roman S. Borschel [ 20/Mar/10 ]

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.

Comment by Guilherme Blanco [ 20/Mar/10 ]

Test case attached.

This is a situation where it should work smoothly IMHO.

Comment by Roman S. Borschel [ 20/Mar/10 ]

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.

Comment by Roman S. Borschel [ 20/Mar/10 ]

You need to understand the difference between managed and detached. Its very important.

Comment by Guilherme Blanco [ 20/Mar/10 ]

Adding merge doesn't work too.... same error.

Juyst add $this->_em->merge($user); in line 52.

Comment by Roman S. Borschel [ 20/Mar/10 ]

Of course it wouldnt because thats not how merge works. Merge returns a managed copy.

So you would do:

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



Comment by Roman S. Borschel [ 20/Mar/10 ]


Comment by Benjamin Eberlei [ 30/Oct/11 ]

Implemented through DDC-217

Generated at Tue Dec 01 04:32:28 EST 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.