You cannot recover from transaction rollback.You have to create a new
session.

On Mon, Jan 12, 2009 at 8:00 PM, kzjkd6 <[email protected]> wrote:

>
>
> We are trying to use nHibernate in a winform application.  We are
> using it in a session-per-business-activity model with entities that
> are disconnected and then associated to sessions using SaveOrUpdate
> ().
>
> We have the following scenario:
>
> App loads entity in Session 1.
> Session 1 is closed.
> App make changes to entity in response to user interaction
> Session 2 is started
> Transaction is started
> Entity is associated with session
> Query is made (which triggers a Flush and as a result the version
> number is incremented on the dirty entity)
> As a result of the business rules evaluated on the query results we
> decide not to commit the transaction.
> Transaction is rolled back.
> Session 2 is closed.
>
> User is shown a message explaining the problem.
> User fixed the problem (screen still bound to the same entity)
>
> Session 3 is started
> Transaction is started
> Entity associated with Session
> Query is made again (which triggers another Flush and the version
> number is incremented yet again)
> Business Rule now satisfied
> Transaction is committed.
> --> Exception thrown because the version number no longer satisfies
> the optimistic lock.
>
> I know we could throw away the user's changes and re-fetch the entity
> when the business rule is initially violated but that represents a
> huge pain for the users.  I know we could do this and then re-apply
> changes on the user's behalf but I am looking for a generic solution
> as the object graph can be quite deep.
>
> What is the recommend way to get around this?
>
> Thanks.
>
>
>
> >
>

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