内容简介:转载请注明出处:由于mybatis plus调用默认的更新操作方法时,不更新值为空,null或默认值等得属性字段,只更新值为非null,非空非默认值的属性字段。以下为mybatis plus sample项目中一个对应数据库的实体类:
转载请注明出处:
由于mybatis plus调用默认的更新操作方法时,不更新值为空,null或默认值等得属性字段,只更新值为非null,非空非默认值的属性字段。
以下为mybatis plus sample项目中一个对应数据库的实体类:
import java.util.List;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
/**
* @author miemie
* @since 2019-11-27
*/
@Data
@TableName(resultMap = "m_b") // 对应xml里的 id
public class Man {
private Long id;
private String name;
private Long laoPoId;
@TableField(exist = false)
private Woman laoPo;
@TableField(exist = false)
private List<Child> waWa;
}
调用 BaseMapper 其中默认的修改方法;
项目中我们经常需要对一些数据库字段就要进行置空或设为默认值的操作,需要在实体类上加一个注解就可以:
@TableField(updateStrategy = FieldStrategy.IGNORED )
在实体类上添加该注解就可以对这个字段进行空的默认值修改操作。对于新增也是一样的。
@TableField(insertStrategy= FieldStrategy.IGNORED )
学习和研究mybatis plus项目可以学习这个项目: https://github.com/baomidou/mybatis-plus-samples
拿走不谢。点赞就好
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- 网市场云建站 v4.6 更新,增加网站转移插件、以及内容管理可无限扩展字段。
- springboot~DTO字符字段与日期字段的转换问题
- Protocol Buffers 学习(2):字段类型和其他语言字段类型之间的映射
- Protocol Buffers 学习(2):字段类型和其他语言字段类型之间的映射
- PHPRAP 2.0.2 发布,接口和字段数据分离,字段使用单独数据表
- 如何正确新增字段
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
The Intersectional Internet
Safiya Umoja Noble、Brendesha M. Tynes / Peter Lang Publishing / 2016
From race, sex, class, and culture, the multidisciplinary field of Internet studies needs theoretical and methodological approaches that allow us to question the organization of social relations that ......一起来看看 《The Intersectional Internet》 这本书的介绍吧!