GithubHelp home page GithubHelp logo

batchUpsert about mybatis-generator-plugin HOT 1 CLOSED

itfsw avatar itfsw commented on May 26, 2024
batchUpsert

from mybatis-generator-plugin.

Comments (1)

itfsw avatar itfsw commented on May 26, 2024

这个是正常现象,Mysql执行insert或者update返回的数量其实是受影响的行数。
对于upsert(即ON DUPLICATE KEY UPDATE)会存在以下几种可能,

  1. 没有主键冲突,对应执行insert此时返回受影响的行数为1;
    2.发生主键冲突,对应执行ON DUPLICATE KEY UPDATE的update,此时返回受影响的行数为2(这也是目前我也比较疑惑的地方,按理应该是1的,但mysql就是返回了2);
    3.发生主键冲突,对应执行ON DUPLICATE KEY UPDATE的update(和其他update一样,如果update里面的数据和原始数据一致,即没有产生更新)此时返回受影响的行数为0;

所以综上,对于batchUpsert来说返回结果是无用的。但是对于upsert来说其实是可以根据其结果区分具体执行情况。

from mybatis-generator-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.