-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Creating Criteria over Base Classes
PostPosted: Sun May 29, 2005 8:50 pm 
Newbie

Joined: Sun May 15, 2005 11:39 pm
Posts: 17
Location: Australia
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>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.