src/ResetableEntityManager.php
public function merge($entity)
    {
        try{
            return $this->entityManager->merge($entity);
        } catch(ORMException $e) {
            if (!$this->entityManager->isOpen()) {
                $this->resetEntityManager();
            }
            throw $e;
        }
    }
public function merge($entity)
    {
        try{
            return $this->entityManager->merge($entity);
        } catch(ORMException $e) {
            if (!$this->entityManager->isOpen()) {
                $this->resetEntityManager();
            }
            throw $e;
        }
    }
Merges the state of a detached entity into the persistence context
of this EntityManager and returns the managed copy of the entity.
The entity passed to merge will not become associated/managed with this EntityManager.

@param object $entity The detached entity to merge into the persistence context.

@return object The managed copy of the entity.

@throws ORMInvalidArgumentException