Mybatis-plus: MySQL8.0环境里主键没有自动返回

Created on 1 Sep 2020  ·  3Comments  ·  Source: baomidou/mybatis-plus

当前使用版本(必填,否则不予处理)

3.1.0

问题描述

表主键字段定义:
PBO_ID varchar(20) not null DEFAULT (UUID_SHORT());
然后Entity定义:
/**
* 主键
*/
@TableId(value = "PBO_ID")
private String pboId;
配置文件中 idType=AUTO
然后通过BaseMapper的insert插入记录之后,记录插入成功,pbo_id也有值,但是代码中entity的pboId并没有自动设置成相应的值

Most helpful comment

那你自己写个mybatis的insert看看能不能返回主键吧

All 3 comments

那你自己写个mybatis的insert看看能不能返回主键吧

数据库需要设置自增

数据库需要设置自增

好的,谢谢。

Was this page helpful?
0 / 5 - 0 ratings