The transaction mechanism for working with BimRv database content keeps the database consistent
and manages concurrent requests for data modifications (add, delete, and edit operations).
All modifications are either all applied to the data or all cancelled.
Such an approach helps to switch the database from one consistent state to another consistent state without risking data
corruption because of one or several modification operations failing.
To work with transactions, follow the workflow described below:
Start a new transaction.
Make appropriate data modifications.
Commit the transaction to apply data modifications to the database, if the operations were successful.
A commit operation ends the transaction.
Rollback the transaction if one or more of data modification operations fail.
Like the commit, the rollback also ends the transaction but without pending any modifications.
Starting with version 20.6, BimRv SDK provides an explicit transaction mechanism for object modification.
The explicit transaction mechanism replaces the previously used implicit transaction mechanism.
Explicit mechanism advantages:
Access to the persistent database state at any moment.
Rollback mechanism.
Lower complexity of the debug process.
No issues with the switch of open modes for a BimRv database.
The explicit transaction mechanism assumes that any data modification operations can be invoked only after starting a transaction,
otherwise an exception is thrown.
The simplest way to handle transactions is to use the transaction block as in the following code fragment:
transaction_name.start(); — Starts a new transaction named "transaction_name".
transaction_name.commit(); — Commits all modifications made during the transaction.
transaction_name.rollback(); — Cancels all modifications made during the transaction.
Note that either the start() or rollback() method ends the transaction, therefore no more modifications
can be done unless you start a new transaction.