I think the problem is your transaction management in end request. rollback
if error (good) else flush session (bad). call transaction.commit() instead
and dispose of the transaction.
some things to consider:
1. sessions are cheap so just create one for each request and dispose when
the request ends.
2. all NH actions should be wrapped in a transaction if every request will
require db access begin/end the transaction with the session. if not all WCF
calls require NH, than manage the transaction with a decorator around the
WCF call (similar to Filters in MVC frameworks)
I would start by cleaning up the module code
//begin request
var session = SessionFactory.OpenSession();
session.BeginTransaction();
ManagedWebSessionContext.Bind(HttpContext.Current, session);
//end request
var session = ManagedWebSessionContext.Unbind(HttpContext.Current,
SessionFactory);
using(session)
{
using(var tx = session.Transaction)
{
if(Server.LastException == null)
{
tx.Commit();
}
else
{
tx.Rollback();
}
}
}
that's it. now if you want to manage the transaction per WCF action then the
module would only manage the session
//begin request
ManagedWebSessionContext.Bind(HttpContext.Current,
SessionFactory.OpenSession());
//end request
ManagedWebSessionContext.Unbind(HttpContext.Current,
SessionFactory).Dispose();
and a WCF decorator would manage the transaction. something like
//decorator... wcfservice is the original/base implementation
using(var txt = SessionFactory.GetCurrentSession().BeginTransaction())
{
try
{
wcfservice.Proceed();
tx.Commit();
}
catch
{
tx.Rollback();
throw;
}
}
--
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.