Open herenickname opened 3 years ago
Hi @ekifox, can you provide a minimal sample repo?
Hi @ekifox / @cassinaooo - Sorry for the late response. I missed this one.
Basically, the runOnTransactionRollback()
and all the other Hooks, are informal only, and cannot be used to do database operations with the same repository.
I believe an external try/catch should be used instead
@odavid so, how can I can solve my case? I need to save information to database when the all transaction has failed.
@ekifox - As I said, the solution for that is to use an external (in the Transactional context) to call the transactional method with a try/catch
block
In the catch block you can call the repository.save()
I have a
@Transactional()
function withrunOnTransactionRollback(() => this.someRepository.save())
in it. So, when the function caught error and rejects with rollback, thethis.someRepository.save()
have called and then I receive the QueryRunnerAlreadyReleasedError error.