c# - How to Implement concurrency in NHibernate -
i have 2 person , persondto classes , i'm using nhibernate save these objects. while have 1 user there no problem , user going update object user updating it. both of can update same object , because updated user, on of changes lost.
in order implement cuncurrency used 2 ways both of them faced problem.
- the first solution : use person constructor update object
- the second approach : using getbyid method
the first approach working great problem unfortunately don't have enough permition load person completetly dependencies. have use second approach.
in second approach when set (update) version o last second, nhibernate using old version changes won't apply.
look @ following code
load person id
person = locator.personrepository.getbyid(dto.id);
version field loaded new value. need set persondto object
person.version = dto.version
during update process nhibernate passes old value sql , don't face concurreny error.
what should implement concurrency in way. appriciated.
as understand problem, guess have field getter works fine when trying set face problem, if so, check following considerations
- check if version field not readonly
- check if has public setter not private one
- check if have needed properties in mapper
- check happening in person constructor not raise when use getbyid method
provide more information if these ideas didn't you
Comments
Post a Comment