一对多结果映射(xml)
样例1:list 对象类型
public class Teacher{
private String tname;
private String tage;
private List<Student> students;
}
xml:
<resultMap id="testMap" type="org.example.controller.Teacher">
<result property="tname" column="name"></result>
<result property="tage" column="name"></result>
<collection property="students" ofType="org.example.controller.Student">
<result property="" column=""></result>
<result property="" column=""></result>
<result property="" column=""></result>
</collection>
</resultMap>
样例1:list String类型
public class Teacher {
private String tname;
private String tage;
//private List<Student> students;
private List<String> studentIds;
}
<resultMap id="testMap" type="org.example.controller.Teacher">
<result property="tname" column="name"></result>
<result property="tage" column="name"></result>
<collection property="students" ofType="org.example.controller.Student">
<result column="student_id"></result>
</collection>
</resultMap>