-->
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.  [ 1 post ] 
Author Message
 Post subject: MappingException - session.Save(newUser);
PostPosted: Fri Jul 27, 2007 8:25 am 
Newbie

Joined: Fri Jul 27, 2007 8:08 am
Posts: 1
Full stack trace of any exception that occurs:
bei NHibernate.Impl.SessionFactoryImpl.GetEntityPersister(Type theClass)
bei NHibernate.Impl.SessionImpl.GetClassPersister(Type theClass)
bei NHibernate.Impl.SessionImpl.GetEntityPersister(Object obj)
bei NHibernate.Impl.SessionImpl.SaveWithGeneratedIdentifier(Object obj, CascadingAction action, Object anything)
bei NHibernate.Impl.SessionImpl.Save(Object obj)
bei WindowsApplication1.Form1..ctor() in C:\Dokumente und Einstellungen\mkubitza\Eigene Dateien\Visual Studio 2005\Projects\NHibernate\WindowsApplication1\WindowsApplication1\Form1.cs:Zeile 62.
bei WindowsApplication1.Program.Main() in C:\Dokumente und Einstellungen\mkubitza\Eigene Dateien\Visual Studio 2005\Projects\NHibernate\WindowsApplication1\WindowsApplication1\Program.cs:Zeile 14.
bei System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bei System.Threading.ThreadHelper.ThreadStart()


-------------------------------------------------------------
Hallo,

ich bekomme eine MappingException
(MappingException – Unkown entity class: NHibernate.Examples.QuickStart.User)
bei session.Save(newUser)

Es scheint als ob die Mapping-Datei nicht gefunden wird.


- Ich verwende: VS 2005
- Die Dateien liegen im Root. ( User.cs, User.hbm.xml )
- Hibernate version: nHibernate - 1.2
- Name and version of the database you are using: MS SQL 2005


-------------------------------------------------------------

Configuration cfg = new Configuration();
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();

-------------------------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="NHibernate.Examples.QuickStart.User, NHibernate.Examples" 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>

-------------------------------------------------------------


using System;

namespace NHibernate.Examples.QuickStart {
public class User {
private string id;
private string userName;
private string password;
private string emailAddress;
private DateTime lastLogon;


public User() {
}

public string Id {
get { return id; }
set { id = value; }
}

public string UserName {
get { return userName; }
set { userName = value; }
}

public string Password {
get { return password; }
set { password = value; }
}

public string EmailAddress {
get { return emailAddress; }
set { emailAddress = value; }
}

public DateTime LastLogon {
get { return lastLogon; }
set { lastLogon = value; }
}

}
}

-------------------------------------------------------------

Außerdem habe ich versucht die Methode: addResource zu benutzen
<- Ohne erfolg. Die Methode erwartet 2 Paramter... !??


Welche configuration soll ich eigentlich verwenden?
http://www.hibernate.org/hib_docs/nhibe ... quickstart


<nhibernate>
<add
key="hibernate.connection.provider"
value="NHibernate.Connection.DriverConnectionProvider"
/>


oder folgendes Schema:

http://forum.hibernate.org/viewtopic.ph ... ddresource



Danke... :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.