Exposed icon indicating copy to clipboard operation
Exposed copied to clipboard

Implement Propagation for nested transaction

Open Tapac opened this issue 6 years ago • 2 comments

Something similar to https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/transaction/annotation/Propagation.html

Tapac avatar Jul 24 '19 20:07 Tapac

@Tapac is there a way to ...

  1. suspend the current transaction
  2. create a new transaction -> (force) commit the new transaction
  3. 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 :)

bastman avatar Aug 22 '19 15:08 bastman

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.

nimanakov avatar Jan 06 '23 17:01 nimanakov