title: How to inject a datasource with autocommit on or off whether a method is run inside a transaction or not
body: <p>I have got:</p>
  
  <ul>
  <li>a DAO class in JOOQ that in its constructor takes a <code>javax.sql.DataSource</code>, which is injected by Guice</li>
  <li>a service class that calls the methods from the DAO class</li>
  </ul>
  
  <p>I want to:</p>
  
  <ul>
  <li>be able to annotate <strong>a few</strong> methods inside the service class as methods requiring a transaction</li>
  </ul>
  
  <p>Possible solution: <a href="https://github.com/jOOQ/jOOQ/tree/master/jOOQ-examples/jOOQ-spring-guice-example" rel="nofollow">https://github.com/jOOQ/jOOQ/tree/master/jOOQ-examples/jOOQ-spring-guice-example</a> i.d.:</p>
  
  <ul>
  <li>a method interceptor invoked when a method is annotated with the <code>Transactional</code> annotation</li>
  <li>the method interceptor calls <code>rollback()</code> if there were exceptions or <code>commit()</code> if everything was fine</li>
  <li>Guice <em>provides</em> a <code>javax.sql.DataSource</code> (BoneCP pooled connection)</li>
  <li>the BoneCP pooled connections have the <code>defaultAutoCommit</code> attribute set to <code>false</code></li>
  </ul>
  
  <p>Finally, my question:</p>
  
  <ul>
  <li>I want the datasource with <code>autocommit</code> set to <code>false</code> to be injected into <strong>all the methods</strong> that are called from the method annotated with  <code>@Transactional</code>, in all the other cases the datasource with <code>autocommit</code> set to <code>true</code></li>
  </ul>
  
  <p>How this can be achieved?</p>