baomidou / mybatis-plus

An powerful enhanced toolkit of MyBatis for simplify development
https://baomidou.com
Apache License 2.0
16.33k stars 4.3k forks source link

mybatis-plus 3.5.2 saveOrUpdateBatch 方法,对新增的字段,生成的SQL无效 #6288

Closed S0Louis closed 3 months ago

S0Louis commented 3 months ago

请详细描述需要增加的功能 项目启动运行了一段时间,今天实体中新增一个字段,部署生产之后发现生成的SQL中,并未包含该新字段,本地测试时又完全正常

nieqiurong commented 3 months ago

就这几个文字,我也不是华佗啊。

xiaohuihui7726 commented 3 months ago

mapper.xml重写了insert方法,saveorupdate处理逻辑中会调用指定mapper.insert方法,可能执行到了你mapper.xml的sql

S0Louis commented 3 months ago

但仍有一事不明,为什么本地做测试时saveOrUpdateBatch 内部优化使用自身insert逻辑,而部署到test环境后,偶尔会出现加载在mapperXX.xml中重写的insert方法;

S0Louis commented 3 months ago

@nieqiurong 感谢回复,当时时间紧急,描述缺失细节,大概问题是这样的: UserMaper接口和xml中重写了BaseMapper insert 这个方法,批量处理时,调用的是ServiceImpl的saveOrUpdateBatch方法,但在近期新增字段并未维护insert方法,然后saveOrUpdateBatch在test环境偶现生成的insert SQL中缺失新增字段; 本地尝试未曾复现,还在排查其具体原因

nieqiurong commented 3 months ago

这个排查看下.

miemieYaho commented 3 months ago

把你重写的删了

S0Louis commented 3 months ago

@miemieYaho 嗯嗯,删除后确实是可以解决这个问题