cerner / beadledom

A simple, composable framework for building RESTful services
http://engineering.cerner.com/beadledom
Apache License 2.0
25 stars 30 forks source link

Add a Post Commit Hook for Jooq Transactions #126

Closed johnlcox closed 5 years ago

johnlcox commented 5 years ago

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:

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

johnlcox commented 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:

johnlcox commented 5 years ago

Fixed by #140