Mybatis 封装返回 List or Map

文章目录

List

List<Employee> getEmpLikeLastNameReturnList(String lastName);
<select id="getEmpLikeLastNameReturnList" resultType="emp">
    select * from tab_empoyee where last_name like #{params1}
</select>

MAP 单条记录

Map Key为表的主键,值为Value

Map<Integer,Object> getEmpLikeLastNameReturnMap(Internet id);
<select id="getEmpLikeLastNameReturnMap" resultType="map">
    select * from tab_empoyee where id=#{params1}
</select>

MAP 多条记录

@MapKey注解指定map的key

@MapKey("id")
    Map<Integer,Employee> getEmpLikeLastNameReturnMap(String lastName);
<select id="getEmpLikeLastNameReturnMap" resultType="map">
    select * from tab_empoyee where last_name like #{params1}
</select>
原文链接:,转发请注明来源!

发表评论