Reputation: 29912
This snippet of code is driving me crazy.
Suppose that entity on which I've done all this operation have all the members that I recall with getters (either on db that on class file; moreover, onto db, all values were inserted).
$this->logger->debug('INV ROOM RATES CAPACITY - $ROOM ID: '.$camera->getId());
$this->logger->debug('INV ROOM RATES CAPACITY - $ROOMCAPACITY: .$camera->getCapienza());
$this->logger->debug('INV ROOM RATES CAPACITY - CAMERA DB ID: '.$camera->getId());
This outputs the following
[2013-02-11 14:17:32] app.DEBUG: INV ROOM RATES CAPACITY - $ROOM ID: 14 [] []
[2013-02-11 14:17:32] app.DEBUG: INV ROOM RATES CAPACITY - $ROOMCAPACITY: [] []
[2013-02-11 14:17:32] app.DEBUG: INV ROOM RATES CAPACITY - CAMERA DB ID: [] []
It seems that ->getCapienza()
method is messing all the things up (second getter on the same object, doesn't return previous value).
Obviously, no error or exceptions are raised.
What's going on here? Any ideas? I'm stuck since hours ....
public function getCapienza()
{
return $this->capienza;
}
Upvotes: 1
Views: 80
Reputation: 25431
Since you just told me that you are clearing the EntityManager sometimes, I digged into it a bit further.
It is a known issue that will be fixed in Doctrine ORM 2.4 when https://github.com/doctrine/doctrine2/pull/406 is merged.
The issue happens because of following piece of code: https://github.com/doctrine/doctrine2/blob/2.3.2/lib/Doctrine/ORM/UnitOfWork.php#L1724-L1780
Basically, it is impossible to merge or generally use proxies that are detached from an EntityManager (you should have lazy-loaded them before).
The problem you are experiencing is related with http://www.doctrine-project.org/jira/browse/DDC-1734
A temporary solution is to re-fetch the data you want to use instead of recycling detached instances.
Upvotes: 1