问题
报错代码块:
if (menuIds.contains(menuId)) { // 判断是否与最上层删除的菜单相同
roleMenu2Mapper.deleteByPrimaryKey(roleMenuId); // 相同则删除
}
报错信息:
### Error updating database. Cause: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: '91eab91ccb774dea976043ef1b7a'
### The error may involve com.yunsystem.system.mapper.RoleMenu2Mapper.deleteByPrimaryKey-Inline
### The error occurred while setting parameters
### SQL: DELETE FROM tb2_role_menu WHERE id = ? AND menu_id = ? AND role_id = ?
### Cause: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: '91eab91ccb774dea976043ef1b7a'
; Data truncation: Truncated incorrect DOUBLE value: '91eab91ccb774dea976043ef1b7a'; nested exception is com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: '91eab91ccb774dea976043ef1b7a'
org.springframework.dao.DataIntegrityViolationException:
原因
请去看看你的xxxMapper对应的实体类XXX定义里字段是否明确了哪一个是主键!!!!!!!
喏,忘了加主键 @Id 了,mybatis不知道哪个是主键,所以你调用deletebyPrimaryKey方法删除时它不知道传入的参数应该匹配哪个,就这么简单~~~