Transactions
Transactions
Transaction callbacks
To perform a bunch of operations in a transaction, use TransactionCallback or VoidTransactionCallback:
db.withTransaction(tx -> {
// transactional operations
...
return result;
});
db.withVoidTransaction(tx -> {
// transactional operations
...
});
Optionally, you can also pass Isolation or Propagation for these calls.
External transaction manager
If you are using Spring Framework, Dalesbred can integrate with Spring's transaction manager. Consult the Spring section for details.
Implicit transactions
If you make calls to Database without an explicit transaction, by default a new transaction is started for each call. You can disallow this: in this case exceptions are thrown for calls without an active transaction:
Nested transactions
Nested transactions are supported if your database supports them: