Hi I just saw a (simplified) code snippet similar to this one in our project
var someEntity = fetchFromDb(Dto.Id); [setting props according to the dto, including...] someEntity.SetVersion(dto.Version); Persist(); ...when someEntity is persisted, the generated sql will use the version value from the row "fetchFromDb" and not the value explicitly set the next row. I guess this is because NH is using version value from its internal 1st level cache when flushing (?)? I know that this problem can be solved by skipping the explicit db load and instead relying on Merge(). Another way would be to handle the version check ourselves one way or the other. However - it's pretty easy for an user to write code like above though, assuming that optimistic locking is correctly used. Why is NH behaving this way? Why isn't nh generate sql based on the entity's current version state? Is there any obvious reason that I don't see? Also... If you are not supposed to change the version state on a persisted entity, couldn't nh notice this and throw at persist to prevent code like above? I guess this can be handled using an interceptor or event listeners but why not default? /Roger --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
