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.  [ 8 posts ] 
Author Message
 Post subject: "associated class not found" exception
PostPosted: Wed Aug 29, 2007 6:35 am 
Newbie

Joined: Wed Aug 29, 2007 6:17 am
Posts: 5
Hi,

I'm getting an error "associated class not found: ClassLibrary.Expense".
Could not compile the mapping document: ClassLibrary.User.hbm.xml

Hibernate version:1.2.0.4000

Mapping documents: User:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="ClassLibrary.User, ClassLibrary" table="Users"
lazy="false">
<id name="Id" column="ID" type="Int64" unsaved-value="0">
<generator class="identity" />
</id>
<property name="UserName" column="UserName" type="String" length="50"/>
<property name="FirstName" column="FirstName" type="String" length="100"/>
<property name="LastName" column="LastName" type="String" length="100"/>
<property name="Email" column="Email" type="String" length="100"/>
<bag name="Expenses" inverse="false" cascade="save-update" table="Expenses">
<key column="ID" />
<one-to-many class="ClassLibrary.Expense" />
</bag>
</class>
</hibernate-mapping>


Expense:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="ClassLibrary.Expense, ClassLibrary" table="Expenses"
lazy="false">
<id name="Id" column="ID" type="Int64" unsaved-value="0">
<generator class="identity" />
</id>
<property name="UserID" column="UserID" type="Int64"/>
<property name="Name" column="Name" type="String" length="100"/>
<property name="Description" column="Description" type="String" length="255"/>
<property name="PayingDate" column="PayingDate" type="DateTime"/>
<property name="ExpenseStart" column="ExpenseStart" type="DateTime"/>
<property name="NoOfMonths" column="NoOfMonths" type="int"/>
</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Configuration cfg = new Configuration();
cfg.AddAssembly("ClassLibrary");

Can someone please give me some feedback on what is wrong in the user mapping file?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 29, 2007 8:41 am 
Newbie

Joined: Wed Aug 01, 2007 8:53 am
Posts: 6
Hi cok,

I had the same issue, so I compare the properites of my hbm.xml files and I conclued that all hbm.xml files used with the AddAssembly must be defined as embedded resources in visual studio 2005. This can be done in the VS 2005 properties of your files.

I hope this helps you.

Cheachwood.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 29, 2007 8:51 am 
Newbie

Joined: Wed Aug 29, 2007 6:17 am
Posts: 5
Thanxs for the tip, but my two xml-files are allready embeded.

best regards

cok


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 29, 2007 9:38 am 
Newbie

Joined: Wed Aug 01, 2007 8:53 am
Posts: 6
OK

so did you try catch your exception like this : Console.WriteLine(Ex.InnerException.Message + "\n" + Ex.InnerException.Source + "\n" + Ex.InnerException.StackTrace); ?

To know exactly what the NHibernate issue is?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 29, 2007 9:49 am 
Newbie

Joined: Wed Aug 29, 2007 6:17 am
Posts: 5
Here is the whole error message:

Code:
associated class not found: ClassLibrary.Expense
NHibernate
   at NHibernate.Cfg.HbmBinder.ClassForFullNameChecked(String fullName, String errorMessage)
   at NHibernate.Cfg.HbmBinder.ClassForNameChecked(String name, Mappings mappings, String errorMessage)
   at NHibernate.Cfg.HbmBinder.BindOneToMany(XmlNode node, OneToMany model, Mappings mappings)
   at NHibernate.Cfg.HbmBinder.BindCollection(XmlNode node, Collection model, String className, String path, Type containingType, Mappings mappings)
   at NHibernate.Cfg.HbmBinder.CollectionType.CollectionTypeBag.Create(XmlNode node, String prefix, String path, PersistentClass owner, Type containingType, Mappings mappings)
   at NHibernate.Cfg.HbmBinder.PropertiesFromXML(XmlNode node, PersistentClass model, Mappings mappings)
   at NHibernate.Cfg.HbmBinder.BindRootClass(XmlNode node, RootClass model, Mappings mappings)
   at NHibernate.Cfg.HbmBinder.BindRoot(XmlDocument doc, Mappings mappings)
   at NHibernate.Cfg.Configuration.AddValidatedDocument(XmlDocument doc, String name)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 29, 2007 10:36 am 
Newbie

Joined: Wed Aug 01, 2007 8:53 am
Posts: 6
Are you sure that the classe Expenses is in the ClassLibrary namespace?
This looks like it is not.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 29, 2007 10:50 am 
Newbie

Joined: Wed Aug 29, 2007 6:17 am
Posts: 5
Code:
namespace ClassLibrary
{               
    public class Expense
    {
    }
}

The two classes (User, Expense), is in the same root folder of ClassLibrary. Here I also got the two xml-files.

If I run some code:
Code:
IList list = session.CreateCriteria(typeof(Expense)).List();
I get the posts from db that is in table Expenses. (I have here uncommented the Bag-tag in User-xml).
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 29, 2007 4:15 pm 
Newbie

Joined: Wed Aug 29, 2007 6:17 am
Posts: 5
In the User.hbm.xml file i changed:
Code:
<one-to-many class="ClassLibrary.Expense" />

To:
Code:
<one-to-many class="ClassLibrary.Expense, ClassLibrary" />


Tnx for the help

best regards

cok


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