Parameter 'ids' not found. Available parameters are [array]


传的参数是一个数组, Long[] ids

后台错误写法

   <delete id="deleteById">
        delete from table
       where id in 
    <foreach collection="ids" index="index" item="item" open="(" separator="," close=")">     
        #{item}    
    </foreach>
  </delete>

正确写法

   <delete id="deleteById">
         delete from table
       where id in 
    <foreach collection="array" index="index" item="item" open="(" separator="," close=")">     
        #{item}    
    </foreach>
  </delete>

当mybatis传入参数为list集合的时候;mybatis会自动把其封装为一个map;会以“list”作为key;每个元素的值作为value;格式为 Map<"list",value>

 

 

当mybatis传入参数为数组的时候mybatis会自动把其封装为一个map;会以“array”作为key;每个元素的值作为value;格式为Map<"array",value>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM