Hibernate: Enable batching or spring.jpa batch settings do nothing

Batch size must be set, and inserts must be ordered, before Hibernate groups statements.

Code
// application.yml
spring:
  jpa:
    properties:
      hibernate:
        jdbc.batch_size: 50
        order_inserts: true
        order_updates: true
        batch_versioned_data: true
Output
Without order_inserts, an interleaved insert order breaks each batch
after one statement, and the batch size has no effect at all.
Advertisement

Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.

Published 2026-08-11