company logo

Transaction buffer

A transaction buffer is used for storing a limited number of database entries (instances and indexes) in a transaction in order to improve performance. Typically, update transactions are used in copy processes, where instances or indexes are accessed several times.

Transaction buffers are started as pool transactions with a maximum number of database entries. When the maximum number of database entries is reached, the transaction buffer is emptied, i.e. transactions are written to database. One may rollback an update transaction, but this does not make much sense, since one never knows to which extent database entries have already been written to the database.

... fragment ( Property &source, Property &target ) {

  // transaction buffer with maximum 500 database entries

  target.objectSpace().beginTransaction(500);

try {  

  target.copyCollection(source);

  target.objectSpace().commitTransaction();

catch (...) {

  target.objectSpace().rollBack(); // error encountered

}

}