nested exception is org.apache.ibatis.binding.BindingException
之前写代码的时候,想写一个批量的删除,我在mybatis层的xml中的sql是这样写的:
<delete id="deleteByHpccIds" parameterType="List">
delete from pf_hpccdev_info
where hpcc_id in
<foreach collection="hpccIds" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach> -
</delete>
然后就报了下面的错误:
Caused by: org.apache.ibatis.binding.BindingException: Parameter '__frch_item_0' not found. Available parameters are [oprInfo, hpccIds, param1, param2]
at org.apache.ibatis.binding.MapperMethod$ParamMap.get(MapperMethod.java:202)
at org.apache.ibatis.reflection.wrapper.MapWrapper.get(MapWrapper.java:45)
at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:122)
at com.chinacache.common.database.dao.PageInterceptor.setParameters(PageInterceptor.java:401)
at com.chinacache.common.database.dao.PageInterceptor.doInsert(PageInterceptor.java:309)
at com.chinacache.common.database.dao.PageInterceptor.interceptDelete(PageInterceptor.java:282)
at com.chinacache.common.database.dao.PageInterceptor.intercept(PageInterceptor.java:69)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61)
at com.sun.proxy.$Proxy458.prepare(Unknown Source)
at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:85)
at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:49)
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)
at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:198)
at org.apache.ibatis.session.defaults.DefaultSqlSession.delete(DefaultSqlSession.java:213)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)
其实就是这样一个简单的删除,但是不知道问题出在哪了,后来想着把xml中的sql改一下,其实就是抱着试试的想法,然后就好了,改过之后的sql:
<delete id="deleteByHpccIds" parameterType="List">
delete from pf_hpccdev_info
where hpcc_id in
<foreach collection="hpccIds" item="item" index="index" open="(" separator="," close=")">
#{hpccIds[${index}],jdbcType=INTEGER}
</foreach>
</delete>
虽然把问题解决了,但不知道第一个sql的写法为什么不行!