You can't precisely restore object state if you're operating on original
object.
You need to make clone of it, attach it to new session and use that copy for
editing. 
Than you can just throw away session without the need to restore state.

There few particular problems we've identified so far for this approach:
1. Listeners, interceptors and similar staff will be given reference to the
clone not the original object.
2. You need to set back on original objects identifiers assigned by NH and
also values of timestamp and version columns.

First is not problem for us, as logic in our listeners and interceptors do
not depend of reference passed but rather on state.
And I think most such staff written at other parties also. But there can be
someone who can suffer from that fact.

Second is not such a big deal but can be tedious if not automated.

P.S. This list may not be complete.
P.P.S. As I understand Refresh should respect cascades as any other similar
operation in NH (like Lock, Save, Update etc) or maybe I'm wrong?

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf
Of darren
Sent: Monday, June 22, 2009 6:39 PM
To: nhusers
Subject: [nhusers] Re: Transaction rollback question


Refresh works but from what I can tell Refresh only restores a single
object.  If it does I'd have to enumerate all the objects in the
session and refresh them manually.

It also hits the database again; aren't the original values already
cached in the session?


On Jun 19, 8:13 pm, Fabio Maulo <[email protected]> wrote:
> You are doing something wrong in somewhere else. My advice is not hope
that
> is a bug in NH.
> If for "restore data" you mean restore old data of your in memory objects
> what you should do, after rollback, is a Refresh
>
> 2009/6/19 darren <[email protected]>
>
>
>
> > If I load data into a session, start a transaction, make some changes,
> > then rollback the transaction why is the session data not restored to
> > the state it was in when the transaction started?
>
> > I'm trying to figure out how implement cancel edit behaviour and
> > haven't been able to find any examples.
>
> --
> Fabio Maulo
 

__________ Information from ESET Smart Security, version of virus signature
database 4174 (20090620) __________

The message was checked by ESET Smart Security.

http://www.esetnod32.ru
 
 

__________ Information from ESET Smart Security, version of virus signature
database 4174 (20090620) __________

The message was checked by ESET Smart Security.

http://www.esetnod32.ru
 


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