MyBatis-sqlMapper傳入List型別引數,返回List型別引數。
阿新 • • 發佈:2019-01-28
Mapper.java
public interface StorageMapper extends BaseMapper<Storage> {
List<Integer> getStorageIdByChannelId(List<Integer> channelIds);
}
mapper.xml
<select id="getStorageIdByChannelId" resultType="java.lang.String"> select storage_id from res_storage <where> <if test="#{0} != null and #{0}.size() != 0"> channel_id in <foreach item="tempId" collection="list" open="(" separator="," close=")"> #{tempId} </foreach> </if> </where> </select>
resultType設定成String,myBatis會自動將結果轉成List集合。