Either set the "shared" flag to `false`, or pass a factory down to your service:
$myService = new MyService(function () use ($sm) { return $sm->createService('Doctrine\ORM\EntityManager'); }); This saves you from having the SM bound to your service, and allows you to use the callback as a "smart constructor" Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On 21 January 2014 17:25, Bas Kamer <baska...@me.com> wrote: > Hello, > > > reading > http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/transactions-and-concurrency.html#exception-handling > > Ok Fine... With a closed entity manager I should get a new entity manager > if i want to work continue doing queries... > > What would be a good strategy to do that with the context of zf2 when the > EM is injected via factories. > > About the only thing I can think of is setting the shared flag of the > entity manager to false… This doen’t seem efficient as that would > (re)create connections not for the exception case but always. > > Intend use is long running background processes - in which a closed entity > manager really helpful > > > Bas