根据下面的配置信息,写出Classes,Teacher和Student这三个POJO的全部代码。<mapper namespace="com.lcb.mapping.userMapper"> <l--association—对—关联查询--> <select id="getClass" parameterType="int" resultMap="ClassesResultMap">select * from class c,teacher t where c.teacher_id=t.t_id and c.c_id=#{id} <select> <resultMap type="com.lcb.user.Classes" id="ClassesResultMap"><l--实体类的字段名和数据表的字段名映射--> <id property="id" column="c_id"/> <result property="name" column="c_name"/><association property="teacher" javaType="com.Icb.user.Teacher"><id property="id" column="t_id" l> <result property="name" column="t_name"/></association> </resultMap> <l--collection—对多关联查询--> <select id="getClass2" parameterType="int"resultMap="ClassesResultMap2"> select * from class c,teacher t,student s where c.teacher_id=t.t_idand c.c_id=s.class_id and c.c_id=#{ id} <select> <resultMap type="com.lcb.user.Classes" id="ClassesResultMap2"><id property=""id" column="c_id"/> <result property="name" column="c_name"/><association property="teacher" javaType="com.Icb.user.Teacher"><id property="id" column="t_id"l> <result property="name" column="t_name"/></association> <collection property="student" ofType="com.Icb.user.Student"><id property="id" column="s_id"/> cresult property="name" column="s_name"/></collection> </resultMap></mapper>
时间: 2023-06-02 19:04:44 浏览: 187
1. Classes POJO代码:
public class Classes {
private int id;
private String name;
private int teacherId;
private Teacher teacher;
// 省略getter和setter方法
}
2. Teacher POJO代码:
public class Teacher {
private int id;
private String name;
// 省略getter和setter方法
}
3. Student POJO代码:
public class Student {
private int id;
private String name;
private int age;
private int classId;
private Classes classes;
// 省略getter和setter方法
}
阅读全文