开发者

how does nhibernate handle update collisions behind the scenes with the ver column?

开发者 https://www.devze.com 2023-04-04 09:02 出处:网络
I\'m just looking for some documentation on how hibernate handles collisions using the ver column. understanding thus far:

I'm just looking for some documentation on how hibernate handles collisions using the ver column.

understanding thus far: a change to a row means that the changed row is inserted with a new version number

-- Is this done via "select max(ver)+1"? --

subsequently the previous version gets deleted.

btw: how do we know that {"sel开发者_JS百科ect max(ver)+1"; insert} will be guaranteed to be an atomic operation? Are they locking the row first?

Thanks in advance for any info. I'm just trying to gain a complete understanding.


I'll expand a bit more here. What hibernate executes for an update is something like

UPDATE table SET string = 'string', number = 1, version = version+1 
WHERE id = %Id% AND version = %Version%

This means that the update will only succeed if the version is still the same as when the object/row was loaded from the database and update the version number in the same query.


See http://ayende.com/blog/3946/nhibernate-mapping-concurrency

0

精彩评论

暂无评论...
验证码 换一张
取 消