Posted on 2009-05-19 15:28
陕西BOY 阅读(713)
评论(0) 编辑 收藏
many to one 就是说多条信息对应同一条信息。如:许多的学生属于同一个学校
<hibernate-mapping package="com.test.Bean">
<!--学生-->
<class name="People" table="people">
<id name="id" column="id">
<generator class="native"></generator>
</id>
<property name="name" column="name"></property>
<ont-to-many name="id" column="id" class="School"></one-to-many> //一所学校对应多个学生
</class>
<!--学校-->
<class name="School" table="school">
<id name="id" column="id">
<generator class="native"></generator>
</id>
<property name="schoolName" column="school_name"></property>
<many-to-one name="pid" column="p_id" class="People"></many-to-one> //多个学生对应一所学校
</class>
</hibernate-mapping>