mybatis返回list<Integer>时resultType写Integer问题
作者:qq_34412985
这篇文章主要介绍了mybatis返回list<Integer>时resultType写Integer问题,具有很好的参考价值,希望对大家有所帮助,
mybatis返回list<Integer>时resultType写Integer

查询出的结果可能有好多条记录,返回类型即是list。
但resultType还是写成resultType="user"(user为集合list中的实体类),而不是写成resultType="java.util.List"
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
where LOCATION_ID in
<foreach item="item" index="index" open="(" separator="," close=")" collection="locationIdList">
#{item}
</foreach>
</select>总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
