title: Hibernate and JDBC in one transaction
body: <p>I have a method, marked as @Transactional.
  It consists of several functions, one of them uses JDBC and the second one - Hibernate, third - JDBC.
  The problem is that changes, made by Hibernate function are not visible in the last functions, that works with JDBC.</p>
  
  <pre><code>@Transactional
  void update() {
    jdbcUpdate1();
    hibernateupdate1();
    jdbcUpdate2(); // results of hibernateupdate1() are not visible here    
  }
  </code></pre>
  
  <p>All functions are configured to use the same datasource:</p>
  
  <pre><code>&lt;bean id="myDataSource" class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy"&gt;
          &lt;property name="targetDataSource" ref="targetDataSource"/&gt;
      &lt;/bean&gt;
  
      &lt;bean id="targetDataSource" class="org.apache.commons.dbcp.BasicDataSource"
            destroy-method="close" lazy-init="true" scope="singleton"&gt;
         &lt;!-- settings here --&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>myDataSource bean is used in the code. myDataSource.getConnection() is used to work with connections in jdbc functions and </p>
  
  <pre><code>getHibernateTemplate().execute(new HibernateCallback() {
              public Object doInHibernate(Session session) throws HibernateException, SQLException {
                 ... 
              }
          });
  </code></pre>
  
  <p>is used in hibernate function.
  Thanks.</p>