I am having some difficulty with this mapping. I have an abstract class TreeNode which maps to a self-joining table called CATEGORY_CHILDREN. The class Category extends TreeNode and maps to the CATEGORY table. Here are the mappings, although the TreeNode can't be mapped like this, because I haven't given it any id. Not sure I am taking the right approach. Any help is appreciated.
<class name="software.executiveutilities.model.TreeNode" table="CATEGORY_CHILDREN" lazy="false">
<one-to-one name="parent" class="software.executiveutilities.model.TreeNode" foreign-key="PARENT_CATEGORY_ID" />
<list name="children" lazy="false" >
<key column="CHILD_CATEGORY_ID" not-null="true" />
<list-index column="CHILD_ORDER" base="0" />
<one-to-many class="software.executiveutilities.model.TreeNode" />
</list>
</class>
<class name="software.executiveutilities.model.Category" table="CATEGORIES" lazy="false">
<id name="id" column="ID">
<generator class="increment" />
</id>
<property name="name" column="NAME" />
<property name="textArea" column="TEXT_AREA" />
<list name="links" lazy="false" cascade="all,delete-orphan" inverse="true">
<key column="CATEGORY_ID" not-null="true" />
<list-index column="LINK_ORDER" base="0" />
<one-to-many class="software.executiveutilities.model.LinkInfo" />
</list>
<list name="images" lazy="false" cascade="all,delete-orphan" inverse="true">
<key column="CATEGORY_ID" not-null="true" />
<list-index column="IMAGE_ORDER" base="0" />
<one-to-many class="software.executiveutilities.model.ImageInfo" />
</list>
<set name="groups" lazy="false" cascade="all,delete-orphan" table="BLUEGROUPS" >
<key column="CATEGORY_ID" not-null="true" />
<one-to-many class="software.executiveutilities.model.Group" />
</set>
</class>
|