title: How to configure two hibernate transactionManager for two different sessions
body: <p>I have a project which deals with two different database instances.
  Each access to a database is transactional, but the transaction on database1 do not need to be linked to transaction on database2.</p>
  
  <p>I am using Hibernate and spring-tx 4.0.3 Release, spring Ioc4 and hibernate4.</p>
  
  <p>I use <code>@Transactional</code> annotation in my DAO services.</p>
  
  <p>So I configure two datasource beans, two sessionFactory beans and two HibernateTransactionManager beans.</p>
  
  <p>But doing so, I get an <code>UniqueBeanException</code>  as the <code>TransactionAspectSupport.determineTransactionManager</code> tries to find only one instance of class implementing <code>PlatformTransactionManager</code> interface.</p>
  
  <p>I have seen that I can make my java configuration class implements <code>TransactionManagementConfigurer</code>, so that I can specifically tell which transaction-manager bean to use, and I was hoping to implement a <code>ProxyTransactionManager</code> who could delegate to each appropriate transaction-manager depending on which database the current call need to be made.</p>
  
  <p>The problem is implementing such <code>ProxyPlatformTransactionManager</code> methods, how can I know which database is being accessed, or which <code>SessionFactory</code> is being accessed? Otherwise I an not know which <code>PlatformTransactionManager</code> to use.</p>
  
  <p>Has anyone faced that type of issue yet?</p>
  
  <p>Thanks,</p>
  
  <p>Mel</p>