小编Dzm*_*yey的帖子

JPA batch_size 属性不适用于本机查询

我正在尝试使用本机查询进行批量插入。

@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);
}
Run Code Online (Sandbox Code Playgroud)

我已将batch_size属性添加到application.properties文件中

spring.jpa.properties.hibernate.jdbc.batch_size = 50
Run Code Online (Sandbox Code Playgroud)

但在日志中,我看到每个插入都是单独处理的。是否可以将批处理应用于本机查询?

sql hibernate jpa bulk spring-boot

5
推荐指数
1
解决办法
1836
查看次数

标签 统计

bulk ×1

hibernate ×1

jpa ×1

spring-boot ×1

sql ×1