Exposed
Exposed copied to clipboard
Implement Propagation for nested transaction
Something similar to https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/transaction/annotation/Propagation.html
@Tapac is there a way to ...
- suspend the current transaction
- create a new transaction -> (force) commit the new transaction
- resume the initial transaction
Currently, I struggle with that. It might be similar the spring TransactionPropagation.REQUIRES_NEW .
My current use case (pseudo code) ...
fun handle() {
outer= transaction.start()
Try {
outer.exec(some sql)
Try {
inner = transaction.start()
inner.exec(sql)
inner.commit()
}
}
.onSuccess() { outer.commit() }
.onFailure() { outer.rollback() } // outer: rollback, but inner should be commited.
}
Thanks a lot for your help :)
I was trying to commit nested transaction with set up useNestedTransactions == true for Database but that did not work. This indeed is nice to have feature.