Marco Pivetta wrote
> 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 <
> baskamer@
> > 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
What if i'm not have access to ServiceManager in program part, where
"EntityManager is Closed" error was occur?
Than i'm use this method
protected function checkEMConnection()
{
if (!$this->getEntityManager()->isOpen()) {
$connection = $this->getEntityManager()->getConnection();
$config = $this->getEntityManager()->getConfiguration();
$this->em = $this->getEntityManager()->create(
$connection, $config
);
}
}
--
View this message in context:
http://zend-framework-community.634137.n4.nabble.com/Doctrine-Closed-Entity-Manager-tp4661505p4662172.html
Sent from the Zend Framework mailing list archive at Nabble.com.
--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]