hibernate 多对多配置 person表:id,person_name book表:id,book_name person_book中间表:person_id,bhibernate 多对多配置person表:id,person_namebook表:id,book_nameperson_book中间表:person_id,book_id这三张表如何配置hib
来源:学生作业帮助网 编辑:作业帮 时间:2024/09/04 08:04:20
hibernate 多对多配置 person表:id,person_name book表:id,book_name person_book中间表:person_id,bhibernate 多对多配置person表:id,person_namebook表:id,book_nameperson_book中间表:person_id,book_id这三张表如何配置hib
hibernate 多对多配置 person表:id,person_name book表:id,book_name person_book中间表:person_id,b
hibernate 多对多配置
person表:id,person_name
book表:id,book_name
person_book中间表:person_id,book_id
这三张表如何配置hibernate ?关键是中间表
hibernate 多对多配置 person表:id,person_name book表:id,book_name person_book中间表:person_id,bhibernate 多对多配置person表:id,person_namebook表:id,book_nameperson_book中间表:person_id,book_id这三张表如何配置hib
Person类
public class Person implements Serializable{
private int id;
private String person_name;
private Set sc = new HashSet();
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getPerson_name() {
return person_name;
}
public void setPerson_name(String person_name) {
this.person_name = person_name;
}
public Set getSc() {
return sc;
}
public void setSc(Set sc) {
this.sc = sc;
}
}
Book类
public class Book implements Serializable{
private int id;
private String book_name;
private Set sc = new HashSet();
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getBook_name() {
return book_name;
}
public void setBook_name(String book_name) {
this.book_name = book_name;
}
public Set getSc() {
return sc;
}
public void setSc(Set sc) {
this.sc = sc;
}
}
Person_Book类
public class Person_Book implements Serializable{
private int id;
private Person person;
private Course course;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public Person getPerson() {
return person;
}
public void setPerson(Person person) {
this.person = person;
}
public Course getC() {
return c;
}
public void setC(Course c) {
this.c = c;
}
}
------------------------
Hbm文件,仅供参考,package包名什么的自己改下!建议在person_book表里面加个id属性
------------------------
person表
----------------------------
book表