Longwinded example follows, thanks in advance to anyone that makes it through the whole thing, let alone feels nice enough to respond:
Let's say I've got an item hierarchy derived from a class called NamedObject. NamedObject is really just an abstraction for a named entity in my domain. The base class has a parent property (pointing to another NamedObject) and the subclasses on the tree have children collections specific to each subclass. For example:
Code:
<?xml version="1.0"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"
assembly="Eg" namespace="Eg"
default-lazy="false">
<class name="NamedObject" table="NamedObjects">
<id name="Id">
<generator class="guid.comb"/>
</id>
<discriminator column="Type" />
<property name="Name" length="256" not-null="true" />
<many-to-one name="Parent" column="ParentId" />
<subclass name="Server">
<bag name="Databases" inverse="true" cascade="all">
<key column="ParentId" />
<one-to-many class="Database" />
</bag>
</subclass>
<subclass name="Database">
<bag name="Tables" inverse="true" cascade="all">
<key column="ParentId" />
<one-to-many class="Table" />
</bag>
</subclass>
<subclass name="Table" />
</class>
</hibernate-mapping>
Ideally what I'd like is to use a <joined-subclass> here for a new type derived from Server called ServerConnectionDetails that should map to it's own table. I'd like a single column that's a PK/FK in this new table like <joined-subclass> does but NHibernate is complaining here about my mapping file, it looks like I can't have a <joined-subclass> child of a <subclass> element.
So I guess there's no way to set up a hybrid inheritence tree like this? If not, what's the next best way to go about this, or is there a cleaner way of doing what I'm attempting? I believe I need the NamedObjects table like I have it or else the code for the bulk of the functionality of my application gets incredibly ugly.