-->
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.  [ 10 posts ] 
Author Message
 Post subject: Unknow entity class:NHibernate.Examples.QuickStart.User
PostPosted: Wed Feb 08, 2006 4:22 am 
Newbie

Joined: Wed Feb 08, 2006 4:10 am
Posts: 16
I need help Please
I follow exactly the example that this web site have given,but after i run the program there have an error as "Unknow entity class:NHibernate.Examples.QuickStart.User", when it come to session.save(newUser).
is it because the AddAssembly?because when i use the session.AddAssembly("NHibernate.Examples") there have an error as "Could not load file or assembly 'NHibernate.Examples' or one of its dependencies. The system cannot find the file specified". later i change it to session.AddAssembly("NHibernate") there was correct but when come to session.save i will have error as "Unknow entity class:NHibernate.Examples.QuickStart.User".

thanks a lot if anyone can help me on this


Top
 Profile  
 
 Post subject: Do you have your mapping files (.xml) in classpath or listed
PostPosted: Wed Feb 08, 2006 5:25 am 
Newbie

Joined: Wed Feb 08, 2006 5:17 am
Posts: 3
Location: Finland
Do you have your mapping files (.xml) in classpath or listed in hibernate.cfg.xml? See documentation.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 5:43 am 
Newbie

Joined: Wed Feb 08, 2006 4:10 am
Posts: 16
i only have the hibernate.cfg.xml at NHibernate file folder i download from, i didn't have it at my own project. do i need to copy it into my own project?
sorry can i ask where is the classpath u mean?
thanks...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 6:14 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Which assembly is NHibernate.Examples.QuickStart.User defined in?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 6:30 am 
Newbie

Joined: Wed Feb 08, 2006 4:10 am
Posts: 16
my assembly is User.hbm.xml as below:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="User" table="users">
<id name="LogonID" column="LogonID" type="String" length="20" unsaved-value="0">
<generator class="assigned" />
</id>
<property name="Name" column="Name" type="String" length="40"/>
<property name="Password" column="Password" type="String" length="20"/>
<property name="EmailAddress" column="EmailAddress" type="String" length="40"/>
<property name="LastLogon" column="LastLogon" type="DateTime"/>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 7:28 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
It's not your assembly, it's a mapping file. Besides, the class name is not qualified there, so NHibernate will not know where it should look for class="User".


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 9:50 am 
Newbie

Joined: Wed Feb 08, 2006 4:10 am
Posts: 16
sorry my mapping file is as below:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="NHibernate.Examples.Quickstart, NHibernate.Examples" table="users">
<id name="LogonID" column="LogonID" type="String" length="20" unsaved-value="0">
<generator class="assigned" />
</id>
<property name="Name" column="Name" type="String" length="40"/>
<property name="Password" column="Password" type="String" length="20"/>
<property name="EmailAddress" column="EmailAddress" type="String" length="40"/>
<property name="LastLogon" column="LastLogon" type="DateTime"/>
</class>
</hibernate-mapping>

if i use the example from this web site, what is the exactly Assembly is?
thanks...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 11:31 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
The assembly is essentially the name of the file that your project compiles to. If it's NHibernate.Examples.dll then the assembly is NHibernate.Examples. Ensure that .NET can find the assembly and that it contains the User class.

You should first learn .NET basics, then you will have much less problems using NHibernate.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 11:12 pm 
Newbie

Joined: Wed Feb 08, 2006 4:10 am
Posts: 16
i'm using "visual web developer 2005 Express Edition" to view the result of save successfully or fail. while i use "Microsoft visual basic 2005 Express Edition" to create the NHibernate.Examples.dll after that i add references of this dll into "visual web developer 2005 Express Edition" file that i have created, from there it will not have the user.vb,user.hbm.xml because it already create at the dll, izit correct if i doing this?
thanks a lot.....


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 09, 2006 12:11 am 
Newbie

Joined: Wed Feb 08, 2006 4:10 am
Posts: 16
Thanks a lot, i have solve the problem :)


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