mybatis的mapper返回map结果集

通过MapKey指定map的key值

@MapKey("id")
Map getUserInfoMap();

@MapKey("id")
Map> getUserValueMap();

map的value为java类

<resultMap id="UserResultMap" type="com.xixicat.domain.UserInfo">
        <result property="id" column="id" />
        <result property="username" column="username" />
        <result property="sex" column="sex" />
    resultMap>
<select id="getUserInfoMap" resultMap="UserResultMap">
   select id,username,sex from user_info
select>

map的value为map

<select id="getUserValueMap" resultType="map" >
        select id,username,sex from user_info
        from user_info
select>

你可能感兴趣的:(java)