Working on zend framework 2 with doctrine 2.
While unit testing, I use a 'testing database' to add, edit and delete values from.
The issue was that I add a new entity, ok. After I add the new entity, witch works perfecty, i tried to Update the entity.
//set all values
$this->getEntityManager->persist($dataEntity);
$this->getEntityManager->flush()
When I Try to retrieve the updated data using:
$produtoAcessorioCompareEntity = $this->getEntityManager()->getRepository('Administrador\Entity\ProdutoAcessorio')->findOneBy(array(
'idProdutoAcessorio' => $produtoAcessorioEntity->getIdProdutoAcessorio()
));
But this cached the old data from ADD Method and not updated the data for the new Entity $produtoAcessorioCompareEntity, I got the old values.
When I check the database, the new values are there. So should have one trick to reorganize loaded entities that I'm probably missing.
How can I update the Working Entities After Persist and Flush, to get the new values by $this->getEntityManager->getRepository() instead open a new connection?