Well, I have a similar thing going on in the last application I worked on.
What about a singular transaction provider? You can instantiate it oncde
inside of your
Context/Runtime/ServiceRegistry/ServiceLocator/WhatEverSingletonAbstractionYouLike.
Or you inject it as a dependency. This provider Interface gives you the
possibilities of starting and committing transactions. Whether it is the
same transactions or nested ones remains then a minor implementation
detail provided by your persistence layers.
BTW, in this app all the semantical user transaction (interactions by
utilizing Interactors) where automatically wrapped in a transaction from
this provider. We could push thousands of requests per second with a
single database server without performance implications. That lead me to
the conclusion, that defaulting to transactions per default is probably
(depending on the system and its runtime context and environment) a good
thing which safes you from different kinds of headaches!
WDYT?
Cheers
--
Jakob Holderbaum, M.Sc.
Systems Engineer
0176 637 297 71
http://jakob.io/
http://jakob.io/mentoring/
h...@jakob.io
@hldrbm