<set name ='students' table="students_table" inverse='false'(默认不用写) > <key column="student_id"/> <many-to-many column="teacher_id" class="com.nedhome.person.Teachers"> </ set> <set name="teacher" table="teacher_table" inverse="true"> <key column="teacher_id"/> <many-to-many column="student_id" class="com.nedhome.person.Teacher"/> </ set> 当student.add(teacher)时因为student的inverse是false,所以在更新student_table表也更新teacher_table表; 当teacher.add(student)时因为teacher的inverse是true,所以只更新teacher_table表;
转自:http://blog.csdn.net/leader_lx/archive/2008/08/06/2774137.aspx