两者的区别在于如果选择insert 那么所有的字段都会添加一遍即使没有值,而insertSelective则会判断非空才进行插入。
体现在sql上为:
student表:
id,name,age
实体代码为:
使用insert时执行的sql语句为:insert into student(id,name,age) values (1,‘zhangsan’,null);
而使用insertSelective时执行的sql语句为:insert into student(id,name) values (1,‘zhangsan’);
Mybatis中insert和insertSelective区别
原文:https://www.cnblogs.com/king0207/p/13564516.html