Reputation: 55
I have an application that needs to access two databases. I am trying to use Spring transactions to accomplish this.
1) Since I have two databases and a transaction manager takes a datasource as a parameter, must I configure two transaction managers, with each @Transactional specifying the correct transaction manager to use? ex: @Transcational("database1"), @Transactional("database2").
2) Since @EnableTransactionManagement will look for a single transaction manager to use for all transactions, I do not think I can use this annotation. Is that the case? Can I still utilize transactions with @Transactional("database") and no @EnableTransactionManagement?
Upvotes: 3
Views: 1527
Reputation: 3257
Please look to the relevant documentation: http://docs.spring.io/spring-framework/docs/4.2.x/spring-framework-reference/html/transaction.html#tx-multiple-tx-mgrs-with-attransactional
Upvotes: 1