mybatis 查询返回Map<String,Object>类型
作者:菜鸟笔记
本文主要介绍了mybatis 查询返回Map<String,Object>类型,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
mybatis 查询返回Map<String,Object> 类型,平时没太注意怎么用,今天又遇到了总结记录一下,方便以后处理此类问题。
Mapper.java中的方法:
@MapKey("userId")
Map<String,UserInfo> personalInfoByUserIds(List<String> list);mapper.xml文件中的配置:
<resultMap id="BaseResultMap" type="com.*.*.entity.UserInfo">
<id column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="user_code" jdbcType="INTEGER" property="userCode" />
<result column="user_name" jdbcType="VARCHAR" property="userName" />
<result column="user_gender" jdbcType="INTEGER" property="userGender" />
<result column="mobile_phone" jdbcType="VARCHAR" property="mobilePhone" />
<result column="birthday" jdbcType="DATE" property="birthday" />
</resultMap>
<select id="personalInfoByUserIds" resultMap="BaseResultMap">
select * from t_user_info i where i.user_id in
<foreach collection="list" item="item" separator="," open="(" close=")" index="index">
#{item}
</foreach>
</select>返回结果如下:

到此这篇关于mybatis 查询返回Map<String,Object>类型的文章就介绍到这了,更多相关mybatis 返回Map<String,Object>类型内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
