This last one should work (the previous does NOT, actually, fit the DTD!)
Well, it gets past the XML parser without throwing an exception. Really. Try for yourself. hibernate 2.0.3...
Anyway, I've fixed my mapping problem. I had some <many-to-one> and <set> tags in subclasses that I hadn't changed the <key> tags on. Silly me. :)
One last question remains: How do I create <generator> like functionality for my <composite-id>? Can I do that in the mapping, or do I have to create a custom type for the composite-id?
I know this isn't there now, but it would be nice if you could have a <generator> embedded in a <key-property> tag.
Anyway, here's my mapping, with some classes with the sets and many-to-one tags I was talking about above: (properties edited out for brevity...)
Code:
<class name="SiteDataObject" table="base_site_data_objects">
<composite-id name="id" unsaved-value="any" class="CompositeSiteID">
<key-property name="generated_id" type="long"/>
<key-many-to-one name="site" class="Site"/>
</composite-id>
<joined-subclass name="Event" table="events">
<key><key column="generated_id"/><key column="site"/></key>
</joined-subclass> <!-- Event -->
<joined-subclass name="Listing" table="listings">
<key><column name="generated_id"/><column name="site"/></key>
</joined-subclass> <!-- Listing -->
<joined-subclass name="MenuItem" table="menu_items">
<key><column name="generated_id"/><column name="site"/></key>
<many-to-one name="parent" class="MenuHeirarchyItem">
<column name="parent_id" unique-key="label-parent"/>
<column name="parent_site" unique-key="label-parent"/>
</many-to-one>
<joined-subclass name="MenuActionItem" table="menu_actions">
<key><column name="generated_id"/><column name="site"/></key>
<many-to-one name="listing" outer-join="false" class="Listing">
<column name="listing_id"/>
<column name="listing_site"/>
</many-to-one>
</joined-subclass> <!-- MenuActionItem -->
<joined-subclass name="MenuHeirarchyItem" table="menu_heirarchy">
<key><column name="generated_id"/><column name="site"/></key>
<set name="children" lazy="true" inverse="true">
<key><column name="parent_id"/><column name="parent_site"/></key>
<one-to-many class="MenuItem"/>
</set>
</joined-subclass> <!-- MenuHeirarchyItem -->
</joined-subclass> <!-- MenuItem -->
</class> <!-- SiteDataObject -->
<class name="Site" mutable="true" table="sites_sites">
<id name="id" type="long">
<generator class="native"/>
</id>
</class><!-- Site -->