title: Hibernate ignoring Autocommit false setting. Creating a local connecction instead
body: <p>I am trying to batch saveorUpdate new entities to a mysql db via hibernate. I put a transaction.begin and a transaction.commit around a loop that does the entity generation and passes it to session.saveorUpdate. However on each pass, hibernate connects to DB, instead of commiting at the end when I call transaction.commit(). On checking logs, hibernate outputs : Connection 'local transaction' will be committed and connection will be set to auto commit mode</p>
  
  <p>So far I have, 1) have tried adding disabledLocalTxn to true to connection url, but no effect,
  2) have set autocommit to false property but no end effect</p>
  
  <p>Hibernate properties:</p>
  
  <pre><code>&lt;property name="hibernate.connection.url"&gt;jdbc:mysql://url:port/Dbname?disableLocalTxn=true&lt;/property&gt;
    &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQL5Dialect&lt;/property&gt;
    &lt;property name="hibernate.show_sql"&gt;false&lt;/property&gt;
    &lt;property name="hibernate.hbm2ddl.auto"&gt;validate&lt;/property&gt;
    &lt;property name="hibernate.current_session_context_class"&gt;thread&lt;/property&gt;
    &lt;property name="hibernate.jdbc.batch_size"&gt;50&lt;/property&gt;
    &lt;property name="hibernate.order_inserts"&gt;true&lt;/property&gt;
    &lt;property name="hibernate.connection.autocommit"&gt;false&lt;/property&gt;
    &lt;property name="hibernate.hbm2ddl.jdbc_metadata_extraction_strategy"&gt;individually&lt;/property&gt;
    &lt;mapping class="Object1"/&gt;
    &lt;mapping class="Object2"/&gt;
  </code></pre>
  
  <p>The code:</p>
  
  <pre><code>tx = session.getTransaction()
  tx.begin();
  
  for(i in elements){
  
  session.saveOrUpdate(generateObject1(i));// - Hibernate queries here 
  
  }
  tx.commit;// - instead of all at end
  </code></pre>
  
  <p>Log output below, last line saying connection will be set to auto commit</p>
  
  <pre><code>Jun 11, 2019 9:26:06 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
  INFO: HHH10001003: Autocommit mode: false
  Jun 11, 2019 9:26:06 PM org.hibernate.engine.jdbc.connections.internal.PooledConnections &lt;init&gt;
  INFO: HHH000115: Hibernate connection pool size: 20 (min=1)
  Jun 11, 2019 9:26:12 PM org.hibernate.dialect.Dialect &lt;init&gt;
  INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
  Jun 11, 2019 9:26:13 PM org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl useContextualLobCreation
  INFO: HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
  Jun 11, 2019 9:26:27 PM org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl getIsolatedConnection
  INFO: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@2257fadf] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
  </code></pre>