Mybatis 返回Map类型

1.mybatis返回map.

(1)返回一条记录的map,其中key是列名,value是列所对应的值。

例如:

接口方法:public Map selectByTaskId(String taskId);

Sql语句:<select id="selectByTaskId" resultType="map">

                       select * from tb_sp_filter 

                       

                                task_id=#{task_id, jdbcType=VARCHAR}

                       

                select>

(2)返回多条记录封装一个map,其中key是map的主键,value是当前这条记录封装后的Javabean。用@MapKey注解在方法上指明用哪个列作为map的主键。

例如:

接口方法:@MapKey("taskId")

                public Map selectFilterListReturnMap();

Sql语句:<select id="selectFilterListReturnMap"  resultType="map">

                       select * from tb_sp_filter

               select>

你可能感兴趣的:(mybatis)