-
1. Re: How To Cancel Update in Home Object
baz Apr 20, 2007 5:48 AM (in response to gzoller)One question:
What do you trying to do?
Perhaps this is your desire?
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=106710
If not please ask again.
And if someone knows the solution to my lasting little problem, eben better.
Hope i could help a little.
Ciao,
Carsten -
2. Re: How To Cancel Update in Home Object
gzoller Apr 20, 2007 1:25 PM (in response to gzoller)Carsten,
I think we're looking at the same problem from different angles. One desired behavior I'm looking for is the ability to cancel a data entry page w/o the changes popping up in the persistent state. I have one page in my app that does this just fine and one that (like yours) somehow persists and keeps the values I wanted to throw away upon cancel. I'll have to do a line-by-line comparison to figure out what the differences are.
The heart of my question is more about the ability to access a field's previous value prior to persisting it, for example in a Home object's update() method. Say for example in update() you'd like to take the difference between a field's old and newly set value and do something with the difference. How would you get the old value?
At the time update() is called the Entity's field has already been set in memory via setFoo(), so no help there. Aha, I thought---I can just hit the db with a query to temporarily pull back the previous value (the find() I show in my example code). But strangely the new value comes back from the query.
Here's what gets me: If I'm hitting the db from within the update() method the new value may exist in memory but hasn't (shouldn't) have been persisted until I call super.update(), right? So why am I getting the new value back? Hmm.
I'd love to know what others have done if they needed to compare old/new values of fields during setting or persisting. The only other thing I thought to try next is to save old values internally in the Entity (transiently of course) and hope that old value is still the last value set when update() is called.
Greg -
3. Re: How To Cancel Update in Home Object
pmuir Apr 20, 2007 1:34 PM (in response to gzoller)Have you looked at this? Its not quite what you are trying to do, but it does access both the old and new variables...
http://wiki.jboss.org/wiki/Wiki.jsp?page=SeamAuditHome -
4. Re: How To Cancel Update in Home Object
gzoller Apr 20, 2007 7:19 PM (in response to gzoller)Many thanks for the tip. No, this isn't quite what I'm after, but it looks quite handy for something else, so much obliged.
I finally got the old/new thing working by simply holding a transient property that is saved off in the setter of the field I want to access old/new values for.