title: Bulk/Batch update using Spring Data JPA/Hibernate on Mysql
body: <p>I am using Mysql, Spring Data JPA. In my use case, I have only 1 table e.g. Customer (ID, FIRST_NAME, LAST_NAME)
  What I am trying to achieve is to update in a batch/bulk where update statements are a group as shown above in the example <strong>to reduce database round trips</strong>.</p>
  
  <p>I have set all properties</p>
  
  <ul>
  <li>hibernate.order_inserts: true </li>
  <li>hibernate.order_updates: true    </li>
  <li>hibernate.jdbc.batch_versioned_data:    true</li>
  </ul>
  
  <p>But the result is (update statements are not getting grouped): <em>logs from MySQL general logs</em></p>
  
  <pre><code>2018-10-28T03:18:32.545233Z 1711 Query update CUSTOMER set FIRST_NAME=’499997′, LAST_NAME=’499998′ where id=499996;
  2018-10-28T03:18:32.545488Z 1711 Query update CUSTOMER set FIRST_NAME=’499998′, LAST_NAME=’499999′ where id=499997;
  2018-10-28T03:18:32.545809Z 1711 Query update CUSTOMER set FIRST_NAME=’499999′, LAST_NAME=’500000′ where id=499998;
  </code></pre>
  
  <p>Desired Result: (updates are grouped as a single query, thus reducing the DB roundtrips)</p>
  
  <pre><code>2018-10-28T03:18:32.545233Z 1711 Query update CUSTOMER set FIRST_NAME=’499997′, LAST_NAME=’499998′ where id=499996; update CUSTOMER set FIRST_NAME=’499998′, LAST_NAME=’499999′ where id=499997; update CUSTOMER set FIRST_NAME=’499999′, LAST_NAME=’500000′ where id=499998;
  </code></pre>
  
  <p>My application needs to perform more then 100 million update and I suppose this is could the fastest way. </p>