-->
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.  [ 4 posts ] 
Author Message
 Post subject: An association refers to an unmapped class
PostPosted: Tue Oct 04, 2005 8:25 pm 
Newbie

Joined: Tue Oct 04, 2005 5:42 pm
Posts: 5
Location: North Carolina, USA
I have two mapping files:

KnowledgeBase.hbm.xml
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
   <class name="SimpliCity.Business.KnowledgeBase, SimpliCity.Business" table="KNOWLEDGEBASE">
      <id name="Id" column="ID" type="System.Int32" unsaved-value="0">
         <generator class="native" />
      </id>      
      <property name="Topic" column="TOPIC" />
      <property name="Text" column="TEXT" />
      <property name="Keywords" column="KEYWORDS" />
      <many-to-one name="Department" class="SimpliCity.Business.Department, SimpliCity.Business" column="DEPARTMENT_ID" />
      <property name="IsInternal" column="INTERNAL_FLAG" type="true_false"/>
      <property name="LastUpdatedDate" column="LAST_UPDATED_DATE" />
      <property name="OverallRanking" column="OVERALL_RANKING" />
      <property name="DailyRanking" column="DAILY_RANKING" />
      <property name="CreationDate" column="CREATION_DATE" />
      <property name="LastUpdatedBy" column="LAST_UPDATED_BY_ID" />
      <property name="CreatedBy" column="CREATED_BY_ID" />
   </class>   
</hibernate-mapping>


Department.hbm.xml
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
   <class name="SimpliCity.Business.Department, SimpliCity.Business" table="DEPARTMENTS">
      <id name="Id" column="ID" type="System.Int32" unsaved-value="0">
         <generator class="native" />
      </id>      
      <property name="Name" column="NAME" />
      <property name="ServicePhoneNumber" column="SERVICE_PHONE_NO" />
      <property name="EmailAddress" column="EMAIL_ADDRESS" />
      <property name="Code" column="CODE" />
      <property name="LastUpdatedDate" column="LAST_UPDATED_DATE" />
      <property name="CreationDate" column="CREATION_DATE" />
      <property name="LastUpdatedBy" column="LAST_UPDATED_BY_ID" />
      <property name="CreatedBy" column="CREATED_BY_ID" />
   </class>   
</hibernate-mapping>


When configuration is run, I get the following error message:
An association from the table KNOWLEDGEBASE refers to an unmapped class: Department
Quote:
[MappingException: An association from the table KNOWLEDGEBASE refers to an unmapped class: Department]
NHibernate.Cfg.Configuration.SecondPassCompileForeignKeys(Table table, ISet done) +438
NHibernate.Cfg.Configuration.SecondPassCompile() +906
NHibernate.Cfg.Configuration.BuildSessionFactory() +12
SimpliCity.ObjectAccess.ObjectAccessManager.OpenSession() in C:\Projects\SimpliService\ObjectAccess\ObjectAccessManager.cs:49
SimpliCity.ObjectAccess.Http.NHibernateHttpModule.ContextBeginRequest(Object sender, EventArgs e) in C:\Projects\SimpliService\ObjectAccess\NHibernateHttpModule.cs:37
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64


I'm sure this is a Newbie error, but any help would be greatly appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 04, 2005 11:10 pm 
Newbie

Joined: Tue Sep 20, 2005 10:22 pm
Posts: 6
Are you embedding this into the Library? usually when i get this error first thing i check is that the Department.hbm.xml is set to embedded resource.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 05, 2005 12:55 pm 
Newbie

Joined: Tue Oct 04, 2005 5:42 pm
Posts: 5
Location: North Carolina, USA
Yes. I have both files set to an embedded resource. Both are getting loaded fine. They will only work when I include both mappings in one file. Does anyone have any ideas?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 05, 2005 1:13 pm 
Newbie

Joined: Thu Sep 08, 2005 12:15 pm
Posts: 17
In your KnowledgeBase mapping file you are referencing to the Departement by the DEPARTEMENT_ID column. But in your Departement mappingfile the Id colomn is named ID

Code:
<many-to-one name="Department" class="SimpliCity.Business.Department, SimpliCity.Business" column="DEPARTMENT_ID" />


Code:
<id name="Id" column="ID" type="System.Int32" unsaved-value="0">


shouln't rather be
Code:
<id name="Id" column="DEPARTMENT_ID" type="System.Int32" unsaved-value="0">


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

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.