sql 查詢返回實體類,實體類中裝有一個集合


1.實體類中的字段,get/set 方案自己生成,這里就不寫了,list里面裝的是另一個實體對象

public class StudentBillBean {
private String studentId;
private String child_name;
private String school_pid;
private String school_no;
private String grade;
private String class_in;
private List<ParentBillBean> users;

2.然后在mapper里面對應的關聯

<resultMap id="Studnetbill" type="實體類的路徑" >
<result column="studentId" property="studentId"/>
<result column="child_name" property="child_name"/>
<result column="class_in" property="class_in"/>
<result column="grade" property="grade"/>
<result column="school_no" property="school_no"/>
<result column="school_pid" property="school_pid"/>
<collection property="users" ofType="List中實體類的路徑">
<result column="user_name" property="user_name"/>
<result column="user_mobile" property="user_mobile"/>
<result column="user_relation" property="user_relation"/>
</collection>
</resultMap>
3.然后就可以寫sql進行查詢了

 






免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM