Closed johnlcox closed 5 years ago
As I've thought about this more I'm less sure one what this class should be named. The javadoc on it must make clear that it's tied to the @JooqTransactional
ThreadLocal
transaction management.
Answers to some of the questions:
Fixed by #140
In order to do things like caching of query/insertion results deep within a chain of nested transactions, it would be helpful to have some sort of callback mechanic that would trigger when the root/top-level transaction is committed.
Some possible classes that could be created to help facilitate this:
TransactionCommitHooks
- Could have a register method that nested transactional code could register lambda expressions with to be executed when the top-level commit is completed. Probably would useThreadLocal
for this sinceThreadLocal
is already used forDslContextProviderImpl
.DslContextProviderImpl
to call the proper set of registered hooks when the unit of work is ended.Should the hooks fire for rollback? Maybe the lambda takes a bool parameter that says whether it was successful or not? Alternatively, maybe there is a separate success/failure callback? What about nested savepoint commit callbacks? Is there value to having callbacks for all the different levels and some sort of indicator whether it's nested or root?
References: django uses a callback function to handle performing tasks after commit, https://docs.djangoproject.com/en/2.1/topics/db/transactions/#performing-actions-after-commit