Hi,
I have a base class with over 20+ sub classes. I wish to call the following so as to force the 70,000 instances of the sub classes to pre-load.
Code:
IList i = Session.CreateCriteria(typeof(CDT.clsCDT_CoreData_Base)).List();
the problem is, I am getting a "problem in find error" from NH. The log goes on to say that "Object with id: 1 was not of the specified sublcass: "
When I change it to get the sub class, everything works fine... however, it only pre-loads the sub classes.
Code:
IList i = Session.CreateCriteria(typeof(CDT.clsCDT_PO)).List();
Could someone please help me by telling me either
a/ If NH supports what I'm trying to do, any ideas what I'm doing wrong?
or
b/ If NH doesn't support what I'm trying, any ideas of how to loop through NH's object model of the parent class to find all the types of the base classes so that I can generate the 20+ CreateCriterias in a loop?
Thank you very much for any help/suggstions that you might be able to give.
Regards,
Damien Sawyer
PS - for the record, here is an extract of my mapping file...
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="OPWLibrary.CDT.clsCDT_CoreData_Base, OPWLibrary" table="tblCoreData">
<!--<class name="OPWLibrary.CDT.clsCoreDataItemBase, OPWLibrary" table="tblCoreData">-->
<id name="CoreDataID" column="iCoreDataID">
<generator class="assigned" />
</id>
<discriminator column="cDataTypeID"/>
<property name="EffectiveDate" access="property" column="dEffective"/>
<property name="Quantity" access="property" column="iQty"/>
<!--Out of interst, need to mark this as insert=false, update=false, because cDataTypeID is used above (as the discriminator)-->
<many-to-one name="CoreDataType" column="cDataTypeID" insert="false" update="false" not-null="true"/>
<subclass name="OPWLibrary.CDT.clsCDT_SOH, OPWLibrary"
discriminator-value="SOH" >
<many-to-one name="Item" column="cLITM" not-null="true"/>
</subclass>
<subclass name="OPWLibrary.CDT.clsCDT_PO, OPWLibrary"
discriminator-value="PO">
<many-to-one name="Item" column="cLITM" not-null="true"/>
</subclass>
......... more sub classes .....
</class>