-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Recover from Rollback in session-per-request best practices?
PostPosted: Mon Jan 12, 2009 9:53 pm 
Newbie

Joined: Mon Jan 12, 2009 9:12 pm
Posts: 1
I'm using nHibernate 2.0 in a winform app and have the following scenario:

Session 1: Used to load a entity, Session 1 closed

Entity bound to screen, user interacts with it and its collections

Session 2:
- Transaction started
- Entity associated to session with SaveOrUpdate
- Flush happens (actually triggered by a query)
- After the flush I notice the version numbers are incremented on dirty entities
- Business Rules evaluated and one fails
- Transaction Rolled Back
- Session Closed

User sees message and fixes problem in Entity (same one still bound)

Session 3:
- Transaction Started
- Flush happens (again triggered by a query)
- Notice version numbers incremented again on dirty entities
- Business Rules evaluated and all pass
- Transaction Committed:
--> Stale Data Exception on account of the version numbers having been incremented twice

What is the recommended way around this? I know I can reload the entities and reapply user changes in code but I'd like to get a generic solution as this will happen throughout the application with entities over varying complexity and object graph depth.

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 26, 2009 7:23 am 
Newbie

Joined: Wed Mar 25, 2009 3:17 am
Posts: 5
I have the same question. Seems related to this topic: http://forum.hibernate.org/viewtopic.php?t=942461


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.