Session becomes useless when it throws exception, they say Tuna Toksöz Eternal sunshine of the open source mind.
http://devlicio.us/blogs/tuna_toksoz http://tunatoksoz.com http://twitter.com/tehlike On Tue, Jul 21, 2009 at 7:27 PM, Matt Lund <[email protected]> wrote: > > I did searching on this forum and couldn't find an answer to my > question, but my apologies if it's already been answered. > > I want to understand how to deal with recovering from a > StaleObjectStateException in a simple scenario. > > Suppose the following occur in this order. Session 1 is occuring on > thread 1 and Session 2 is occuring on thread 2. > > 1. Session 1 loads entity a1 of type A, entity b1 of type B, and > entity c1 of type C > 2. Session 2 loads entity c2 of type C > 3. Session 1 modifies properties of a1, b1, and c1 > 4. Session 2 modifies properties of c2 > 5. Session 2 flushes and commits > 6. Session 1 flushes and commits > > At step 6 I can clearly expect a StaleObjectStateException. When this > occurs I try to: > > 7. Evict c2 from session 1 > 8. Load c2 on session 1 > 9. Re-apply changes to c2 > 10. Flush session 1 > > But I get StaleObjectStateException on 10 as well. > > So in lieu of the evict/load in steps 7-8 I tried a few other things > that didn't work either. I tried a refresh (same outcome). And I > tried an evict & refresh (same outcome). > > The only success I've had is when, as a result of the > StaleObjectStateException on step 6, I clear the session and re-do > steps 1,5. > > The conclusion I'm reaching is that once I get a > StaleObjectStateException, nothing can be done to simply treat c1 and > get to a point where I can attempt to flush the session again. Is > this the case? > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
