I want to execute batch update. I use JPA and Hibernate 5 as JPA provider and have the following code:
for (int i = 0; i < entities.size(); i++) {
if (i > 0 && i % JpaSettings.BATCH_SIZE == 0) {
entityManager.flush();
entityManager.clear();
}
....
count = count + entityManager.createQuery(criteria).executeUpdate();
}
entityManager.flush();
entityManager.clear();
However, this code seems not to execute batch updates. Because when I, for example, do insert I see in log something like:
DEBUG org.hibernate.engine.jdbc.batch.internal.BatchingBatch - Executing batch size: 2
But I don't see this message after my update operations. Could anyone say how to do batch update using executeUpdate?.