问题
We are using SQL Server and it is possible that Snapshot isolation may be a good way to improve out performance and fix some deadlocking concerns.
Assuming that we have a real need to change to Snapshot isolation, I can't seem to find an easy way to enable Snapshot isolation on Springs @Transactional
.
I found the following hibernate configuration option for doing it in Hibernate, however we use spring-jdbc and don't have a hibernate impl. this seems to suggest that the isolation value could be provided manually somehow.
<property name=”hibernate.connection.isolation”>4096</property>
Does anyone know of a way of getting Spring to use SQL Server Snapshot isolation on transactions?
回答1:
4096 is code for SNAPSHOT isolation, refer post here, you have to set isolation level on connection object, I don't think you can achieve this with @Transactional, you can use other transaction solutions provided by spring, mainly 'TransactionTemplate'.
来源:https://stackoverflow.com/questions/8983873/spring-isolation-support-msql-snapshot-isolation