High-performance Java Persistence.pdf __top__

int updatedEntities = entityManager.createQuery( "update Post set status = :newStatus where createdOn < :date") .setParameter("newStatus", Status.OLD) .setParameter("date", LocalDate.now().minusDays(30)) .executeUpdate(); // Sends 1 SQL statement.

By enabling hibernate.jdbc.batch_size and ordering your inserts/updates so that Hibernate can group statements of the same type into a single batch, you can turn 1,000 network roundtrips into just a few. High-performance Java Persistence.pdf

In addition to the strategies outlined above, here are some best practices to keep in mind: int updatedEntities = entityManager