简体   繁体   English

Hibernate + SQL Server:一个事务阻塞所有其他事务

[英]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.我正在使用 Spring + Hibernate + SQL-Server 开发服务器应用程序,并且我认识到我的所有事务都在阻止其他事务,即使其他事务没有触及相同的表/行并且这些表之间没有关系。

Here is a screenshot:这是一个屏幕截图:

Transaction Report交易报告

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.截图显示A表的delete语句阻塞了表B的select语句,但是表之间没有关系。 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.一开始我为整个过程打开了一个事务,并在这个过程中复制了 n 个对象。 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.这种设计就像 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.就像在我的情况下,已经复制的对象将保留,因为事务已关闭并为每个对象单独提交。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SQL Server事务如何提交我的事务 - SQL Server Transactions how can I commit my transaction 我可以回滚SQL Server中具有多个内部事务的事务吗? - Can I rollback a transaction that has multiple inner transactions in SQL Server? SQL - 基于一个值返回所有交易 - SQL - Returning all transactions based on one value SQL查找总交易金额最大的Top Customer,列出交易,并在底部的行中合计所有交易 - SQL Find Top Customer with greatest total transaction amount, list transactions, and total all transactions in row at bottom SQL Server需要一列的前1条记录和所有其他记录 - SQL Server need top 1 record for one column and all other records SQL Server将一个表的行与另一表的所有行进行比较 - SQL Server Compare rows of one table with all rows of other table 查看SQL Server 2008中的所有事务日志 - View all transaction logs in SQL Server 2008 SQL 服务器过滤在其他事务中选择的行 - SQL Server filter rows which are being selected in other transactions SQL服务器。 TSQL。 在所有其他触发器和所有其他过程之后执行一个我的过程 - SQL SERVER. TSQL. Execute one my procedure after all other triggers and all other procedures 更新其他交易可见的交易价值 - Is updated in transaction value visible to other transactions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM