Jira issue originally created by user mrkanister:
(I'm using doctrine 2.1.4.)
I'm trying to merge an Entity back to the UnitOfWork.
The Entity is created from a serialized object (The deserialzed Entity is a valid Entity Object. The only difference
is that it is not managed by Doctrine yet) and I'm using the merge
method of the EntityManager to get it in managed state again.
This results in a call of the Method doMerge() in the UnitOfWork
This method takes the id of my deserialized Entity, that I want to
merge, and looks if an Entity with that id is already in doctrine
cache. If that is the case my deserialized Entity is merged with the
one in the cache. So far so good. But I've got the Problem, that the
Entity, which is in cache, is not initialized yet. It is not initialized because
this Entity has a relation to another Entity that a used earlier in code.
It's there but in uninitialized stat, because I did not access it yet.
So when my deserialized Entity and the one from cache gets merged, some field are
uninitialized (the id field, for example).
I fixed the problem by adding this piece of code in line 1446 in the
Comment created by @beberlei:
Fixed and merged into 2.2 and 2.1
Issue was closed with resolution "Fixed"