记录 mybatis-plus 使用问题

记录 mybatis-plus 使用问题:

  1. 测试mapper.insert()方法提示主键类型错误
    解决: 实体类忘记添加注解: @TableId(type = IdType.AUTO)
  2. 不支持两个主键

mybaity-plus 实体类注解说明:

参考:https://baomidou.gitee.io/mybatis-plus-doc/#/generic-crud?id=注解说明

表名注解 @TableName
描述
value 表名( 默认空 )
resultMap xml 字段映射 resultMap ID
主键注解 @TableId (暂不支持组合主键)
描述
value 字段值(驼峰命名方式,该值可无)
type 主键 ID 策略类型( 默认 INPUT ,全局开启的是 ID_WORKER )
字段注解 @TableField
描述
value 字段值(驼峰命名方式,该值可无)
update 预处理 set 字段自定义注入
condition 预处理 WHERE 实体条件自定义运算规则
el 详看注释说明
exist 是否为数据库表字段( 默认 true 存在,false 不存在 )
strategy 字段验证 ( 默认 非 null 判断,查看 com.baomidou.mybatisplus.enums.FieldStrategy )
fill 字段填充标记 ( FieldFill, 配合自动填充使用 )

猜你喜欢

转载自blog.csdn.net/qq_33799320/article/details/83538774