Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restarting the Entity Manager from Exception

How do I reset/restart a Entity Manager?

Looking at Doctrines docs:

  • http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/transactions-and-concurrency.html#approach-2-explicitly

I see that on an exception the Entity Manager closes. This is a problem for me as I have a RabbitMQ Server and the consumer(s) are always running. Durring testing we are mocking different scenarios and missing data was one of them. Well this caused and exception as it should and our Try/Catch logic worked just fine except it also closed the Entity Manager.

Reading other threads where they are having or have had the same or related issue, I've not seen a clear way to restart the EM.

Any thoughts?

Related:

  • https://github.com/symfony/symfony/issues/5339
  • Doctrine's entity manager crashes and stays down
like image 451
Phill Pafford Avatar asked Jan 08 '13 04:01

Phill Pafford


1 Answers

Have you tried calling the resetEntityManager method as suggested by stof? https://github.com/doctrine/DoctrineBundle/blob/master/Registry.php#L83

like image 112
Thierry Marianne Avatar answered Nov 06 '22 13:11

Thierry Marianne