public function flush($entity = null)
    {
        try{
            return $this->entityManager->flush($entity);
        } catch(ORMException $e) {
            if (!$this->entityManager->isOpen()) {
                $this->resetEntityManager();
            }
            throw $e;
        }
    }
public function flush($entity = null)
    {
        try{
            return $this->entityManager->flush($entity);
        } catch(ORMException $e) {
            if (!$this->entityManager->isOpen()) {
                $this->resetEntityManager();
            }
            throw $e;
        }
    }
public function flush ( $ entity = null ) { try { return $ this -> entityManager -> flush ( $ entity ) ; } catch ( ORMException $ e ) { if ( ! $ this -> entityManager -> isOpen ( ) ) { $ this -> resetEntityManager ( ) ; } throw $ e ; } }
Flushes all changes to objects that have been queued up to now to the database.
This effectively synchronizes the in-memory state of managed objects with the
database.

If an entity is explicitly passed to this method only this entity and
the cascade-persist semantics + scheduled inserts/removals are synchronized.

@param null|object|array $entity

@return void

@throws \Doctrine\ORM\OptimisticLockException If a version check on an entity that
makes use of optimistic locking fails.
Flushes all changes to objects that have been queued up to now to the database . This effectively synchronizes the in - memory state of managed objects with the database .