title: Transaction on two tables at the same time in two different databases
body: <p>I have <code>spring-boot</code> app with <code>mybatis</code> as my ORM. I also use <code>sqlserver 2012</code>.   </p>
  
  <p>I consider following scenario:   </p>
  
  <pre><code>void foo () {
      set current datasource as Datasource D1 (connected to database D1)
      do some insert on table T1 in database D1
      set current datasource as Datasource D2 (connected to database D2)
      do some insert on table T1 (the same name) in database D2
  }
  </code></pre>
  
  <p>I would like to be able to ensure that it <strong>always</strong> succees both queries. Otherwise (when at least one of them fails) transaction will be rollback (I mean no changes) in both databases (even if one of them query succeed).   </p>
  
  <p>I think that <code>@Transactional</code> above <code>foo()</code> is not sufficient.<br>
  Is it possible to gain this effect ?</p>