Details
-
Task
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
Just identified a use case where Cayenne transaction management API falls short.
DFLib JDBCConnector allows manual transaction management. I am using Cayenne with DFLib for a multi-step data transformation process, with multiple commits within a transaction. Cayenne queries should be able to include intermediate results flushed to DB (but still not committed), so they need to run over the same Connection.
I was able to implement a custom solution that required wrapping both DataSource and Transaction in custom classes. I think we can simplify this for the end users. Some ideas:
- add the ability to pass an explicit DataSource (and/or Connection) to TransactionDescriptor. Expand ServerRuntime.performInTransaction(..) to take TransactionDescriptor (just like TransactionManager does).
- allow TransactionListener to provide its own connection, both in "willAddConnection" (so it can wrap passed connection), or in a separate new method that would allow to provide own Connection before Cayenne checks out one from its own DataSource.