transaction

abstract fun <T> transaction(definition: TransactionDefinition, block: () -> T): T

Runs block with a transaction open, committing when it returns and rolling back when it throws. Every execute from this thread while block runs lands on the transaction's session; work handed to another thread does not.

A failure turned into a value inside block is not a throw, so the transaction commits over it; transactionResult turns a returned failure back into one.