Reputation: 1170
I've 1000 entities to update in MySQL database so If I use myRepository.saveAll(List<Entity>)
does it internally use hibernate batch to update the table. I'm using below hibernate property for batch update/insert
spring.jpa.properties.hibernate.jdbc.batch_size=100
spring.jpa.properties.hibernate.order_inserts=true
spring.jpa.properties.hibernate.order_updates=true
I'm wondering if JPA will execute 10 queries to update in batch or will work same as JPA save(Entity)
method and execute 1000 queries to update ? Is there any way to trace it ?
Upvotes: 0
Views: 3637
Reputation: 691913
saveAll()
is just a loop calling save()
on each entity. It can't be anything else, as JPA doesn't have any method to save several entities at once.
Does that mean that hibernate batching isn't used? No, because Hibernate batching precisely consists in grouping insert queries in batches, and execute the batches.
Upvotes: 2