title: "Select for update" and update with pessimistic locking
body: <p>I'm trying to implement pessimistic locking using select for update, as I want other threads to wait until the lock on the selected row is released.
  The part that I have understood is after going through multiple threads <a href="https://stackoverflow.com/questions/56350833/spring-jdbc-select-for-update">Spring JDBC select for update</a> and various similar threads is it is achievable in case select and update are happening within same method and hence they are part of same transaction.</p>
  <p>The issue in my case is I have a JAR for DAO functionality where in a <code>selectforUpdate</code> method is available and a separate update method is available, both method has a finally block which contains</p>
  <pre><code>resultSet.close();
  statement.close();
  connection.close();
  </code></pre>
  <p>Now I'm struggling to find out is there a way in which I can use both the methods from outside of the JAR, maybe by annotating my method with <code>@Transactional</code> annotation and make it work in some way. So that lock is only released once update method has been executed.</p>