UsersRoles.hbm.xml
User.hbm.xml
Role.hbm.xml
就是说只要映射关系就行了,不用特别的设置,这张表要自己建立出来,不是自动生成的
在配置文件里写,比如说:teacher 和 student 的关系 一个学生可以有多个老师,一个老师也可以有多个学生 配置文件内容 --student一方的配置文件-- <set name="teachers" table="stu_tea_info"(中间表的)> <key column="sid">//中间表与student 关联的列 与student中的主键关联 <many-to-many class="teacher" column="tid">//teacher与中间表关联的列 与teacher主键关联 </set> --teacher一方的配置文件-- <set name="students" table="stu_tea_info"(中间表的)> <key column="tid">//此处column值必须与上面<many-to-many class="teacher" column="tid">处的column值一致 <many-to-many class="student" column="sid">//此处column值必须与上面 <key column="sid">的column值一致 </set>