隔离问题 - 读取 - 提交 [英] Concurency problem with Isolation - read-committed
问题描述
我正在使用hibernate。我的版本控制只有这样解决这个问题或者我应该去另一个隔离级别?
我很想说乐观锁定的确是要走的路(这就是我会做的而不是改变隔离级别,同一记录上的并发访问听起来像一个特殊的机构)。
I have to write a simple demo for amount withdrawl from a joint Bank amount .Andy and Jen holds a joint bank account with number 123 . Suppose they have 100$ in their account .Jen and Andy are operating their account at the same time and both are trying to withdraw 90$ at the time being .My transaction Isolation is set to read-committed and both are able to withdraw money leaving the balance to -(minus)80$ although I have constraint that balance should never be less than 0.
I am using hibernate .Is versioning only way to solve this problem or I should go for another Isolation level ?
I'm tempted to say that optimistic locking is indeed the way to go (and this is what I would do instead of changing the isolation level, concurrent accesses on the same record sounds like an exceptional situtation).
这篇关于隔离问题 - 读取 - 提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!