Hibernate映射_html/css_WEB-ITnose
时间:2021-07-01 10:21:17
帮助过:31人阅读
一对一
XML/HTML代码
- < class name = "Person" table = "t_person" >
- < id name = "id" >
- < generator class = "native" > generator >
- id >
- < property name = "name" > property >
-
- < set name = "employees" inverse = "true" >
- < key column = "deptId" > key >
- < one-to-many class = "Employee" />
- set >
- class >
XML/HTML代码
- < class name = "Employee" table = "t_employee" >
- < id name = "id" >
- < generator class = "native" > generator >
- id >
- < property name = "name" > property >
-
- < many-to-one name = "department" class = "Department" column = "deptId" > many-to-one >
- class >
多对多
XML/HTML代码
- < class name = "Teacher" table = "t_teacher" >
- < id name = "id" >
- < generator class = "native" > generator >
- id >
- < property name = "name" > property >
- < set name = "students" table = "t_student_teacher" >
- < key column = "teacher_id" > key >
- < many-to-many class = "Student" column = "student_id" > many-to-many >
- set >
- class >
XML/HTML代码
- < class name = "Student" table = "t_student" >
- < id name = "id" >
- < generator class = "native" > generator >
- id >
- < property name = "name" > property >
- < set name = "teachers" table = "t_student_teacher" >
- < key column = "student_id" > key >
- < many-to-many class = "Teacher" column = "teacher_id" > many-to-many >
- set >
- class >