title: MyBatis-Spring multi-datasource configuration cache issues
body: <p>Using mybatis-3.1.0, spring-3.1.1.RELEASE, and mybatis-spring-1.1.0, we are facing some nasty cache issues in a multi-datasource configuration.</p>
  
  <p>For security reasons, we have separate datasources pointing to the same database and schema, each datasource using different credentials. The goal is to use a db user having only select permissions for doing selects, another user with insert/update/delete permissions to do dml operations, and so on.</p>
  
  <p>For doing so, we have configured three separate SqlSessionFactoryBeans, one for each datasource. And the problem comes here: when an insert operation is performed using the "DML" session, the local cache of "SELECT" sessions is not flushed. Therefore, for example, we do not see newly created users in the user list.</p>
  
  <p>So my question is: do we have any way of configuring a single SqlSessionFactoryBean associated to all three datasources at the same time?</p>
  
  <p>Update:</p>
  
  <p>After some more debugging, it looks like the core issue is actually transaction management related. Some actions in the site involve several operations, and these operations are performed through different datasources. It looks like we are not correctly configuring the transaction manager, and one or more of those operations are left out of the commit. After several attempts, as the connections are exhausted, database operations get totally messed up.</p>
  
  <p>So, the question now is, how to configure a single transaction manager to handle all involved datasources?</p>