MyBatis查询单表返回List<Bean>

来源:互联网 发布:mac如何玩魔兽世界 编辑:程序博客网 时间:2024/06/05 16:50

本来以为把List<Bean> 封装在一个javabean里,然后在映射文件里配置一个<resultMap>然后利用<collection>进行封装就好了,确实可以,但是也比较麻烦,查了一下百度发现也没什么例子可以直接返回List


后来才知道只需要配置一个resultMap就好了



[html] view plain copy
 print?
  1. <span style="font-size:18px;"><resultMap type="Model.stu" id="studentList">  
  2.                 <result property="id" column="id"/>  
  3.                 <result property="student_name" column="student_name"/>  
  4.                 <result property="student_age" column="student_age"/>  
  5.         </resultMap>  
  6.       
  7.         <select id="selectSomeStudent" resultMap="studentList">  
  8.             select * from student limit #{f},#{r}  
  9.         </select></span>  


List<stu> selectSomeStudent(@Param("f")int firstResult,@Param("r")int maxResult);

原创粉丝点击