mybatis 批量更新 Parameter '__frch_item_0' not found. Available parameters are [list]
一次在做批量更新数据的时候报错 Parameter '__frch_item_0' not found. Available parameters are [list] 记过反复查找,最后才发现是一个字段的字母小写了。
下面给大家提供一个实例:
xml:这里说明一下这个sql的意思是根据h_code去更新h_clientA的值
<update id="updateHards" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
update hard
<set>
<if test="item.h_clientA !=null">
h_clientA = #{item.h_clientA,jdbcType=VARCHAR}
</if>
<if test="item.h_clientB !=null">
h_clientB = #{item.h_clientB,jdbcType=VARCHAR}
</if>
<if test="item.h_clientC !=null">
h_clientC = #{item.h_clientC,jdbcType=VARCHAR}
</if>
</set>
where h_code = #{item.hCode,jdbcType=VARCHAR}
</foreach>
</update>
dao:
int updateHards(List<Hard> list);
controller:
List<Hard> hards = new ArrayList<Hard>();
for (int i = 0; i < split.length; i++) {
Hard hard = new Hard();
switch (client.getClient_level()) {
case 2:
hard.setH_clientB(h_client);
break;
case 3:
hard.setH_clientC(h_client);
break;
} hard.sethCode(split[i]);
hards.add(hard);
}
// 3.进行操作,并返回 int updateHards = hardManageService.updateHards(hards);
相关的错误信息:
1.查看parameterType的类型是不是java.util.List类型,如果是的话,看foreach 的collection属性是不是list,
因为 传递一个 List 实例或者数组作为参数对象传给 MyBatis,MyBatis 会自动将它包装在一个 Map 中,用名称在作为键。List 实例将会以“list” 作为键,而数组实例将会以“array”作为键
2.看一下foreach里面的值有没有传递进来
3.看foreach里面的名称字段是否写错
4.还有就是我用Mybatis的时候,用mysql的值插入自动增长值,里面的key我在数据库中没有设置自动增长,然后我又用了selectkey,所以也会出现这种情况
如有需要可以加我Q群【308742428】大家一起讨论技术。
后面会不定时为大家更新文章,敬请期待。
喜欢的朋友可以关注下。
mybatis 批量更新 Parameter '__frch_item_0' not found. Available parameters are [list]的更多相关文章
- mybatis 批量增加 Parameter '__frch_item_0' not found. Available parameters are [list]
当在mybatis用到foreach的时候,会报这个错误Parameter '__frch_item_0' not found. Available parameters are [list]会出现的 ...
- 解决使用mybatis做批量操作时发生的异常:Parameter '__frch_item_0' not found. Available parameters are [list] 记录
本文主要描述 使用mybatis进行批量更新.批量插入 过程中遇到的异常及总结: 首先贴出使用批量操作报的异常信息: java.lang.RuntimeException: org.mybatis.s ...
- 解决mybatis foreach 错误: Parameter '__frch_item_0' not found
解决mybatis foreach 错误: Parameter '__frch_item_0' not found 在遍历对象的属性(是ArrayList对象)时报错: org.mybatis.spr ...
- mybatis批量更新报错badsql
mybatis批量更新时语法写的都对,但是报错,需要在连接上面加上allowMultiQueries=true 示例:jdbc:MySQL://192.168.1.236:3306/test?useU ...
- mybatis批量更新update-设置多个字段值 报错 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
mybatis批量更新update-设置多个字段值 2016年08月01日 12:49:26 姚一号 阅读数:29539 标签: mysql mybatis批量更新批量更新allowMultiQuer ...
- Mybatis批量更新<转>
Mybatis批量更新 批量操作就不进行赘述了.减少服务器与数据库之间的交互.网上有很多关于批量插入还有批量删除的帖子.但是批量更新却没有详细的解决方案. 实现目标 这里主要讲的是1张table中.根 ...
- Mybatis批量更新详解
转:http://www.cnblogs.com/winkey4986/p/3915151.html Mybatis批量更新 批量操作就不进行赘述了.减少服务器与数据库之间的交互.网上有很多关于批量插 ...
- mybatis批量更新两种方式:1.修改值全部一样 2.修改每条记录值不一样
Mybatis批量更新数据 mybatis批量更新两种方式:1.修改值全部一样 2.修改每条记录值不一样 mybatis批量更新两种方式:1.修改值全部一样 2.修改每条记录值不一样 mybatis批 ...
- mybatis批量更新策略
我们知道循环中操作db会导致连接数满,严重影响数据库性能.所以在对db进行DQL与DML时,根据业务逻辑尽量批量操作,这里我们介绍下使用mybatis批量更新mysql的两种方式. 方式一: < ...
随机推荐
- Ubuntu16.04安装cuda9.0+cudnn7.0
Ubuntu16.04安装cuda9.0+cudnn7.0 这篇记录拖了好久,估计是去年6月份就已经安装过几遍,然后一方面因为俺比较懒,一方面后面没有经常在自己电脑上跑算法,比较少装cuda和cudn ...
- 在SSL / https下托管SignalR
https://weblog.west-wind.com/posts/2013/Sep/23/Hosting-SignalR-under-SSLhttps 2013年9月23日•来自毛伊岛,HI• ...
- os模块walk方法
1.os.walk import os for root, dirs, files in os.walk(top, topdown=False): for name in files: os.remo ...
- Linux中设置服务自启动的三种方式,ln -s 建立启动软连接
有时候我们需要Linux系统在开机的时候自动加载某些脚本或系统服务(http://www.0830120.com) 主要用三种方式进行这一操作: ln -s 在/etc/rc.d/rc*.d目录中建立 ...
- ubuntu中vi下删除键和上下左右键的异常解决
解决办法: 卸载旧的vim apt-get remove vim-common 安装新的vim apt-get install vim tips:可是我发现,无论卸载还是安装都是版本为(2 ...
- python基础day2
一.python字符串 字符串是 Python 中最常用的数据类型.可以使用引号('或")来创建字符串 1.1Python访问字符串中的值 Python不支持单字符类型,单字符在 Pytho ...
- tomcat部署项目启动采坑之UnknownHostException
在一台新服务器上,把war包部署在tomcat上,很普通的很简单的一个活,但我踩到一个大坑. 需要组件tomcat8,mysql5.7,mosqquito1.5,centos7,war包,把组件都装好 ...
- [Python]CentOS - ImportError: No module named '_curses'
网上搜了不少答案, 基本都是说Windows环境下curses包不适用的问题. 作为碰到这个问题的linux用户,实在感到无奈. 起因是在CentOS上部署uwsgi,想要使用uwsgitop来监控. ...
- Android 性能优化之使用Lint
代码静态检查推荐: (1)Android自定义Lint实践 (2)美团外卖Android Lint代码检查实践 (3)Android自定义Lint实践2——改进原生Detector Lint 是 An ...
- Xmanager6 下载地址
Xmanager-6标准版下载地址 http://xiazai.xshellcn.com/trial/Xmanager-6.0.0080_yy.exe Xmanager-6企业版下载地址 http:/ ...