title: Batch Insert using Hibernate: why stats show me a different number of flushed entitites?
body: <p>I am new to Spring and Hibernate. I have 157 records and I want to batch insert the records using Hibernate. I created my entity and in my service I am making a list of entities. I am using <code>CrudRepository.saveAll(List)</code> to do batch insert.</p>
  
  <p>But Hibernate statistics show me 1045 flushed entities. When I add something to logger to see SQL queries it is exactly 157 statements for this entity. It shows batch size as what I <code>defined(160)</code>. I tried different ways like <code>session.flush</code> and <code>session.clear</code>. All other methods have the same result. It saves 157 records in the database which means the result is correct. Why does it show me 1045 instead of 157? Can I see the number of inserted entities instead?</p>
  
  <p>P.S: It is 158 statements in statistics because one single record is for another entity that is not part of my question.<br>
  This is part of my code:</p>
  
  <pre><code>for (int i = 0; i &lt; listsize; i++){
      listFields.add(entity);
  }
  FieldsDAO.saveAll(listFields);
  </code></pre>
  
  <p>and the screenshot for the report
  <a href="https://i.stack.imgur.com/uW11l.png" rel="nofollow noreferrer">spring.jpa.properties.hibernate.generate_statistics=true</a></p>
  
  <p>My second concern is why it executes both batch and JDBC Statement? Thanks in advance for your help</p>