mybatis返回list<Integer>时resultType写Integer问题
目录
- myBATis返回list<Integer>时resultType写Integer
- mybatis forEach List<Integer>
- 总结
mybatis返回list<Inte编程ger>时resultType写Integer

查询出的结果可能有好多条记录,返回类型即是list。
但resultType还是写成resultType="user"(user为集合list中的实体类),而不是写成resultType="Java.util.Ljsist"
mybatis返回list<Integer>时resultType写java.lang.Integer而不是java.util.List
如果写成java.util.List时会报错
error querying database.the error occurred while handling results.
mybatis forEach List<Integer>
DAO内容:
List<ItEquipmentHeadersCustom> selectByListLocationId(@Param("locationIdList")List<Integer> locationIdList);
XML文件内容:
<select id="selectByListLocationId" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM IT.IT_EQUIPMENT_HEADERS ieh
wherVVXmYMBe LOCATION_ID in
<foreach item="item" index="index" open="(" separator="," close=")" collpythonection="locationIdList">
javascript#{item}
</foreach>
</select>
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程客栈(www.devze.com)。
加载中,请稍侯......
精彩评论