/hibernate_03(xml)/src/cn/itcast/domain/Customer.hbm.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<!-- 配置类和表的映射 -->
<class name="cn.itcast.domain.Customer" table="cst_customer">
<!-- 配置主键和属性的映射 -->
<id name="cust_id" column="cust_id">
<!--
native: 使用都是数据库的自增
如果用的是mysql: auto_increment
如果用的是oracle: 序列
uuid: 针对的是字符串类型
自动给你生成唯一的字符串来保证oid的唯一
-->
<generator class="native"></generator>
</id>
<!-- 配置其它字段和其它属性的映射 -->
<property name="cust_name" column="cust_name"></property>
<property name="cust_source" column="cust_source"></property>
<property name="cust_industry" column="cust_industry"></property>
<property name="cust_level" column="cust_level"></property>
<property name="cust_address" column="cust_address"></property>
<property name="cust_phone" column="cust_phone"></property>
<!-- 配置一对多的关系 集合(linkmans)-->
<!--
name:集合的名字
inverse:true 指定放弃外键的维护权
cascade: save-update 级联保存
delete:级联删除
lazy: true 默认值 默认使用延迟加载
false 不使用延迟加载 立即加载
-->
<set name="linkmans" inverse="true" cascade="save-update,delete" lazy="false">
<!-- 外键的字段名 -->
<key column="wj_id" ></key>
<!-- class:多的一方的全限定名 -->
<one-to-many class="cn.itcast.domain.Linkman"/>
</set>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<!-- 配置类和表的映射 -->
<class name="cn.itcast.domain.Customer" table="cst_customer">
<!-- 配置主键和属性的映射 -->
<id name="cust_id" column="cust_id">
<!--
native: 使用都是数据库的自增
如果用的是mysql: auto_increment
如果用的是oracle: 序列
uuid: 针对的是字符串类型
自动给你生成唯一的字符串来保证oid的唯一
-->
<generator class="native"></generator>
</id>
<!-- 配置其它字段和其它属性的映射 -->
<property name="cust_name" column="cust_name"></property>
<property name="cust_source" column="cust_source"></property>
<property name="cust_industry" column="cust_industry"></property>
<property name="cust_level" column="cust_level"></property>
<property name="cust_address" column="cust_address"></property>
<property name="cust_phone" column="cust_phone"></property>
<!-- 配置一对多的关系 集合(linkmans)-->
<!--
name:集合的名字
inverse:true 指定放弃外键的维护权
cascade: save-update 级联保存
delete:级联删除
lazy: true 默认值 默认使用延迟加载
false 不使用延迟加载 立即加载
-->
<set name="linkmans" inverse="true" cascade="save-update,delete" lazy="false">
<!-- 外键的字段名 -->
<key column="wj_id" ></key>
<!-- class:多的一方的全限定名 -->
<one-to-many class="cn.itcast.domain.Linkman"/>
</set>
</class>
</hibernate-mapping>