您的位置:首页 > 大数据 > 人工智能

Mybatis:Parameter 'list' not found. Available parameters are [termIds, eventIds, param1, param2]

2017-09-10 19:11 2451 查看
我的EsdTemplateSealMapper.java里面定义的接口是这样的

List<SchoolCalendarEntity> selectForSchoolCalendar(@Param("termIds") List<String> termIds, @Param("eventIds") List<String>eventIds);


 然后我的EsdTemplateSealMapper.xml里面的sql是这样的:

<select id="getFilteOutSeal" resultMap="BASE_RESULT_MAP">
select t.TEMPLATE_ID, t.SEAL_ID, t.SEAL_TYPE, t.DATA_SRC, t.VERSION
from ESD_TEMPLATE_SEAL t
where t.TEMPLATE_ID=#{templateId,jdbcType=VARCHAR}
and t.SEAL_TYPE not in
<foreach item="item" collection="list" separator="," open="(" close=")" index="">
#{0}
</foreach>
</select>


也写过这样的:

<select id="getFilteOutSeal" resultMap="BASE_RESULT_MAP">
select t.TEMPLATE_ID, t.SEAL_ID, t.SEAL_TYPE, t.DATA_SRC, t.VERSION
from ESD_TEMPLATE_SEAL t
where t.TEMPLATE_ID=#{templateId,jdbcType=VARCHAR}
and t.SEAL_TYPE not in
<foreach item="item" collection="list" separator="," open="(" close=")" index="">
#{filterList}
</foreach>
</select>


控制台都报类似:“

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'list' not found. Available parameters are [templateId, param1, param2, valueList]

”的问题,

最终的解决方案是:

<select id="getFilteOutSeal2" parameterType="map" resultMap="BASE_RESULT_MAP">
select t.TEMPLATE_ID, t.SEAL_ID, t.SEAL_TYPE, t.DATA_SRC, t.VERSION
from ESD_TEMPLATE_SEAL t
where t.TEMPLATE_ID=#{id}
and t.SEAL_TYPE not in
<foreach item="item" collection="filterList" separator="," open="(" close=")" index="index">
#{item}
</foreach>
</select>


ps:网上的解释实在坑爹,根本原因就是他们根本就没有理解foreach里面的collection应该放什么东西,错误的理解里面放的是java.util.List,其实这个类型应该是和我们的@Param绑定的参数名一致
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐