devloop icon
Metastores

Explicit transactions

Although the framework supports automatic transaction boundaries for objects trees, it is also possible to specify object transactions explicitly using the ObjectTransactionGroup class.

In this example we group a series of Object I/O operations in a single transaction:


	ObjectTransactionGroup otg = new ObjectTransactionGroup();
	otg.insert(new User("username"));
	otg.update(otherObject);
	otg.insert(new Role("rolename"));
	otg.execute();
   
This sample code is taken from a JUnit test

Please note that although the objects are in the same Object I/O group, they may end up being in separate Storage I/O groups depending on TransactionMode defined for each type. Also, object triggers (cascade) will still apply and may cause other objects to be saved.
For more information on transaction processing, see the extensive transaction documentation.