-->
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.  [ 2 posts ] 
Author Message
 Post subject: Unhandled Exception: NHibernate.MappingException
PostPosted: Thu Feb 16, 2006 1:43 am 
Newbie

Joined: Thu Feb 16, 2006 1:32 am
Posts: 1
Hi,

I am new to NHibernate. I have downloaded the NHibernate and tried with my vs.net 2003 very much the same example given in the quick tutorial.

I am receiving the below error at
// Tell NHibernate that this object should be saved
session.Save(newUser);

Error is:
Unhandled Exception: NHibernate.MappingException: Unknown entity class: nhibernate.User


Please help.

Sreekanth

My hbm.xml is given below

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="nhibernate.User,nhibernate" table="users">
<id name="Id" column="LogonId" type="String" length="20">
<generator class="assigned" />
</id>
<property name="UserName" column="Name" type="String" length="40"/>
<property name="Password" type="String" length="20"/>
<property name="EmailAddress" type="String" length="40"/>
<property name="LastLogon" type="DateTime"/>
</class>
</hibernate-mapping>

User.cs is the same example file


I am calling the object like the following
private void Form1_Load(object sender, System.EventArgs e)
{
// try
// {
Configuration cfg = new Configuration();
//cfg.AddAssembly("MyNHibernate.Examples");
cfg.AddAssembly("nhibernate");
ISessionFactory factory = cfg.BuildSessionFactory();
ISession session = factory.OpenSession();
ITransaction transaction = session.BeginTransaction();

User newUser = new User();
newUser.Id = "joe_cool";
newUser.UserName = "Joseph Cool";
newUser.Password = "abc123";
newUser.EmailAddress = "joe@cool.com";
newUser.LastLogon = DateTime.Now;

// Tell NHibernate that this object should be saved
session.Save(newUser);

// commit all of the changes to the DB and close the ISession
transaction.Commit();
session.Close();


Top
 Profile  
 
 Post subject: Check These
PostPosted: Fri Feb 17, 2006 12:50 am 
Regular
Regular

Joined: Tue Jan 03, 2006 7:21 am
Posts: 85
Make sure that you pass the assembly that contains your mapping files and classes to the cfg.AddAssembly and make sure that the Build Option for the mapping files are set as Embedded Resource in the Visual Stidio.


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