Inherited @Transactional methods should be able to use class-level TransactionManager qualifier from concrete class #24291
Description
Setup: In a multi-DB environment, there is an abstract Service/DAO class with @Transactional
methods common to all entities from all DBs. Then there are multiple concrete Service/DAO beans, one per DB, each with specific transactionManager in the class-level @Transactional
annotation.
Problem: When calling a base-class method via some DB-specific bean, a wrong transactionManager is used (always the @Primary
one). The worst is that no exceptions are thrown, no error messages printed in log. The entities are simply silently e.g. not saved/updated in DB. Or, I afraid, they could even be saved to wrong DB.
The problem has already been described at least in #14011, #14295, #17080. Related issue is also #11839. But all the issues have been closed (as outdated) without a solution.
There were also some workarounds: https://stackoverflow.com/questions/51087660/dynamic-selection-of-transactionmanager-spring-boot, https://www.tirasa.net/en/blog/dynamic-springs-at-transactional, also #14295. But they all are not working (anymore).
How can it be solved? What do you, guys, do in such situation? Am I missing something obvious?
Thank you for your thoughts.
Activity