简体   繁体   English

MS-SQL快照隔离和休眠行为

[英]MS-SQL Snapshot Isolation and Hibernate behaviour

My doubt is relating to the behaviour of Snapshot isolation in SQLserver 2008 and its corresponding configuration in hibernate 我的疑问与SQLserver 2008中的快照隔离行为及其在hibernate中的相应配置有关

I am referring to the following link 我指的是以下链接

Step1: To enable snapshot isolation I have to run the following statements in the database: 步骤1:要启用快照隔离,我必须在数据库中运行以下语句:

ALTER DATABASE MyDatabase
SET ALLOW_SNAPSHOT_ISOLATION ON

ALTER DATABASE MyDatabase
SET READ_COMMITTED_SNAPSHOT ON

Step2: And I set the following property in hibernate.cfg.xml 步骤2:然后在hibernate.cfg.xml中设置以下属性

<!-- Hibernate Isolation Level [READCOMMITED SNAPSHOT ISOLATION]-->    
<property name=”hibernate.connection.isolation”>4096</property>

What I have observed is that, when I omit Step2 from the configuration file, the snapshot isolation does not work in my java program. 我观察到的是,当我从配置文件中省略Step2时,快照隔离在我的Java程序中不起作用。

Since the isolation level is set in the Database, shouldn't it work irrespective of the hibernate configuration ? 由于隔离级别是在数据库中设置的,因此无论休眠配置如何,它都不能正常工作吗?

因为它设置了JDBC事务隔离级别。

See this link: 看到这个链接:

(Queries have to do this explicitly– as in run a command 'SET TRANSACTION ISOLATION LEVEL SNAPSHOT', or have it set in their connection string.) (查询必须明确地执行此操作,如在运行命令“ SET TRANSACTION ISOLATION LEVEL SNAPSHOT”时一样,或在其连接字符串中进行设置。)

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM