sql - Hibernate + SQL Server: One Transaction blocks all other transactions
问题描述
I am developing a server application with Spring + Hibernate + SQL-Server and i recognized that all my transactions are blocking other transaction, even if other transactions do not touch the same tables / rows and there are no relationships between this tables.
Here is a screenshot:
The screenshot shows that a delete statement on table A blocks a select statement on table B. But there is no relationship between the tables. In my understanding a transaction should only lock a table or row and another transactions that will hit the locked table or row will be blocked. But why are all transactions blocked? Do i missunderstand anything?
解决方案
Solution was found:
The process was a copy-process. At the beginning i opened a transaction for the whole process and copy n-objects in this process. When i need to do selects while copying the selects were blocked. So i decide to open a transaction everytime i copy one object and after that copying-process close the transaction for this one object. So selects are no longer blocked. This design is like the copy-process in Windows. If you decide to cancel the copy-process the already copied files will stay. Like in my case the already copied objects will stay cause the transaction was closed and committed for every object separatly.
推荐阅读
- arrays - xcode 7 图像数组分配
- azure-web-app-service - 使用 AlwaysOn 的 10.0.128.25 地址作为 Azure 应用服务中的 IP 限制?
- javascript - 即使分片文件为真,测试也会在量角器中按顺序运行
- wordpress - Wordpress post_type 在插入/更新帖子之前需要 post_title
- ios - 如何更改 JSON 键名 Swift?
- php - mysql加入多个值的子查询
- python - 如果字符串包含“XX”然后改变颜色...Write_rich_string 到 Panda Dataframe?
- python - 如何在 Python 烧瓶应用程序中对 main() 函数进行行分析?
- robotics - 在辣椒机器人中将项目保存为默认值的问题
- javascript - 如何覆盖文本
使用 JavaScript 标记