title: Transaction not starting unless I do modification
body: <p>I'm having an issue where my transaction doesn't truly seem to be starting unless I issue a command that appears to be transaction worthy (the last part is conjecture). </p>
  
  <p>Below I have a method decorated with the @Transaction attribute, it's public, it's being called via the spring proxy.  I'm connecting to SQL Server, using Microsoft's JDBC driver version 4.2.  And getting an app lock, if I try and get the app lock before doing something that's transaction worth the transaction doesn't appear to start.  I'm guessing this based on the returned error code (-999) which is consistent with not being in a transaction.</p>
  
  <p>This code works perfectly fine in my other project, but there we are doing more than just grabbing an app lock.</p>
  
  <h3>Here's the method (Ignore the fact that this would just lose the app lock right after fetching it)</h3>
  
  <pre><code>@Transactional
  public Boolean getAppLock(String lockString, Integer timeoutMilliseconds) {
      try {
          Session session = entityManager.unwrap(Session.class);
  
          int result = session.doReturningWork(connection -&gt; {
              int execResult = -1;
  
              // Works if I add this line
              // connection.prepareStatement("insert into foo (baz) values('bar')").execute();
  
              // This line works also, which is stupid, cause it doesn't even update anything
              // connection.prepareStatement("update foo set baz = baz where id = 1231241").execute();
              try (PreparedStatement statement = connection.prepareStatement("declare @i int; exec @i = sp_getapplock ?,?,?,?; select @i;")) {
  
                  statement.setString(1, lockString);
                  statement.setString(2, "Exclusive");
                  statement.setString(3, "Transaction");
                  Integer timeout = timeoutMilliseconds == null ? 0 : timeoutMilliseconds;
                  statement.setInt(4, timeout);
  
                  try (ResultSet resultSet = statement.executeQuery()) {
                      resultSet.next();
  
                      // Complains about not being in a transaction, unless
                      // I have a random statement that seems transaction worthy
                      execResult = resultSet.getInt(1);
                  } catch (Exception ex) {
                      logger.error("Failed getting the result set from the app lock", ex);
                  }
              } catch (Exception ex) {
                  logger.error("Error executing statement sp_getapplock", ex);
              }
              return execResult;
          });
  
         // see return codes here (https://msdn.microsoft.com/en-us/library/ms189823.aspx), 0+ is good, &lt; 0 is bad
  
          return result &gt;= 0;
      }
      catch (Exception ex){
          throw new RuntimeException(ex.getMessage());
      }
  }
  </code></pre>
  
  <p>I'm not sure if this is a driver or a spring thing, I'm leaning toward driver thing.</p>