MyBatis查询单表返回List

来源:互联网 发布:小榕sql注入工具 编辑:程序博客网 时间:2024/06/04 23:25

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


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



<resultMap type="Model.stu" id="studentList"><result property="id" column="id"/><result property="student_name" column="student_name"/><result property="student_age" column="student_age"/></resultMap><select id="selectSomeStudent" resultMap="studentList">select * from student limit #{f},#{r}</select>


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

0 0
原创粉丝点击