1:用xml的方式配置事物隔离级别,Read Uncommitted不生效
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="get*" propagation="REQUIRED" read-only="true" />
<tx:method name="find*" propagation="REQUIRED" read-only="true" />
<tx:method name="query*" propagation="REQUIRED" read-only="true" />
<tx:method name="load*" read-only="true" />
<tx:method name="*Event" read-only="true" />
<tx:method name="*Task" read-only="true" />
<tx:method name="barrier*" isolation="READ_UNCOMMITTED" />
<tx:method name="read*" isolation="READ_UNCOMMITTED" />
<tx:method name="sync*" propagation="NEVER" />
<tx:method name="nver*" propagation="NEVER" />
<tx:method name="supports*" propagation="SUPPORTS" />
<tx:method name="notsupported*" propagation="NOT_SUPPORTED" />
<tx:method name="*" />
</tx:attributes>
</tx:advice>
2:用注解的方式可以生效,不知道是不是spring版本的问题。
3:附上我使用的版本,希望大家遇到这个spring这个3.2.0版本如果read uncommitted不起作用,就用注解的方式,就可以生效了
Manifest-Version: 1.0
Created-By: 1.7.0_05 (Oracle Corporation)
Implementation-Title: spring-core
Implementation-Version: 3.2.0.RELEASE
Manifest-Version: 1.0
Created-By: 1.7.0_05 (Oracle Corporation)
Implementation-Title: spring-tx
Implementation-Version: 3.2.0.RELEASE
4:上面这个问题坑了我2天,被项目经理说了2周,就是说我这个查询老是报锁获取异常,实际就是read uncommitted不起作用。