mybatis:### The error may involve defaultParameterMap### The error occurred while setting parameter

完整报错:

Caused by: org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'id' cannot be null
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: insert into tbl_activity (id,owner,name,startDate,endDate,cost,description,createTime,createBy)         values (?,?,?,?,?,?,?,?,?)
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'id' cannot be null

控制台显示的sql语句:

2021-12-28 12:33:57,402 [http-nio-8080-exec-1] DEBUG [com.cyy.crm.workbench.dao.ActivityDao.save] - ==>  Preparing: insert into tbl_activity (id,owner,name,startDate,endDate,cost,description,createTime,createBy) values (?,?,?,?,?,?,?,?,?) 
2021-12-28 12:33:57,403 [http-nio-8080-exec-1] DEBUG [com.cyy.crm.workbench.dao.ActivityDao.save] - ==> Parameters: null, null, null, null, null, null, null, null, null

前端通过ajax请求往后端发送数据,debug后端controller发现是可以正常接收数据的,

检查过mapper文件无数遍,小到连空格是否是中文了也检查过了,就是解决不了。

我开始尝试把id的主键约束去掉,发现可以正常insert,但是insert的所有属性值都为null

好端端的数据怎么会变成null呢???

茫然了好几天,还好看了一篇文章有了思路,既然后端、配置文件都没问题,会不会是前端的原因呢??

于是我查看了前端的ajax请求,人傻了

 这参数压根没对上啊???还有一个#忘记加了,活该我收的数据都是null

当后端和配置文件没问题的时候记得去检查前端!!!!心疼浪费的这几天时间

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值