All,
We are having issues with NHibernate L1 Caching. We have an app which
updates a record in the database through UI. There is a background job
which picks up the record and processes it. The issue here is, in the UI we
change the record status from “Pending Approved” and then to “Release”
status. When the background picks up the information it is showing the
status as only “Pending Approved” where as in the database the record is
updated as Release. We see the problem with GetCurrentSession method and
the background job uses same thread context for each request and hence new
session is not created. Find below the GetCurrentSession code. Any ideas of
how to resolve this issue.
public static ISession GetCurrentSession()
{
ISession currentSession = null;
HttpContext context = null;
if (IsInWebContext())
{
context = HttpContext.Current;
currentSession = context.Items[CurrentSessionKey] as
ISession;
if (currentSession == null || !currentSession.IsOpen)
{
currentSession = sessionFactory.OpenSession();
context.Items[CurrentSessionKey] = currentSession;
}
}
else
{
currentSession = (ISession)CallContext
.GetData(CurrentSessionKey);
if (currentSession == null || !currentSession.IsOpen)
{
currentSession = sessionFactory.OpenSession();
CallContext.SetData(CurrentSessionKey, currentSession);
}
}
return currentSession;
}
private static bool IsInWebContext()
{
return HttpContext.Current != null;
}
--
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.