测试类
public void selectReturnList() throws IOException { start(); PersonMapper mapper = sqlSession.getMapper(PersonMapper.class); List list = mapper.getPersonByLikeName("%t%");//名字里带e字母的 System.out.println(list.toString()); sqlSession.close(); log.debug("test"); }需要知道map的key是什么东西,如指定为主键或其他列名
@MapKey("pId") public Map<Integer,Person> getPersonByIdReturnMutipleMap(@Param("p_Name") String name); <!--返回多条map 返回值为<Integer,Person> 对应 主键+对象 【resultType】还是写map里的实体类类型而不是写map --> <select id="getPersonByIdReturnMutipleMap" resultType="com.yiki.Entity.Person"> select * from Person where p_name like #{p_Name} </select> public void selectReturnMutipleMap() throws IOException { start(); PersonMapper mapper = sqlSession.getMapper(PersonMapper.class); Map map = mapper.getPersonByIdReturnMutipleMap("tiffany"); System.out.println(map); //key value //1 person1 //2 person2 System.out.println(map.get(1)); sqlSession.close(); log.debug("test"); }