当前位置:Gxlcms > html代码 > Hibernate映射_html/css_WEB-ITnose

Hibernate映射_html/css_WEB-ITnose

时间:2021-07-01 10:21:17 帮助过:31人阅读

一对一

XML/HTML代码

  1. < class name = "Person" table = "t_person" >
  2. < id name = "id" >
  3. < generator class = "native" >
  4. < property name = "name" >
  5. < set name = "employees" inverse = "true" >
  6. < key column = "deptId" >
  7. < one-to-many class = "Employee" />

XML/HTML代码

  1. < class name = "Employee" table = "t_employee" >
  2. < id name = "id" >
  3. < generator class = "native" >
  4. < property name = "name" >
  5. < many-to-one name = "department" class = "Department" column = "deptId" >

多对多

XML/HTML代码

  1. < class name = "Teacher" table = "t_teacher" >
  2. < id name = "id" >
  3. < generator class = "native" >
  4. < property name = "name" >
  5. < set name = "students" table = "t_student_teacher" >
  6. < key column = "teacher_id" >
  7. < many-to-many class = "Student" column = "student_id" >

XML/HTML代码

  1. < class name = "Student" table = "t_student" >
  2. < id name = "id" >
  3. < generator class = "native" >
  4. < property name = "name" >
  5. < set name = "teachers" table = "t_student_teacher" >
  6. < key column = "student_id" >
  7. < many-to-many class = "Teacher" column = "teacher_id" >

人气教程排行