Reputation: 1548
I've got a problem doing updates with a stateless session and I'm wondering if anyone has seen something like this. (NHibernate 3.1).
I'm basically doing the following:
SomeEntity e = statelessSession.Get<SomeEntity>(id);
e.SomeProperty = "a new value";
statelessSession.Update(e);
and I am getting the following error:
NHibernate.MappingException: No persister for:
Castle.Proxies.SomeEntityProxy
at NHibernate.Impl.SessionFactoryImpl.GetEntityPersister(String
entityName)
at NHibernate.Impl.StatelessSessionImpl.GetEntityPersister(String
entityName, Object obj)
at NHibernate.Impl.StatelessSessionImpl.Update(String entityName,
Object entity)
at NHibernate.Impl.StatelessSessionImpl.Update(Object entity)
The mapping -
class SomeEntityMap : ClassMap<SomeEntity>
{
public SomeEntityMap()
{
Table("Some_Entity");
Id(x => x.ID).Column("ID");
Map(x => x.Name).Column("NAME");
}
I have stepped through in the debugger and can see that statelessSession.Get(id) is returning me a proxy. Is this correct?
anyone have any idea what is the problem ? Please share your view and suggestion.
Upvotes: 4
Views: 3463
Reputation: 2003
I did a test project as you outlined in your question and wasn't able to reproduce the issue. The only scenarios that I was able to reproduce the error were:
The location of the mappings haven't been specified when initializing the session factory, i.e. you are missing
Fluently.Configure()
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<SomeEntity>());
One of the properties of SomeEntity
has been marked as lazy="no-proxy"
. More information can be found here.
Upvotes: 1