-->
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.  [ 5 posts ] 
Author Message
 Post subject: Unknown Entity Class - I can not solve this!!!
PostPosted: Fri Jan 05, 2007 10:43 am 
Newbie

Joined: Thu Jan 04, 2007 10:50 am
Posts: 8
Hello All

I am tearing my hair out over this. I have browsed related issues, but to no avail.

Basically it looks like the Configuration loads in my hbm files without a hitch. However, as soon as I go to save an object, it throws the error 'Unknown Entity Class' as part of the MappingException.

My hbm.xml files are all embedded, and it can find them ok. (If I try doing AddClass(typeof(myclass)) it doesnt work however - it says it can't find the files even though they are there... doing it on assembly name instead seems to get past this)

My assembly name is PropertyTrackerBusiness

as an example, a class I have is declared as follows in Property.cs in the above assembly (which I have verified in project properties)

Code:
namespace PropertyTrackerBusiness.Domain
{
public class Property
{
   //public props etc..
}
}



my Property.hbm.xml file is as follows:

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="PropertyTrackerBusiness.Domain.Property, PropertyTrackerBusiness" table="Properties">
<id name="Id" column="Id" type="Int64" unsaved-value="0">
<generator class="identity" />
</id>
<property name="Description" column="Description" type="String" length="50"/>
<property name="Address1" column="Address1" type="String" length="50"/>
<property name="Address2" column="Address2" type="String" length="50"/>
<property name="Town" column="Town" type="String" length="50"/>
<property name="County" column="County" type="String" length="50"/>
<property name="Postcode" column="Postcode" type="String" length="50"/>
<property name="Country" column="Country" type="String" length="50"/>
</class>
</hibernate-mapping>


And this file is embedded.

In fact, I have checked the configuration object at runtime and it has imported all of my definitions.

Yet as soon as I do session.Save(property) it just says it can't find the entity..... Does anyone know of anything I am not doing?

I have a helper class which creates the factory and then gets the session. This seems to go through without a hitch. It's just when I do a save.....


Top
 Profile  
 
 Post subject: "Unknown entity class"
PostPosted: Fri Jan 05, 2007 2:32 pm 
Newbie

Joined: Fri Jan 05, 2007 2:22 pm
Posts: 1
you should set the "build action" property of your class mapping file (XXX.hbm.xml) to "Embedded Resource" .
Try it...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 05, 2007 2:58 pm 
Newbie

Joined: Thu Jan 04, 2007 10:50 am
Posts: 8
Thanks, but as I said before they are already embedded resources. I have actually solved the problem rather silly really. Basically I was creating the factory from the config first before actually loading the config (so the factory was empty).


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 08, 2007 2:30 pm 
Newbie

Joined: Mon Jan 08, 2007 2:27 pm
Posts: 1
I am a little new to this so please bear with me.

How did you solve this problem? I have the same problem and I can't figure it out. I am working in VB.net and there is very little help for this enviroment.


Top
 Profile  
 
 Post subject: -
PostPosted: Tue Jan 09, 2007 12:19 pm 
Beginner
Beginner

Joined: Thu Jul 06, 2006 4:44 am
Posts: 31
Are your hbm files in the same directory as you class files?
Using typeof(myclass) should work if not check again your assembly name or compare it with one entered by hand. Sometimes you need to check all things step by step (i had similar experience at the beginning). Are you using the full assembly name in your mapping file? Another way is to loop through the xml files and load them "on the fly":

// get all xml's from the assembly
Assembly a = Assembly.GetExecutingAssembly();
// get a list of resource names from the manifest
string [] resNames = a.GetManifestResourceNames();

foreach (string resourceName in resNames)
{
XmlDocument docXML = new XmlDocument();
docXML.Load(a.GetManifestResourceStream(resourceName));
configuration.AddDocument(docXML);
}

I thing calling "configuration.BuildSessionFactory();" should throw an exception if mapping is not ok.

hope I somehow helped you with this...


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