Please help. I receive the following error: Unknown entity class: System.Int32
I've tried different settings/attributes for the many-to-one tag without any success. Everything works fine when I remove the foreign-key constraints from the database and the many-to-one tag. My *.hbm.xml files are set as Embedded Resources.
I did a lot of searching already and the little I found wasn't helpful. Is this a bug, or am I missing something here?
NHibernate version: 1.2.1 GA
Mapping documents:
Project.hbm.xml
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Testing_Console" namespace="Testing_Console">
<class name="Testing_Console.Project, Testing_Console" table="projects">
<id name="Id" column="projects_id" type="Int32">
<generator class="identity" />
</id>
<property name="Name" column="name" type="String" length="50" not-null="true" />
</class>
</hibernate-mapping>
MixDesign.hbm.xmlCode:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Testing_Console" namespace="Testing_Console">
<class name="Testing_Console.MixDesign, Testing_Console" table="mix_designs">
<id name="Id" column="mix_designs_id" type="Int32">
<generator class="identity" />
</id>
<property name="ProjectId" column="projects_id" not-null="false" type="Int32"/>
<property name="Name" column="name" type="String" length="50"/>
<property name="SpecifiedStrength" column="specified_strength" type="Int32"/>
<many-to-one name="ProjectId" column="projects_id" foreign-key="FK_mix_designs_projects" class="Project" />
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
Configuration cfg = new Configuration();
cfg.AddAssembly("Testing_Console");
ISessionFactory factory = cfg.BuildSessionFactory();
ISession session = factory.OpenSession();
ITransaction transaction = session.BeginTransaction();
MixDesign mix = new MixDesign();
mix.Name = "C4000";
mix.SpecifiedStrength = 4000;
session.Save(mix);
transaction.Commit();
session.Close();
Full stack trace of any exception that occurs:Code:
StackTrace " at NHibernate.Impl.SessionFactoryImpl.GetEntityPersister(Type theClass) in D:\\Program Files\\NHibernate\\src\\src\\NHibernate\\Impl\\SessionFactoryImpl.cs:line 608\r\n at NHibernate.Impl.SessionImpl.GetClassPersister(Type theClass) in D:\\Program Files\\NHibernate\\src\\src\\NHibernate\\Impl\\SessionImpl.cs:line 3629\r\n at NHibernate.Impl.SessionImpl.GetEntityPersister(Object obj) in D:\\Program Files\\NHibernate\\src\\src\\NHibernate\\Impl\\SessionImpl.cs:line 3637\r\n at NHibernate.Impl.SessionImpl.IsUnsaved(Object obj, Boolean earlyInsert, Object self) in D:\\Program Files\\NHibernate\\src\\src\\NHibernate\\Impl\\SessionImpl.cs:line 1171\r\n at NHibernate.Impl.SessionImpl.NullifyTransientReferences(Object value, IType type, Boolean earlyInsert, Object self) in D:\\Program Files\\NHibernate\\src\\src\\NHibernate\\Impl\\SessionImpl.cs:line 1102\r\n at NHibernate.Impl.SessionImpl.NullifyTransientReferences(Object[] values, IType[] types, Boolean earlyInsert, Object self) in D:\\Program Files\\NHibernate\\src\\src\\NHibernate\\Impl\\SessionImpl.cs:line 1081\r\n at NHibernate.Impl.SessionImpl.DoSave(Object theObj, EntityKey key, IEntityPersister persister, Boolean replicate, Boolean useIdentityColumn, CascadingAction cascadeAction, Object anything) in D:\\Program Files\\NHibernate\\src\\src\\NHibernate\\Impl\\SessionImpl.cs:line 953\r\n at NHibernate.Impl.SessionImpl.DoSave(Object obj, Object id, IEntityPersister persister, Boolean useIdentityColumn, CascadingAction cascadeAction, Object anything) in D:\\Program Files\\NHibernate\\src\\src\\NHibernate\\Impl\\SessionImpl.cs:line 872\r\n at NHibernate.Impl.SessionImpl.SaveWithGeneratedIdentifier(Object obj, CascadingAction action, Object anything) in D:\\Program Files\\NHibernate\\src\\src\\NHibernate\\Impl\\SessionImpl.cs:line 767\r\n at NHibernate.Impl.SessionImpl.Save(Object obj) in D:\\Program Files\\NHibernate\\src\\src\\NHibernate\\Impl\\SessionImpl.cs:line 708\r\n at Testing_Console.Program.Main(String[] args) in D:\\Projects\\Testing and Experimental\\Testing-Console\\Testing-Console\\Program.cs:line 24\r\n at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)\r\n at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)\r\n at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()\r\n at System.Threading.ThreadHelper.ThreadStart_Context(Object state)\r\n at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n at System.Threading.ThreadHelper.ThreadStart()" string
Name and version of the database you are using:
SQL Server 2005 SP2