关联映射即:持久化类的属性 是 引用另一持久化类的类
1.单向 N-1映射 student - school 每个学生对应一个正在就读的学校 通过学生访问学校
1.1 无连接表
①POJO类
Student.java
Student类 由于要访问School类属性 ,所有要提供school属性 及setter getter 方法
package xy.po;
public class Student
{
public Student()
{
}
private int id;
private String name;
private School school;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public School getSchool() {
return school;
}
public void setSchool(School school) {
this.school = school;
}
public void setId(int id) {
this.id = id;
}
public int getId() {
return id;
}
}
School.java
School类就是一普通的持久化类
package xy.po;
public class School
{
public School()
{
}
private int id;
private String name;
public String getName() {
return name;
}
public void setName(Strin