title: Increase Hibernate performance on big write/update
body: <p>I am trying to do a massive write/update to a database using hibernate taking data from an uploaded csv which can vary from 60,000 to 100,000 rows. I am using batch updates but even with that it takes quite some time i.e. 20+ min. Does anyone have any tips? I would like to avoid writing sql but is that the only way?</p>
  
  <p>The current code</p>
  
  <pre><code>for (String row : rows) {
      String[] rowData = row.split(",");
      try {
          long userID = Long.parseLong(rowData[0]);
          int platformID = Integer.parseInt(rowData[1]);
          if (platformID == 14 &amp;&amp; userID &gt; 0) {
              MCTileScheduleEntity schedule = new MCTileScheduleEntity.Builder()
                                                  .tile(tile)
                                                  .userID(userID)
                                                  .platformID(platformID)
                                                  .startDate(startDate)
                                                  .endDate(endDate)
                                                  .build();
              if (existUser.add(userID)){
                  schedules.add(schedule);    
              } else {
                  error += 1;
                  errMessage += "Duplicated data detected for user id "+ userID + "\n";
              }
          } else {
              error += 1;
              errMessage += "Malformed data detected for user id "+ userID + "\n";
          }
      } catch (NumberFormatException e) {
          error += 1;
          errMessage += "Non-numerical input for user id " + rowData[0] + "\n";
      }
  }
  
  if (error == 0) {
      //write to database in batches
      hb.batchUpdate(schedules);
      tile.setTargetCount(Long.valueOf(schedules.size()));
      hb.update(tile);
  }
  </code></pre>