【问题标题】:Spring boot data + Oracle = batch update of entities not workingSpring boot 数据 + Oracle = 实体批量更新不起作用
【发布时间】:2020-09-10 02:29:11
【问题描述】:

我正在尝试使用 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>

让我知道还需要做什么才能使其正常工作?如果提供这些属性不起作用,还有其他可能的解决方案吗?

【问题讨论】:

    标签: hibernate spring-boot spring-data


    【解决方案1】:

    确保在你的 pom.xml 中使用official JDBC drivers

    <groupId>com.oracle.database.jdbc</groupId>
    <artifactId>ojdbc8</artifactId>
    <version>18.3.0.0</version>
    

    【讨论】:

      【解决方案2】:

      我有问题。我使用的是较旧的方言,即 org.hibernate.dialect.Oracle10gDialect,它似乎不支持批处理。我将其更改为 org.hibernate.dialect.Oracle12cDialect 并且有效。

      【讨论】:

        猜你喜欢
        • 2017-12-31
        • 2021-08-13
        • 2017-09-17
        • 1970-01-01
        • 2020-05-09
        • 1970-01-01
        • 2018-11-14
        • 2014-08-24
        • 2019-05-15
        相关资源
        最近更新 更多