一、读取到一个list中
public ArrayList<teacher> SelectUsers(@Param("name")String name);
<!--
模糊查询,获取多条记录,封装成list,但是result类型为里面元素的类型
-->
<select id="SelectUsers" parameterType="String" resultType="teacher">
select id,t_name as name from `tb_Teacher` where t_name like #{name}
</select>
二、单条记录读取到Map中
//map 单条记录
public HashMap<String, Object> SelectUsers2(@Param("name")String name);
<!-- map 获取单条记录
key:属性
value:值
-->
<select id="SelectUsers2" parameterType="String" resultType="map">
select id,t_name as name from `tb_Teacher` where t_name = #{name}
</select>
三、多条记录读取到map中
//map多条记录
@MapKey("id")
public HashMap<Integer, teacher> SelectUsers3(@Param("name")String name);
<!-- map 获取多条记录
key:id(或其他属性列)
value:pojo
-->
<select id="SelectUsers3" parameterType="String" resultType="teacher">
select id,t_name as name from `tb_Teacher` where t_name like #{name}
</select>