I have a @Transactional annotation in all my DAOs, but I can only define one TransactionManager that accepts only one SessionFactory. I have one SessionFactory for each client, one DataSource for each client and apparently I need to change the TransactionManager for each client. But how can I get the correct transaction manager for the client when I can only define one Spring bean name for one TransactionManager?
Spring 3 , @Transactional delimitation
http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/transaction.html#tx-multiple-tx-mgrs-with-attransactional
, ?
, Spring , , . , , DAO , TransactionTemplate, .
TransactionTemplate
, , JTA, Spring JtaTransactionManager. , Spring API. , DataSources SessionFactories . , DataSources , , , .
JtaTransactionManager
PlatformTransactionManager, . , , ThreadLocal.
PlatformTransactionManager
ThreadLocal