A 一对多 classes---->student (one--->many)
单向:
one
public class Classes {
private Integer id;
private String name;
private Set students; 在一的一方保存多的集合
}
many
public class Student {
private Integer id;
private String name;
}
B 多对一
单向
many
public class Student {
private Integer id;
private String name;
private Classes classes;在多的一方保留一的引用
}
one
public class Classes {
private Integer id;
private String name;
}
双向 一对多(one to many) / 多对一(many to one)
many
public class Student {
private Integer id;
private String name;
private Classes classes; 在多的一方保留一的引用
}
one
public class Classes {
private Integer id;
private String name;
private Set students; 在一的一方保存多的集合
}
多对多
单向
many1
public class Role{
private Integer id;
private String name;
private Set<User> users; 在任一方保留对方的set
}
many2
public class User{
private Integer id;
private String name;
}
双向
many1
public class Role{
private Integer id;
private String name;
private Set<User> users; 在两一方保留对方的set
}
many2
public class User{
private Integer id;
private String name;
private Set<Role> roles;在两方保留对方的Set
}