Begin transaction.

Begins an transaction, make sure you'll call commit or rollback when done,
otherwise work will be lost.
968485
public function beginTransaction()
    {
        $return = $this->repository->beginTransaction();

        if ($this->signalDispatcher instanceof TransactionHandler) {
            $this->signalDispatcher->beginTransaction();
        }

        return $return;
    }
664301
@Override
	public AppEngineTransaction beginTransaction() {
		if (isTransactional()) {
			throw new IllegalStateException("Transaction has already started ["
					+ transaction.get().id() + "]");
		}
		
		AppEngineTransaction tx = new AppEngineTransaction(this);
		transaction.set(tx);
		logger.fine("Transaction [" + transaction.get().id() + "] started");
		return tx;
	}
685234
def _process(self, on_commit: UpdateCallable, on_rollback: UpdateCallable) -> Any:
        

        _debug("---> commiting", on_commit)
        result = self._do_with_retry(on_commit)

        if len(self._transactions) > 0:
            # add statement to rollback log in case something goes wrong
            self._transactions[-1].insert(0, on_rollback)

        return result
786032
@Override
  public void start()
  {
    LOGGER.debug("Start Loading");
    // validate parameters
    validateParameters();

    if (_op == null)
    {
      this.abort(new ConnectionError("Loader started with no operation"));
      return;
    }

    initDateFormats();

    initQueues();

    if (_is_first_start_call)
    {
      // is this the first start call?

      try
      {
        if (_startTransaction)
        {
          LOGGER.debug("Begin Transaction");
          _processConn.createStatement().execute("begin transaction");
        }
        else
        {
          LOGGER.debug("No Transaction started");
        }
      }
      catch (SQLException ex)
      {
        abort(new Loader.ConnectionError("Failed to start Transaction",
                                         Utils.getCause(ex)));
      }

      if (_truncate)
      {
        truncateTargetTable();
      }

      try
      {
        if (_before != null)
        {
          LOGGER.debug("Running Execute Before SQL");
          _processConn.createStatement().execute(_before);
        }
      }
      catch (SQLException ex)
      {
        abort(new Loader.ConnectionError(
            String.format("Execute Before SQL failed to run: %s", _before),
            Utils.getCause(ex)));
      }
    }
  }
716080
def commit_transaction(self):
        
        self._check_ended()
        retry = False
        state = self._transaction.state
        if state is _TxnState.NONE:
            raise InvalidOperation("No transaction started")
        elif state in (_TxnState.STARTING, _TxnState.COMMITTED_EMPTY):
            # Server transaction was never started, no need to send a command.
            self._transaction.state = _TxnState.COMMITTED_EMPTY
            return
        elif state is _TxnState.ABORTED:
            raise InvalidOperation(
                "Cannot call commitTransaction after calling abortTransaction")
        elif state is _TxnState.COMMITTED:
            # We're explicitly retrying the commit, move the state back to
            # "in progress" so that _in_transaction returns true.
            self._transaction.state = _TxnState.IN_PROGRESS
            retry = True

        try:
            self._finish_transaction_with_retry("commitTransaction", retry)
        except ConnectionFailure as exc:
            # We do not know if the commit was successfully applied on the
            # server or if it satisfied the provided write concern, set the
            # unknown commit error label.
            exc._remove_error_label("TransientTransactionError")
            _reraise_with_unknown_commit(exc)
        except WTimeoutError as exc:
            # We do not know if the commit has satisfied the provided write
            # concern, add the unknown commit error label.
            _reraise_with_unknown_commit(exc)
        except OperationFailure as exc:
            if exc.code not in _UNKNOWN_COMMIT_ERROR_CODES:
                # The server reports errorLabels in the case.
                raise
            # We do not know if the commit was successfully applied on the
            # server or if it satisfied the provided write concern, set the
            # unknown commit error label.
            _reraise_with_unknown_commit(exc)
        finally:
            self._transaction.state = _TxnState.COMMITTED
490480
public static function beginTransaction()
    {
        if (static::inTransaction()) {
            throw new PDOException();
        }

        static::inTransaction(true);

        $transaction = static::makeTransaction(static::countTransactions());

        static::addTransaction($transaction);
    }
1228083
public function beginTransaction() {
        ++$this->transactions;

        if ($this->transactions == 1) {
            $this->transaction = $this->orient->beginTransaction();
        }

        $this->fireConnectionEvent('beganTransaction');
    }
451245
def begin(self):
        
        conn = yield self._get_conn()
        try:
            yield conn.begin()
        except:
            self._close_conn(conn)
            raise
        trx = Transaction(self, conn)
        raise Return(trx)
73224
@Override
    public void begin()
    {
        if (isActive())
        {
            throw new IllegalStateException("Transaction is already active");
        }
        else
        {
            this.coordinator = ((EntityManagerImpl) entityManager).getPersistenceDelegator().getCoordinator();
            ((EntityManagerImpl) entityManager).getPersistenceDelegator().begin(); // transaction
                                                                                   // de-marcation.
            this.coordinator.coordinate(TxAction.BEGIN);
        }
    }
1309114
def _ExecuteTransaction(self, transaction):
    """"""

    def Action(connection):
      connection.cursor.execute("START TRANSACTION")
      for query in transaction:
        connection.cursor.execute(query["query"], query["args"])
      connection.cursor.execute("COMMIT")
      return connection.cursor.fetchall()

    return self._RetryWrapper(Action)
163664
def begin(self, close=True, expire_on_commit=False, session=None,
              commit=False, **options):
        
        if not session:
            commit = True
            session = self.session(expire_on_commit=expire_on_commit,
                                   **options)
        else:
            close = False
        try:
            yield session
            if commit:
                session.commit()
        except Exception:
            session.rollback()
            raise
        finally:
            if close:
                session.close()
315388
public function beginDatabaseTransaction()
    {
        $database = $this->app->make('db');

        foreach ($this->connectionsToTransact() as $name) {
            $connection = $database->connection($name);
            $dispatcher = $connection->getEventDispatcher();

            $connection->unsetEventDispatcher();
            $connection->beginTransaction();
            $connection->setEventDispatcher($dispatcher);
        }

        $this->beforeApplicationDestroyed(function () use ($database) {
            foreach ($this->connectionsToTransact() as $name) {
                $connection = $database->connection($name);
                $dispatcher = $connection->getEventDispatcher();

                $connection->unsetEventDispatcher();
                $connection->rollback();
                $connection->setEventDispatcher($dispatcher);
                $connection->disconnect();
            }
        });
    }
813465
public void commitTransaction() throws SystemException
   {
      Long key = Long.valueOf(Thread.currentThread().getId());
      TransactionImpl tx = txs.get(key);
      if (tx != null)
      {
         try
         {
            tx.commit();
         }
         catch (Throwable t)
         {
            SystemException se = new SystemException("Error during commit");
            se.initCause(t);
            throw se;
         }
      }
      else
      {
         throw new IllegalStateException("No transaction to commit");
      }
   }
969477
public function beginTransaction()
    {
        ++$this->transactions;

        if ($this->transactions == 1) {
            $this->pdo->beginTransaction();
        }

        $this->fireConnectionEvent('beganTransaction');
    }
561243
public function beginTransaction()
    {
        $return = true;
        $opcount = $this->getNestedTransactionCount();
        if ($opcount === 0) {
            $return = self::exec('BEGIN TRANSACTION');
            if ($this->useDebug) {
                $this->log('Begin transaction', null, __METHOD__);
            }
            $this->isUncommitable = false;
        }
        $this->nestedTransactionCount++;

        return $return;
    }
364302
public function beginTransaction()
    {
        if ($this->disableTransactionHandling) {
            return;
        }

        if (null !== $this->session) {
            throw new \RuntimeException('Transaction already started');
        }
        $this->session = $this->mongoClient->startSession();
        $this->session->startTransaction([
            'readConcern' => new \MongoDB\Driver\ReadConcern('snapshot'),
            'writeConcern' => new \MongoDB\Driver\WriteConcern(\MongoDB\Driver\WriteConcern::MAJORITY),
        ]);
    }
780662
def begin_transaction(self):
        """"""
        self.ensure_connected()
        self._transaction_nesting_level += 1
        if self._transaction_nesting_level == 1:
            self._driver.begin_transaction()
        elif self._nest_transactions_with_savepoints:
            self.create_savepoint(self._get_nested_transaction_savepoint_name())