mybatis返回list<Integer>时resultType写Integer问题
更新时间:2023年12月06日 09:29:54 作者: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>总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
相关文章
SpringBoot3.3.X整合Mybatis-Plus的实现示例
本文介绍了在Spring Boot 3.3.2中整合MyBatis-Plus 3.5.7,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧2025-03-03
Spring中的@EnableScheduling定时任务注解
这篇文章主要介绍了Spring中的@EnableScheduling注解,@EnableScheduling是 Spring Framework 提供的一个注解,用于启用 Spring 的定时任务功能,通过使用这个注解,可以在 Spring 应用程序中创建定时任务,需要的朋友可以参考下2024-01-01


最新评论