NHibernate users,

I'm pretty new to nHibernate and I've been watching the summer of
nhibernate series (very good btw!).  I've also read this:
http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx
and this: 
http://nhforge.org/blogs/nhibernate/archive/2010/07/11/nhibernate-bootstrapper-unitofwork-and-sessionperrequest.aspx

All of those methods seem to suggest that Session Per Request is the
way to go with nHibernate.  Though this may work for multiple hits per
session and speed things up, how do people do this for ASP .NET
applications?

My issue is that when I load the data via nHibernate the session goes
away, and then when I want to save the data back to the database the
data in the database may have already changed and I need to throw an
exception to the user and give them the latest data.

Can anyone provide a working code example on how they have handled
this with the follow types of data:

1.  Tables with timestamp columns
2.  Tables without timestamp columns or any versioning columns to
begin with, therefore I'm looking for the techniques in nHibernate
that just pass in a huge WHERE SQL clause that compares all columns to
make sure they are still the same and if not throws a concurrency
violation.  We have a lot of these due to legacy databases.

Right now I have the session working on a per request basis in the
ASP .NET demo application, but am looking for guidance on the
concurrency issue (with code examples, and the appropriate HBM XML
mapping examples).

As I see it right now I need to have nHibernate go and retrieve the
data from the database again, compare the timestamp value and if it is
different then throw a concurrency violation to the user and give them
the latest data to try update again.

How have people done this in the past with highly volatile data using
a stateless application such as ASP .NET?  Any code examples you can
point me to?

-- 
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