Hi,
The reference documentation contains an example of this mapping, using Cats and Kittens where a Cat can mapped to 0 or more kittens (which are also cats).
i.e.
CAT ----(kittens)----* CAT (kittens)
The mapping (from version 2.1 of the documentation- chapter 5) is:
Code:
<hibernate-mapping>
<class name="eg.Cat" table="CATS" discriminator-value="C">
<id name="id" column="uid" type="long">
<generator class="hilo"/>
</id>
<discriminator column="subclass" type="character"/>
<property name="birthdate" type="date"/>
<property name="color" not-null="true"/>
<property name="sex" not-null="true" update="false"/>
<property name="weight"/>
<many-to-one name="mate" column="mate_id"/>
<set name="kittens">
<key column="mother_id"/>
<one-to-many class="eg.Cat"/>
</set>
<subclass name="eg.DomesticCat" discriminator-value="D">
<property name="name" type="string"/>
</subclass>
</class>
<class name="eg.Dog">
<!-- mapping for Dog could go here -->
</class>
</hibernate-mapping>
Check out the documentation for more details
Justin