-->
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.  [ 3 posts ] 
Author Message
 Post subject: Association references unmapped class
PostPosted: Thu Apr 27, 2006 10:20 am 
Newbie

Joined: Mon Oct 17, 2005 4:16 am
Posts: 4
Hi,

I am having trouble with a "Association references unmapped class" exception. I have checked everything I can think of and no luck. This comes up during initiation of session factory.

Using VS 2005, SQL Server 2005, NHibernate 1.0.2.0

All my hbm.xml files are in the VS 2005 project as "Embedded Resources"

The strange thing is that it was all running fine a couple of hours ago. I made some changes (non NH related) and added one hbm.xml file to the project, not related to the one which features in the error below.

Is anyone aware of a VS2005 bug which doesnt "Embed" resources? seems like it doesnt make a difference whether the xml file is included or excluded from the project.

Help would be greatly appreciated.

Mapping documents:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" schema="dbo">
  <class name="Seamless.Security.UserGroupRole, Seamless.Security" table="secUserGroupRole">
    <id name="id" type="Int32" column="userGroupRoleId">
      <generator class="native" />
    </id>
    <many-to-one name="objGroup" column="groupId" class="Seamless.Security.Group, Seamless.Security" />
    <many-to-one name="objRole" column="roleId" class="Seamless.Security.Role, Seamless.Security" />
    <many-to-one name="objUser" column="userId" class="Seamless.Security.User, Seamless.Security" />
  </class>
</hibernate-mapping>


Inner Exception & Stack trace:
Quote:
Association references unmapped class: UserGroupRole

Code:
at NHibernate.Cfg.Binder.BindCollectionSecondPass(XmlNode node, Collection model, IDictionary persistentClasses, Mappings mappings)
   at NHibernate.Cfg.Binder.CollectionSecondPass.SecondPass(IDictionary persistentClasses)
   at NHibernate.Cfg.Binder.AbstractSecondPass.DoSecondPass(IDictionary persistentClasses)
   at NHibernate.Cfg.Configuration.SecondPassCompile()
   at NHibernate.Cfg.Configuration.BuildSessionFactory()
   at Seamless.Core.NHibernateBase.NHibernateSessionManager.InitSessionFactory() in C:\Dev\SeamlessCMS\SeamlessBaseSolution\Seamless.Core\DAO\NHibernateBase\NHibernateSessionManager.cs:line 69
   at Seamless.Core.NHibernateBase.NHibernateSessionManager..ctor() in C:\Dev\SeamlessCMS\SeamlessBaseSolution\Seamless.Core\DAO\NHibernateBase\NHibernateSessionManager.cs:line 37
   at Seamless.Core.NHibernateBase.NHibernateSessionManager.Nested..cctor() in C:\Dev\SeamlessCMS\SeamlessBaseSolution\Seamless.Core\DAO\NHibernateBase\NHibernateSessionManager.cs:line 46


Top
 Profile  
 
 Post subject: Re: Association references unmapped class
PostPosted: Fri Feb 19, 2010 2:58 am 
Newbie

Joined: Fri Feb 19, 2010 2:51 am
Posts: 1
If you are using visual studio for NHibernate then
Take the config file (.hbm.xml) properties locate the "Advanced Section" and change "Build Action" to "Embedded Resource"

_________________
~Mathew Philip~


Top
 Profile  
 
 Post subject: Re: Association references unmapped class
PostPosted: Tue Nov 23, 2010 2:36 pm 
Newbie

Joined: Tue Nov 23, 2010 2:32 pm
Posts: 1
Always start with the basics.

Make sure each of your entities are "making it into" the configuration.


private void ShowConfig(NHibernate.Cfg.Configuration cfg)
{
StringBuilder sb = new StringBuilder();
foreach (PersistentClass model in cfg.ClassMappings)
{
sb.Append("Key=:" + model.Key + System.Environment.NewLine);
sb.Append("MappedClass=:" + model.MappedClass + System.Environment.NewLine);
sb.Append(System.Environment.NewLine);
}
//this.txtMessages.Text = sb.ToString();
}

Loop over the .ClassMappings in your language of choice, and check the basic information.
My guess is that one of your primary entities is not in the configuration.

And (as previously written), not having your hbm.xml file as an embedded resource is one cause of this.
Having ".xml" and not ".hbm.xml" as the extension is also a culprit here.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.