隔离问题 - 读取 - 提交 [英] Concurency problem with Isolation - read-committed

查看:161
本文介绍了隔离问题 - 读取 - 提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须从一个联合银行的金额中写出一个简单的金额退出示范.Andy和Jen持有一个共123个银行账户。假设他们的账户有100美元.Jen和Andy正在同一时间运行他们的帐户,并且都试图在当时提取90 $。我的交易隔离被设置为读取 - 提交,并且都能够提取钱离开余额为 - (减)80 $虽然我有约束,平衡不应该小于0。



我正在使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆