MyBatis return list<object> method

Source: Internet
Author: User

Ah, looked for a long time Baidu, unexpectedly there is no direct example ... Own reference to other examples, wrote a ...

Other ignores, directly on the key code:

Transfer from http://www.xuebuyuan.com/782623.html

Pojo class:

Package Com.mymaven.mybatisdemo.po;public class Department {private string dp_id;private string Dp_name;private string Cost_center;public String getdp_id () {return dp_id;} public void setdp_id (String dp_id) {this.dp_id = dp_id;} Public String Getdp_name () {return dp_name;} public void Setdp_name (String dp_name) {this.dp_name = Dp_name;} Public String Getcost_center () {return cost_center;} public void Setcost_center (String cost_center) {this.cost_center = Cost_center;} Public Department () {super ();}}

Mapper Interface:

Public interface Departmentmapper {//query returns a listpublic list<department> queryalldepartment ();}

Mapper the corresponding configuration file:

<!--here namespace need to specify DAO interface--><mapper namespace= "Com.mymaven.mybatisdemo.dao.DepartmentMapper" >    <!--Configure a resultmap to specify the type returned--    <resultmap id= "departMent" type= "departMent" >        <id column= "Dp_ ID "property=" dp_id "/>        <result column=" Dp_name "property=" Dp_name "/> <result        column=" Cost_ Center "property=" Cost_center "/>    </resultMap>    <!--returns a list of the notation--    <select id=" Queryalldepartment "  resultmap=" departMent ">        select * from T_department    </select>   </ Mapper>

Attention
<select id= "queryalldepartment"  resultmap= "DepartMent" Here the return type is Resultmap, not resulttype. I got it wrong.

MyBatis return list<object> method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.