insertSelective 的用法

int insert(T record);
int insertSelective(T record);

insertSelective 对应的 SQL 语句加入了 NULL 检验,只会插入数据不为 null 的字段,而 insert会插入所有字段,会插入 null 数据。

也就意味着如果定义了表 default 字段,使用 insert 还是会插入 null 而忽略 default

insertSelective 当字段为 null 时会用 default 自动填充

posted @ 2019-07-10 19:24  沧海一粟95  阅读(7803)  评论(0编辑  收藏  举报