views:

998

answers:

2

Hi, I was wondering if this seemed to familiar to any experience NHibernate developers or if someone could give me an idea as to where to start to try and resolve this issue:

I inherited an NHibernate site written in ASP.NET 1.1 using NHibernate 0.6 and .NET remoting to the DAL layer residing on the database server. I have been trying to upgrade it to ASP.NET 3.5 and NHibernate 1.2.1.4.

I replaced the .NET remoting setup with a direct database connection and everything works fine until the site gets under some load and then NHibernate calls start to intermittently fail throwing an exception: ADOException could not execute query followed by the NHibernate generated SQL statements.

The stack trace given with the error is: NHibernate.Loader.Loader.LoadEntity(ISessionImplementor session, Object id, IType identifierType, Object optionalObject, Type optionalEntityName, Object optionalIdentifier, IEntityPersister persister)

at NHibernate.Loader.Entity.AbstractEntityLoader.Load(ISessionImplementor session, Object id, Object optionalObject, Object optionalId)

at NHibernate.Loader.Entity.AbstractEntityLoader.Load(Object id, Object optionalObject, ISessionImplementor session)

at NHibernate.Persister.Entity.AbstractEntityPersister.Load(Object id, Object optionalObject, LockMode lockMode, ISessionImplementor session)

at NHibernate.Impl.SessionImpl.DoLoad(Type theClass, Object id, Object optionalObject, LockMode lockMode, Boolean checkDeleted)

at NHibernate.Impl.SessionImpl.DoLoadByClass(Type clazz, Object id, Boolean checkDeleted, Boolean allowProxyCreation)

at NHibernate.Impl.SessionImpl.Load(Type clazz, Object id)

Thanks!

+1  A: 
  • verify your connection settings.
  • if you can, cache objects as much as you can to avoid battering the server
  • make sure you've got your tables indexed...that's a huge one
  • make sure log4net's logging is turned to warn/error so you're not writing an encyclopedia to the logs
mspmsp
+1  A: 

Problem was non thread-safe nhibernate session factory. Changed project to use an http module to use one nhibernate session per request (and made sure not to open a session for rquests on non .as*x files) and all is well.

CtrAltDel