title: SELECT FOR UPDATE issue in Spring JDBC app
body: <p>I am using <code>SELECT ... FOR UPDATE</code> statement to achieve row-level locking in my SpringBoot app. Database: MySQL 5.7.28, connector - MariaDb java client 2.5.2, connection pool HikariCP 2.7.9, spring boot version - 2.0.3 Release.</p>
  
  <p>Persistence is accomplished by Spring JDBC Template, not by JPA. I am using Spring Transaction management, annotation-based by slapping <code>@Transactional</code> annotation on my DAO methods. Transactional proxies are generated via AspectJ compile-time weaving (<code>@EnableTransactionManagement(mode = AdviceMode.ASPECTJ)</code>). I am sure that the transaction manager is configured correctly.</p>
  
  <p>I have written a couple of integration tests that would verify the possibility of a race condition when multiple threads are competing to update the same row, that is supposed to be locked with <code>SELECT ... FOR UPDATE</code>.</p>
  
  <p>Now, the tests work 95% of the time, however, there is one test that is failing when there is a particular sequence of ITs executed.</p>
  
  <p>I am certain that when a test fails, a row lock is not imposed.</p>
  
  <p>I have enabled the MySql query log on the server to help with troubleshooting.</p>
  
  <p>Here is what I see when the first thread is executing the <code>SELECT ... FOR UPDATE</code> statement:</p>
  
  <pre><code>2020-01-26T12:54:06.681319Z  1219 Query set autocommit=0
  2020-01-26T12:54:36.616097Z  1209 Query SELECT _listed_fields_ FROM _my_table_ WHERE id IN ('19qix6lvsfx') FOR UPDATE
  </code></pre>
  
  <p>It seems that the auto-commit is set on a wrong connection object. Do I read it right? What are those numbers <code>1219</code> and <code>1209</code>? </p>
  
  <p>When everything works right, the log looks like this:</p>
  
  <pre><code>2020-01-26T13:24:22.940787Z  1243 Query set autocommit=0
  2020-01-26T13:24:36.515016Z  1243 Query SELECT _listed_fields_ FROM _my_table_ WHERE id IN ('19xbs7vv53r') FOR UPDATE
  </code></pre>
  
  <p>Any help will be greatly appreciated.</p>