Parameter 'XXX' not found. Available parameters are [collection, list]] with root cause

在使用mybatis的時候,mapper只傳了一個list集合參數,結果就報錯:

Parameter 'roleIds' not found. Available parameters are [collection, list]] with root cause

就是說這個參數沒有找到, 這個時候可以用@Param指定參數就行了。
mapper

import org.apache.ibatis.annotations.Param;
int deleteByIds(@Param("roleIds") List<String> roleIds);

mapper.xml

    <delete id="deleteByIds" parameterType="java.util.List">
         delete from role where id in
         <foreach collection="roleIds" item="item" separator="," open="(" close=")" >
             #{item, jdbcType=INTEGER}
         </foreach>
    </delete>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章