GlobalObjects
|
Transactions are provided in order to be able to perform several actions in the object database in a closed loop. If a number of operations in the object database are combined in one transaction, these can all be undone, for example, in the event of an error, by terminating the transaction. To do this, the operations in a transaction are kept in a transaction buffer until confirmation or termination, and are not stored immediately.
For the instance that started the transaction, the status of the object database is as if the object(s) had already been saved or deleted. Meanwhile, in multi-user mode, the object(s) from the object database is still valid for the other instances (clients of the GloServer).
Nested transactions are supported. Nested means here that another transaction can be initiated during a transaction. If this further transaction is cancelled, the system only rolls back to the last "start" of a transaction. All previous and further actions are executed when the transaction is "confirmed". This allows transactions to be encapsulated in units and used transparently in further transactions.
Examples:
Base.beginTransaction() >> Obj_ A->store() >> Base.beginTransaction() >> Obj_B->store() >> Base.abortTransaction() >> Base.commitTransaction()
Result: Only Obj_A is stored.
Base.beginTransaction() >> Obj_ A->store() >> Base.beginTransaction() >> Obj_B->store() >> Base.commitTransaction() >> Base.abortTransaction()
Result: No object is stored.
Base.beginTransaction() >> Obj_ A->store() >> Base.beginTransaction() >> Obj_B->store() >> Base.commitTransaction() >> Base.commitTransaction()
Result: Obj_A and Obj_B are stored.
The start of a transaction can be initiated with glo::Base::beginTransaction(). Object database operations such as glo::BasePersistent::store (...) and glo::BasePersistent::deleteInBase (...) are not executed in the object database, but are kept in the transaction buffer.
A transaction can be confirmed via glo::Base::commitTransaction(). This means that all actions in the object database such as glo::BasePersistent::store (...) and glo::BasePersistent::deleteInBase (...) which have been initiated since the last start of the transaction are executed and then removed from the transaction buffer.
A transaction can be aborted via glo::Base::abortTransaction(). This means that all actions in the object database such as glo::BasePersistent::store (...) and glo::BasePersistent::deleteInBase (...) which have been initiated since the last start of the transaction are removed from the transaction buffer, i.e. not executed.