views:

32

answers:

1

Hi

I have implemented optimistic locking for concurrency situations. I have used the version property in the mapping files to link to a integer.

My aim is that if a user tried to save an out-of-date object, she will be given the option to overwrite changes.

I have easily managed to get the SaveOrUpdate to throw an exception, but how do I now override that so that if the user so wishes, the current object overwrites the existing persisted object, while still updating the version number, and without doing a manual member-wise copy of the variables into the non-stale object?

This seems like this is a regular logical scenario, but I don't see any built-in mechanism for this.So is this an anti-pattern?

Thanks for your help and insight.

Kind regards

LJ

A: 

I think you should look into the session.Merge method.

Jide

Jideo