I’m trying to do a batch insert (spring boot, jpa, hibernate) and when I look at the generated statistics, realized that it is still inserting them one by one instead as a batch . Below is the configuration and using JpaRepository’s saveAll(collection) method. My only hunch is, I’m using an assigned primary key instead of a generated one, not sure if that is the cause.
How do I solve the problem?
spring.jpa.properties.hibernate.jdbc.batch_size=10 spring.jpa.properties.hibernate.order_inserts = true spring.jpa.properties.hibernate.order_updates = true spring.jpa.properties.hibernate.batch_versioned_data=true spring.jpa.properties.hibernate.generate_statistics=true
@Id @Column(name = "SKU") private String sku;
43972157 nanoseconds spent acquiring 1 JDBC connections; 0 nanoseconds spent releasing 0 JDBC connections; 128270518 nanoseconds spent preparing 10 JDBC statements; 1320687164 nanoseconds spent executing 8 JDBC statements; 126666002 nanoseconds spent executing 2 JDBC batches; 0 nanoseconds spent performing 0 L2C puts; 0 nanoseconds spent performing 0 L2C hits; 0 nanoseconds spent performing 0 L2C misses; 152061315 nanoseconds spent executing 2 flushes (flushing a total of 16 entities and 0 collections); 0 nanoseconds spent executing 0 partial-flushes (flushing a total of 0 entities and 0 collections)