IDEA 项目中,传参数 是 集合时 出现的问题。

在IDEA的Java Spring项目中,当在Mapper层传递集合参数时可能出现错误,主要是因为集合中包含多个字段导致SQL无法明确使用哪个字段。解决方案包括:1) 使用别名如`item.id`来指定字段;2) 确保集合只包含一个相关字段,避免字段混淆。
摘要由CSDN通过智能技术生成

Type handler was null on parameter mapping for property '__frch_uid_0'


【IDEA 项目中,传参数 是 集合时 出现的问题。】
nested exception is org.apache.ibatis.exceptions.PersistenceException:
Error querying database. Cause: java.lang.IllegalStateException: Type handler was null on parameter mapping for property ‘__frch_uid_0’. It was either not specified and/or could not be found for the javaType / jdbcType combination specified.
Cause: java.lang.IllegalStateException: Type handler was null on parameter mapping for property ‘__frch_uid_0’. It was either not specified and/or could not be found for the javaType / jdbcType combination specified.
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
Error querying database. Cause: java.lang.IllegalStateException: Type handler was null on parameter mapping for property ‘__frch_uid_0’. It was either not specified and/or could not be found for the javaType / jdbcType combination specified.
————————————————

这个在 mapper 层 。

 select * from table  where id in

	<foreach collection="yourList" index="index" item="item" open="(" separator="," close=")">    
          #{item}       
    </foreach> 

1、你的这个 " yourList " 如果传递过来的是 对象的集合。例如:[“id”:"","":""],像这种 集合中有很多字段,你的mapper 中的 sql 不知道要使用哪个字段。
所以才会报你看不懂的错误日志。
那么,你应该获取的是 (item是自起的别名) item.id ,否则就报错 。 修改为 #{item.id}

2、或者,你直接把 id 查出来放到集合中 (保证其中只有一个相关字段)。那么就直接用了。所以不会报错 。

//普通
<if test="heiList!=null and heiList.size()!=0" >
    and t.sales_code not in
    <foreach collection="heiList" item="mid" index="index" open="(" separator="," close=")">
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值