I've spent the last two days trying to get my first bit of nHibernate
to work. I am in "No Persister" hell.

Following is everything I have relative to this problem (what I've
tried, environment, file names, xml, classes, error text).

Please, for the love of all that is holy, help me!!

tqii

What I've tried:

I've moved the file around everywhere that makes sense. It is
presently in the same directory as the class.
I took out the class definition. Nothing changes at all.
I inserted stupid assembly and namespace definitions. Nothing changes
at all.
I recreated my starter project a few times. Doesn't matter.
All of the alternatives to "embedded resource" that seemed relevant.
It is presently embedded.
I changed the code to refer to a new class with a different name but
left the hbm unchanged. Same error, different name.

Environment:

Windows 7
ASP.NET MVC
ASP.NET 3.5 sp1
Visual Studio 2008

File names:

In the same directory
studentBase.cs
studentBase.hbm.xml

Also, hibernate.cfg.xml is in the top directory of the project. I used
the sample with no changes except the connection string. I think this
is being found properly because I can induce errors by changing it.

StudentBase.hbm.xml:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="ExpressBook" namespace="ExpressBook">
  <class name="ExpressBook.Services.BaseDataObjects.StudentBase,
ExpressBook">
    <id name="id" column="id" type="int32" unsaved-value="0">
      <generator class="native">
      </generator>
    </id>
    <property name="first" column="first" type="text" not-null="false"/
>
    <property name="last" column="last" type="text" not-null="false"/>
  </class>

</hibernate-mapping>

StudentBase.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ExpressBook.Services.BaseDataObjects
{
    public class StudentBase
    {
        public virtual int id { get; set; }
        public virtual string first { get; set; }
        public virtual string last { get; set; }
    }
}

The Offending Code:

Line 20:             NHibernate.ISession session =
sessionFactory.OpenSession();
Line 21:
Line 22:             return
session.Get<Services.BaseDataObjects.StudentBase>(id);

The Error Message:

Stack Trace:


[MappingException: No persister for:
ExpressBook.Services.BaseDataObjects.StudentBase]
   NHibernate.Impl.SessionFactoryImpl.GetEntityPersister(String
entityName) +103
   NHibernate.Event.Default.DefaultLoadEventListener.OnLoad(LoadEvent
event, LoadType loadType) +112
   NHibernate.Impl.SessionImpl.FireLoad(LoadEvent event, LoadType
loadType) +159
   NHibernate.Impl.SessionImpl.Get(String entityName, Object id) +186
   NHibernate.Impl.SessionImpl.Get(Type entityClass, Object id) +137
   NHibernate.Impl.SessionImpl.Get(Object id) +175
   ExpressBook.Models.Student.getStudentById(Int32 id) in C:\Users
\tqwhite\Documents\Visual Studio 2008\Projects\ExpressBook\ExpressBook
\Models\Student.cs:22
   ExpressBook.Controllers.DistrictController.getStudentById(Int32 id)
in C:\Users\tqwhite\Documents\Visual Studio 2008\Projects\ExpressBook
\ExpressBook\Controllers\DistrictController.cs:22
   lambda_method(ExecutionScope , ControllerBase , Object[] ) +79
   System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase
controller, Object[] parameters) +17
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext
controllerContext, IDictionary`2 parameters) +178
 
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext
controllerContext, ActionDescriptor actionDescriptor, IDictionary`2
parameters) +24
 
System.Web.Mvc.<>c__DisplayClassd.<InvokeActionMethodWithFilters>b__a()
+52
 
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter
filter, ActionExecutingContext preContext, Func`1 continuation) +254
 
System.Web.Mvc.<>c__DisplayClassf.<InvokeActionMethodWithFilters>b__c()
+19
 
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext
controllerContext, IList`1 filters, ActionDescriptor actionDescriptor,
IDictionary`2 parameters) +192
 
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext
controllerContext, String actionName) +314
   System.Web.Mvc.Controller.ExecuteCore() +105
   System.Web.Mvc.ControllerBase.Execute(RequestContext
requestContext) +39
 
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext
requestContext) +7
   System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__4() +34
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0()
+21
 
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult
_) +12

   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +59
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult
asyncResult) +44
 
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult
result) +7

 
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+8679150

   System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
Boolean& completedSynchronously) +155

Version Information: Microsoft .NET Framework Version:2.0.50727.4927;
ASP.NET Version:2.0.50727.4927

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to