/**
  * Commits the current transaction, writing any unflushed changes to the database.
  * If the commit fails, the running transaction is rolled back.
  *
  * @throws Doctrine\DBAL\ConnectionException If the commit failed due to no active transaction or
  *         because the transaction was marked for rollback only.
  * @throws Doctrine\ORM\OptimisticLockException If a version check on an entity that
  *         makes use of optimistic locking fails.
  */
 public function commit()
 {
     try {
         $this->_em->flush();
         $this->_conn->commit();
     } catch (Exception $e) {
         $this->rollback();
         throw $e;
     }
 }