@TableId(type = IdType.AUTO)该注解用于数据库设定了主键自增
@TableId(type = IdType.ASSIGN_ID)该注解需要给主键手动传值
在使用mybatisplus时,主键报错,提示主键为空,原因是前端手动传了一个id主键,错用了@TableId(type = IdType.AUTO),如果没有在数据库设定主键自增,且没有添加@TableId(type = IdType.AUTO),会报错
Cause: java.sql.SQLException: Field ‘id‘ doesn‘t have a default value ; Field ‘id‘ doesn‘t have
最新推荐文章于 2023-07-28 16:35:22 发布