Java – Multiple SessionFactories, multiple DataSources and Hibernate TransactionManager can take only one Sessionfactory

hibernatejavaspringtransactions

I have @Transactional annotation in all my DAOs, but I can only define one TransactionManager that takes only one SessionFactory. I have one SessionFactory per customer, one DataSource per customer and apparently I need to change TransactionManager for every customer. But how can I get correct transaction manager for customer, when I can only define one Spring bean name for one TransactionManager?

Best Answer

Spring 3 has support for multiple transaction managers, while keeping the declarative @Transactional delimitation

http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/transaction.html#tx-multiple-tx-mgrs-with-attransactional

Is this not what you want?

Related Topic