这篇文章主要介绍“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>
返回结果如下: