JPA batch_size property does not work for native query

I’m trying to make a bulk insert with a native query.

@Repository public interface Repository extends CrudRepository<Entity, Integer> {      @Modifying     @Query(value = "INSERT INTO table_name(value) VALUES (:value)", nativeQuery = true)     void insert(@Param("value") String value); } 

I’ve added batch_size property to the application.properties file

spring.jpa.properties.hibernate.jdbc.batch_size = 50 

But in the logs, I see that every insert processed separately. Is it possible to apply batching to native query?

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.