如题,以下是具体代码片
<update id="editupthat" parameterType="java.util.Map">
update t_sys_pos_policy_info
set module1_end_date=#{map.isdate}
where policy_id=#{map.isid}
and module1_pickup_date < #{map.isdate}
and id in (#{map.issn})
</update>
前端传值
每次执行都会报错
### Error updating database. Cause: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: '18948,18949'
### The error may involve com.ruoyi.project.deveagent.syspospolicy.mapper.SysPosPolicyMapper.editupthat-Inline
### The error occurred while setting parameters
### SQL: update t_sys_pos_policy_info set module1_end_date=? where policy_id=? and module1_pickup_date < ? and id in (?)
### Cause: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: '18948,18949'
; Data truncation: Truncated incorrect DOUBLE value: '18948,18949'
/**
* @param params
* @return
*/
@Transactional
public R editupthat(Map<String,Object> params) {
try {
int k = 0;
k = sysPosPolicyMapper.editupthat(params);
if(k == 0){
return R.error("修改失败!");
}
}catch (Exception e){
return R.error("修改异常!");
}
return R.ok("修改成功!");
}
可以传一下list集合,在mybatis里面用foreach循环
你的字段里面不是多个值是用逗号分割的, 可以用这个方法Arrays.asList(s.split(","),转接转成list集合,在把集合传进去,循环这个集合。(pd是我们自己封装的,其它就是一个map对象)
java代码
mapper
https://blog.csdn.net/ru_yin_hai/article/details/104904707
我看你截图里面是linkedhashmap 已经有取到值了,mybatis的写法有问题,你的 parameterType是map,#里面不要加map,直接用key。
update t_sys_pos_policy_info
set module1_end_date=#{isdate}
where policy_id=#{isid}
and module1_pickup_date < #{isdate}
and id in (#{issn})
至于其他评论说的list 是另外一回事,如果是批量操作,就是他们说的foreach。你如果只有一个map,就是上面的写法
用${map.issn}这种方式传,#{}传的字符串,逗号不会被解析的