gavin wrote:
No, <key-many-to-one> is no problem.
I assume that the user has not followed your instruction to add inverse="true".
Here is the final variant of Parent object (NOT WORKING):
<hibernate-mapping>
<class name="objects.Parent" table="PARENT">
<composite-id name="parent_pk" class="objects.ParentPK">
<key-property name="parent_id" column="PARENT_ID" type="int"/>
<key-many-to-one name="GRAND_PARENT" class="objects.GrandParent">
<column name="GRANDPARENT_ID"/>
</key-many-to-one>
</composite-id>
<property name="text" type="string">
<column name="TEXT" sql-type="TEXT" not-null="false"/>
</property>
<set name="children" table="CHILD" sort="comparators.ChildComparator"
inverse="true" cascade="all-delete-orphan">
<key>
<column name="GRANDPARENT_ID"/>
<column name="PARENT_ID"/>
</key>
<one-to-many class="objects.Child"/>
</set>
</class>
</hibernate-mapping>
Maybe it's not working because of 2-level relationships ???
GrandParent has 0 or more Parent objects, and Parent object may has 0 or more Child objects ! Exception, while deleting Parent object !