Cause: org.apache.ibatis.binding.BindingException: Parameter ‘xx‘ not found.

Error updating database. Cause: org.apache.ibatis.binding.BindingException: Parameter ‘xxx’ not found. Available parameters are [arg2, arg1, arg0, param3, param1, param2]

这种情况可能是由于对数据库进行操作时有多个参数但是持久层即Dao层中的方法内没有写占位符 @Param(“xxx”) 导致的:

例如:对数据库进行更新时:

<update id="update" >
        update lmonkey_cart
        set quantity=#{quantity}
        where u_id=#{u_id} and p_id=#{p_id}
</update>

这里面就包含了三个参数,
如果Dao层中是这样的:

public interface Lmonkey_CartDao {
	//更新
    int update(Integer quantity,
               String u_id,
               Integer p_id);
}

那么便会报某参数找不到的错,但是如果在每个参数前面加上占位符的话就不会出现这种错误:

public interface Lmonkey_CartDao {
	//更新
    int update(@Param("quantity") Integer quantity,
               @Param("u_id") String u_id,
               @Param("p_id") Integer p_id);
}

当然,在Service层中也可以写上占位符,并不会有任何影响,但是Dao层是必须要写的,因为它是直接和xml文件里的SQL语句进行对接的。

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

OfficialUser

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值