What are the best practices for using NHibernate in web services (or
in any n-tier pattern) where you pass your object out of the scope of
the session to the client, have them modify it, then send it back for
persistence?

Simple Example with User object:

* Client calls service to request existing User.
* Service opens session, gets User, returns it to client, closes
session
* Client modifies User, then sends it to the service to persist the
updates
* Service opens a session, validates object, persists to database,
then closes session

Some questions...

1) If the client sets a property on the User object outside the scope
of the session:
      a) Is it marked as dirty?
      b) If so, is it marked as dirty if they assign the same value
that already existed?

2) In the service, what is the best way to obtain the previous state
for the User? If I attempt to open another copy of the object I get an
error saying that the object already exists in the Session. If I try
to use the method outlined here (http://nhforge.org/wikis/howtonh/
finding-dirty-properties-in-nhibernate.aspx), I get null errors when
attempting to unproxy.  The only thing I can think of is to user 2
sessions: Get a copy of the original in the first, then check the
values in the second.  I'm guessing there is a better way or that I am
missing something.

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