===========================模板================================
一对多(Set)
<set name="">
<key column=""/>
<one-to-many class=""/>
</set>
多对一
<many-to-one name="" class="" column=""/>
多对多(Set)
<set name="" table="">
<key column=""/>
<many-to-many class="" column=""/>
</set>
一对一(基于外键的有外键方)
<many-to-one name="" class="" column="" unique="true"/>
一对一(基于外键的无外键方)
<one-to-one name="" class="" property-ref=""/>
===========================填空=================================
<!-- privileges属性,表示与Privilege的多对多关系-->
--------1---------------------2---------3-----------------------
1、name属性:填 1
2、class属性:填 2
3、column属性:
在many-to-one中:写本条配置中的name属性值加Id后缀
在一对多的<key>中:写对方类的表达此关系的外键名
在多对多的<key>中:写自己类的名称加Id后缀
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.jxlg.bean">
<class name="Privilege" table="t_privilege">
<id name="id">
<generator class="native"/>
</id>
<property name="action"/>
<!--accounts属性,表示与UserAccount的多对多关系-->
<set name="accounts" table="t_userAccount_privilege">
<key column="privilegeId"/>
<many-to-many class="UserAccount" column="userAccountId"/>
</set>
</class>
</hibernate-mapping>
一对多(Set)
<set name="">
<key column=""/>
<one-to-many class=""/>
</set>
多对一
<many-to-one name="" class="" column=""/>
多对多(Set)
<set name="" table="">
<key column=""/>
<many-to-many class="" column=""/>
</set>
一对一(基于外键的有外键方)
<many-to-one name="" class="" column="" unique="true"/>
一对一(基于外键的无外键方)
<one-to-one name="" class="" property-ref=""/>
===========================填空=================================
<!-- privileges属性,表示与Privilege的多对多关系-->
--------1---------------------2---------3-----------------------
1、name属性:填 1
2、class属性:填 2
3、column属性:
在many-to-one中:写本条配置中的name属性值加Id后缀
在一对多的<key>中:写对方类的表达此关系的外键名
在多对多的<key>中:写自己类的名称加Id后缀
在多对多的many-to-many的column中:写对方类的名称加Id后缀
使用案例
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.jxlg.bean">
<class name="Privilege" table="t_privilege">
<id name="id">
<generator class="native"/>
</id>
<property name="action"/>
<!--accounts属性,表示与UserAccount的多对多关系-->
<set name="accounts" table="t_userAccount_privilege">
<key column="privilegeId"/>
<many-to-many class="UserAccount" column="userAccountId"/>
</set>
</class>
</hibernate-mapping>