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();
|