à实体层映射:
hibernate-mapping
package="org.lxh.hibernate">
<class
name="Person" table="PERSON">
<id
name="id" column="ID" type="int">
<generator
class="assigned" />
</id>
<component
name="name" class="org.lxh.hibernate.Name">
<property
name="firstname" column="FIRSTNAME" type="string"
not-null="true" />
<property
name="lastname" column="LASTNAME" type="string"
not-null="true" />
</component>
<component
name="contact" class="org.lxh.hibernate.Contact">
<property
name="address" column="ADDRESS" type="string"
not-null="true" />
<property
name="zipcode" column="ZIPCODE" type="string"
not-null="true" />
<property
name="tel" column="TEL" type="string" />
</component>
</class>
</hibernate-mapping>
à实体层设计:2个HBM文件的例子
|-- <hibernate-mapping
package="org.lxh.hibernate04">
<class name="TItem"
table="TITEM">
<id name="id"
column="ID" type="string">
<generator class="assigned"
/>
</id>
<property name="name"
column="NAME" type="string" not-null="true" />
<property
name="manufacturer" column="MANUFACTURER"
type="string" />
<joined-subclass
name="org.lxh.hibernate04.TBook" table="TBook">
<key
column="ID"></key>
<property name="pageCount"
type="java.lang.Integer"
column="pagecount"></property>
</joined-subclass>
<joined-subclass
name="org.lxh.hibernate04.TDVD" table="TDvd">
<key
column="ID"></key>
<property name="regionCode"
type="java.lang.String"
column="regioncode"></property>
</joined-subclass>
</class>
</hibernate-mapping>
|-- <hibernate-mapping package="org.lxh.hibernate05">
<class
name="TItem" table="TITEM">
<id
name="id" column="ID" type="string">
<generator
class="assigned" />
</id>
<discriminator
column="category"
type="java.lang.String"></discriminator>
<property
name="name" column="NAME" type="string"
not-null="true" />
<property
name="manufacturer" column="MANUFACTURER"
type="string" not-null="true" />
<subclass
name="org.lxh.hibernate05.TBook"
discriminator-value="1">
<property
name="pageCount" column="PAGECOUNT" type="int"
/>
</subclass>
<subclass
name="org.lxh.hibernate05.TDVD" discriminator-value="2">
<property
name="regionCode" column="REGIONCODE"
type="string" />
</subclass>
</class>
</hibernate-mapping>
-- 学海无涯