src/ResetableEntityManager.php
public function persist($entity)
    {
        try{
            return $this->entityManager->persist($entity);
        } catch(ORMException $e) {
            if (!$this->entityManager->isOpen()) {
                $this->resetEntityManager();
            }
            throw $e;
        }
    }
public function persist($entity)
    {
        try{
            return $this->entityManager->persist($entity);
        } catch(ORMException $e) {
            if (!$this->entityManager->isOpen()) {
                $this->resetEntityManager();
            }
            throw $e;
        }
    }
Tells the EntityManager to make an instance managed and persistent.

The entity will be entered into the database at or before transaction
commit or as a result of the flush operation.

NOTE: The persist operation always considers entities that are not yet known to
this EntityManager as NEW. Do not pass detached entities to the persist operation.

@param object $entity The instance to make managed and persistent.

@return void

@throws ORMInvalidArgumentException