<class name="User" table="t_user">
<id name="id" column="id">
<generator class="native"></generator>
</id>
<property name="userName"></property>
<set name="address" table="lin">
<key column="uid"></key>
<element column="address" type="string"></element>
</set>
<list name="addressList" table="sam">
<key column="aid"></key>
<list-index column="idx"></list-index>
<element column="address" type="string"></element>
</list>
<id name="id" column="id">
<generator class="native"></generator>
</id>
<property name="userName"></property>
<set name="address" table="lin">
<key column="uid"></key>
<element column="address" type="string"></element>
</set>
<list name="addressList" table="sam">
<key column="aid"></key>
<list-index column="idx"></list-index>
<element column="address" type="string"></element>
</list>
</class>
这里的table要是在数据库中已经存在,要么在全局配置中写上这条<property name="hibernate.hbm2ddl.auto">update</property>