db_comitTransactions in DBAccess are handled using a class method on DBTransaction, transactions can be started from anywhere at anytime, are entirely thread-safe. Any modifications to records that are due to event triggers being raised are also included within the transaction and rolled back on failure.

The DBTransaction class has a single method,

+ (void)transaction:(DBTransactionBlockBlock)transaction withRollback:(DBTransactionBlockBlock)rollback;.

A transaction is setup, and the block is then executed with any objects which have their persistence altered being committed within a single operation. If ANY one individual update/insert/delete fails, then the transaction is aborted and rolled back, and the rollback block is then executed.


[DBTransaction transaction:^{

	for (Person* p in [[Person query] fetch]) {
		[p remove];

} withRollback:^{

	NSLog(@"Transaction Failed");