Thanks in advance for your help.
I\'m wondering if anyone quickly knows what functions to call on the Entity Repository to jog its reconnection if it is dead. I am
This is a fairly common problem with long running processes and connections.
The solution is to retrieve the ORM's DBAL connection and re-create it if the connection was lost (ensuring it didn't die during a transaction). This is obviously annoying, but it's the only way of doing it right now:
// note - you need a ServiceManager here, not just a generic service locator
$entityMAnager = $serviceManager->get('entity_manager');
$connection = $entityManager->getConnection();
try {
// dummy query
$connection->query('SELECT 1');
} catch (\Doctrine\DBAL\DBALException $e) {
if ($connection->getTransactionIsolation()) {
// failed in the middle of a transaction - this is serious!
throw $e;
}
// force instantiation of a new entity manager
$entityManager = $serviceManager->create('entity_manager');
}
$this->doFoo($entityManager);