我正在尝试使用 CrudRespositories saveAll 方法进行批量/批量更新,但它似乎不起作用。生成日志:
2020-05-23 07:06:27.963Z INFO [nio-8080-exec-1] i.StatisticalLoggingSessionEventListener {} : Session Metrics {
314694800 nanoseconds spent acquiring 1 JDBC connections;
0 nanoseconds spent releasing 0 JDBC connections;
54054998 nanoseconds spent preparing 12 JDBC statements;
5762126698 nanoseconds spent executing 12 JDBC statements;
0 nanoseconds spent executing 0 JDBC batches;
我认为0 JDBC batches
意味着没有完成批量更新?
我已经为批处理配置了以下属性:
spring.jpa.properties.hibernate.jdbc.batch_size=30
spring.jpa.properties.hibernate.order_updates=true
spring.jpa.properties.hibernate.order_inserts=true
spring.jpa.properties.hibernate.batch_versioned_data=true
依赖项版本:
Spring boot : 2.2.5.RELEASE
Oracle : tried on both 11g and 12c
jdbc driver :
<groupId>com.oracle</groupId>
<artifactId>ojdbc8</artifactId>
<version>18.3</version>
让我知道还需要做什么才能正常工作?如果通过提供这些属性不起作用,还有什么其他可能的解决方案?
我遇到了这个问题。我使用的是较旧的方言,即org.hibernate.dialect.Oracle10gDialect,它似乎不支持批处理。我把它改成了org.hibernate.dialect.Oracle12cDialect,它起作用了。
确保在你的pom中使用官方的JDBC驱动程序.xml
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>18.3.0.0</version>