<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- Mapping file autogenerated by MyEclipse Persistence Tools --> <hibernate-mapping> <class name="cn.bdqn.studentInfo.entity.Teacher" table="Teacher"> <id name="id"> <generator class="assigned" /> </id> <property name="name" > </property> <!-- 多对多关系映射 --> <!-- name:映射对方表的属性名 ttable:关系表的名字 inverse:是否维护关系,false的话,另一方进行维护,true的话,该方进行维护 --> <set name="students" table="student_teacher" cascade="all"> <!-- name:该表的外键 --> <key> <column name="teacherId"/> </key> <!-- class:多对多的另一方的实体类 column:另一方的外键 --> <many-to-many class="cn.bdqn.studentInfo.entity.Student" column="studentid"></many-to-many> </set> </class> </hibernate-mapping>