The EntityManager is closed

前端 未结 17 1767
星月不相逢
星月不相逢 2020-11-29 18:36
[Doctrine\\ORM\\ORMException]   
The EntityManager is closed.  

After I get a DBAL exception when inserting data, EntityManager closes and I\'m not

17条回答
  •  被撕碎了的回忆
    2020-11-29 18:52

    My solution.

    Before doing anything check:

    if (!$this->entityManager->isOpen()) {
        $this->entityManager = $this->entityManager->create(
            $this->entityManager->getConnection(),
            $this->entityManager->getConfiguration()
        );
    }
    

    All entities will be saved. But it is handy for particular class or some cases. If you have some services with injected entitymanager, it still be closed.

提交回复
热议问题