Mapper of mybatis returns map result set

  mybatis

Mybatis series

Specify the key value of map through MapKey.

@MapKey("id")
Map<Long, UserInfo> getUserInfoMap();

@MapKey("id")
Map<Long, Map<String,Object>> getUserValueMap();

Map’s value is a java class.

<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>

The value of map is map.

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