Here's my heirarchy:
class abstract Entity { /*members*/ } // mapped to entity table class abstract User : Entity { /*members*/ } // mapped to user table class Employee : User { /*no members*/ } // no table, discriminator = "E" class Contractor : User { /*no members*/ } // no table, discriminator = "C"
Here's my mappings in two separate hbm files:
<class name="Entity" table="entity" xmlns="urn:nhibernate-mapping-2.2"> <id name="Id" column="id"> <generator class="guid.comb" /> </id> <property ... /> </class> <joined-subclass name="User" extends="Entity" table="user"> <key column="id" /> <discriminator column="type" /> <property ... /> <subclass name="Employee" discriminator-value="E" /> <subclass name="Contractor" discriminator-value="C" /> </joined-subclass>
The following is the exception I get:
MappingException: XML validation error: The element 'joined-subclass' in namespace 'urn:nhibernate-mapping-2.2' has invalid child element 'discriminator' in namespace 'urn:nhibernate-mapping-2.2'.
What am I missing? Can you not map a discriminated subclass hierarchy of a joined-subclass?
What you want to do is not currently possible.
Check http://www.nhforge.org/doc/nh/en/index.html#inheritance for allowed constructs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With