欢迎来到天天文库
浏览记录
ID:34724546
大小:49.43 KB
页数:4页
时间:2019-03-10
《mybatis多参数传递且其中一个参数传多个值用in》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、1.当查询的参数只有一个时 findByIds(Listids)1.a如果参数的类型是List,则在使用时,collection属性要必须指定为listSelectfromjriawhereIDin2、arator=","close=")">#{item} findByIds(Long[]ids)1.b如果参数的类型是Array,则在使用时,collection属性要必须指定为arrayselectfromjriawhereIDin3、x"collection="array" open="("separator=","close=")">#{item} 2.当查询的参数有多个时,例如findByIds(Stringname,Long[]ids)这种情况需要特别注意,在传参数时,一定要改用Map方式,这样在collection属性可以指定名称下面是一个示例Mapparams=newHashMap(2);params.put("nam4、e",name);params.put("ids",ids);mapper.findByIdsMap(params);selectfromjriawhereIDin#{it5、em} 完整的示例如下:例如有一个查询功能,Mapper接口文件定义如下方法:ListfindByIds(Long...ids);使用in查询的sql拼装方法如下:selectfromjriawhereIDin6、ion="array" open="("separator=","close=")">#{item}例子:Mapper.xml中SELECTFROMt_bi_equ7、ipmentwhere0=0andEQUIPMENT_STOCK_STATUS=#{equipmentStockStatue,jdbcType=INTEGER}andEQUIPMENT_STATUSin8、index"collection="equipmentStatue"open="("separator=","close=")">#{item}Mapper中ListselectByStockAndEquipmentStatus(Mapparams);Service中ListselectByStockAndEquipmentStatus(intequipmentS
2、arator=","close=")">#{item} findByIds(Long[]ids)1.b如果参数的类型是Array,则在使用时,collection属性要必须指定为arrayselectfromjriawhereIDin3、x"collection="array" open="("separator=","close=")">#{item} 2.当查询的参数有多个时,例如findByIds(Stringname,Long[]ids)这种情况需要特别注意,在传参数时,一定要改用Map方式,这样在collection属性可以指定名称下面是一个示例Mapparams=newHashMap(2);params.put("nam4、e",name);params.put("ids",ids);mapper.findByIdsMap(params);selectfromjriawhereIDin#{it5、em} 完整的示例如下:例如有一个查询功能,Mapper接口文件定义如下方法:ListfindByIds(Long...ids);使用in查询的sql拼装方法如下:selectfromjriawhereIDin6、ion="array" open="("separator=","close=")">#{item}例子:Mapper.xml中SELECTFROMt_bi_equ7、ipmentwhere0=0andEQUIPMENT_STOCK_STATUS=#{equipmentStockStatue,jdbcType=INTEGER}andEQUIPMENT_STATUSin8、index"collection="equipmentStatue"open="("separator=","close=")">#{item}Mapper中ListselectByStockAndEquipmentStatus(Mapparams);Service中ListselectByStockAndEquipmentStatus(intequipmentS
3、x"collection="array" open="("separator=","close=")">#{item} 2.当查询的参数有多个时,例如findByIds(Stringname,Long[]ids)这种情况需要特别注意,在传参数时,一定要改用Map方式,这样在collection属性可以指定名称下面是一个示例Mapparams=newHashMap(2);params.put("nam
4、e",name);params.put("ids",ids);mapper.findByIdsMap(params);selectfromjriawhereIDin#{it
5、em} 完整的示例如下:例如有一个查询功能,Mapper接口文件定义如下方法:ListfindByIds(Long...ids);使用in查询的sql拼装方法如下:selectfromjriawhereIDin6、ion="array" open="("separator=","close=")">#{item}例子:Mapper.xml中SELECTFROMt_bi_equ7、ipmentwhere0=0andEQUIPMENT_STOCK_STATUS=#{equipmentStockStatue,jdbcType=INTEGER}andEQUIPMENT_STATUSin8、index"collection="equipmentStatue"open="("separator=","close=")">#{item}Mapper中ListselectByStockAndEquipmentStatus(Mapparams);Service中ListselectByStockAndEquipmentStatus(intequipmentS
6、ion="array" open="("separator=","close=")">#{item}例子:Mapper.xml中SELECTFROMt_bi_equ
7、ipmentwhere0=0andEQUIPMENT_STOCK_STATUS=#{equipmentStockStatue,jdbcType=INTEGER}andEQUIPMENT_STATUSin8、index"collection="equipmentStatue"open="("separator=","close=")">#{item}Mapper中ListselectByStockAndEquipmentStatus(Mapparams);Service中ListselectByStockAndEquipmentStatus(intequipmentS
8、index"collection="equipmentStatue"open="("separator=","close=")">#{item}Mapper中ListselectByStockAndEquipmentStatus(Mapparams);Service中ListselectByStockAndEquipmentStatus(intequipmentS
此文档下载收益归作者所有