1. When using the set in (X,x ... The parameters can be single or multiple when they are single:
Findbyids (list<long> IDs), or Findbyids (Long [] IDs)
<select id= "Findbyidsmap" resultmap= "Baseresultmap" >
Select
<include refid= "Base_column_list"/>
From Jria where ID in
Open= "(" separator= "," close= ")" >
#{item}
</foreach>
collection= "Array" when an array is set
2 When there are multiple parameters for a query, such as Findbyids (String name, long[] IDs)
This situation requires special attention, when passing parameters, be sure to use the map mode, so that the collection property can specify the name
Here is an example
map<string, object> params = new hashmap<string, object> (2);
Params.put ("name", name);
Params.put ("IDs", IDS);
Mapper.findbyidsmap (params);
<select id= "Findbyidsmap" resultmap= "Baseresultmap" >
Select
<include refid= "Base_column_list"/>
From Jria where ID in
<foreach item= "item" index= "index" collection= "IDs "
open= "(" separator= "," close= ")" >
#{item}
</foreach>
</select>
Recently used MySQL and mybatis to combine common knowledge points to sit down and organize