V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
cmxzj
V2EX  ›  Java

mybatis batch 插入

  •  
  •   cmxzj · Jul 30, 2021 · 2251 views
    This topic created in 1731 days ago, the information mentioned may be changed or developed.

    使用 mybatis executortype.batch 每批插入 1000 条数据,遇到报错应该怎样日志打印出来报错的那条数据呢,LOG 开的是 INFO,目前想到的是 try catch 插入的方法打印报错的整个 1000 条数据。。

    1 replies    2021-08-12 11:41:47 +08:00
    hcen1997
        1
    hcen1997  
       Aug 12, 2021
    报的错有这个异常吗? org.apache.ibatis.executor.BatchExecutorException
    mybatis 3.5.5 好像有相关信息的打印
    ----
    message.append(batchResult.getMappedStatement().getId())
    .append(" (batch index #")
    .append(i + 1)
    ---
    org/mybatis/mybatis/3.5.5/mybatis-3.5.5-sources.jar!/org/apache/ibatis/executor/BatchExecutor.java:138
    你看看 138 行的代码能不能解决你的问题

    不过这个只能打印 index
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5363 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 01:21 · PVG 09:21 · LAX 18:21 · JFK 21:21
    ♥ Do have faith in what you're doing.