Mybatis 传输List的实现代码
1.当查询的参数只有一个时
findByIds(Listids)
1.1如果参数的类型是List,则在使用时,collection属性要必须指定为list
Xml代码
Select fromjriawhereIDin #{item} Select fromjriawhereIDin #{item} findByIds(Long[]ids)
1.2如果参数的类型是Array,则在使用时,collection属性要必须指定为array
Xml代码
select fromtabswhereIDin #{item} select fromtabswhereIDin #{item}
2.当查询的参数有多个时,例如findByIds(Stringname,Long[]ids)
这种情况需要特别注意,在传参数时,一定要改用Map方式,这样在collection属性可以指定名称
下面是一个示例
Mapparams=newHashMap (2); params.put("name",name); params.put("ids",ids); mapper.findByIdsMap(params);
Xml代码
select fromtabswhereIDin #{item}
总结
以上所述是小编给大家介绍的Mybtis传输List的实现代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对毛票票网站的支持!