Hi,
I'm developing and Enterprice Application that use NHibernate and some Microsoft's Application Block.
This is the first time that I use NHibernate and I have many problems to implement the optimistic concurrency.
I read the strategies for the optimistic concurrency control in the NHibernate Documentation specially the case
"Many Sessions with automatic versioning".
Using
Composite User Interface Application Block I create one ISession per WorkItem so I have many sessions and many detached entities.
When the user modify the entities the standard Data Flow is the follow:
[One WorkItem]
1. Load Entities
[An other WorkItem]
2. Modify Entities
3. Update Entities
Now when the user update an entity I call session.Update(...) method and I catch the StaleStateException (In the NHibernate Class Mapping File there are the follow settings: dynamic-update="true" and optimisic-lock="dirty"). When the Exception is catched I want to display an error messange and to ask to the user if reload the entity.
Now, Which is the best way that I must use for the entity reload?
I'm trying to use the session.Refresh(...) method but there is a problem when the user try to save the data after the refresh. The problem is the sql update query that have in the where clause the first entity data and not the refreshed data so the StaleStateException is fired another time.
Where is the mistake?
P.s.: sorry for my broken english.
Regards
Andrea