开发者

How do I override the default isolation level when using the Transaction attribute in Spring.Net

开发者 https://www.devze.com 2023-04-12 12:12 出处:网络
When using the Transaction() attribute on a method the default isolation level is ReadCommitted.What I want to do is set the default isolation level to ReadUncommitted in the Spring.NET config ( so as

When using the Transaction() attribute on a method the default isolation level is ReadCommitted. What I want to do is set the default isolation level to ReadUncommitted in the Spring.NET config ( so as not to modify all the Transaction attribute definitions that exist currently)

How do I do it ? Can it be done with Spring.NET 1.2 ?

I've tried to follow the documentation using tx:advice etc to no avail.

I've even stepped in to the code of Spring with Reflector but all I开发者_StackOverflow中文版 seem to understand from that, is that Spring simply reads the settings from the Attribute declaration on the method.

Can it be done or am I going to have to go through the code and modify the attribute where necessary?


I usually use e.g.:

[Transaction( IsolationLevel.ReadUncommitted )]

on my repository methods. And it works in conjuction with <tx:attribute-driven transaction-manager="HibernateTransactionManager"/>.

<object
  name="HibernateTransactionManager"
  type="Spring.Data.NHibernate.HibernateTransactionManager, Spring.Data.NHibernate32"
  dependency-check="none">
  <property name="DbProvider" ref="MsSqlDbProvider"/>
  <property name="SessionFactory" ref="SessionFactory"/>
</object>


You should be able to create your own transaction interceptor that extends the standard transaction interceptor. And then hook up that one using ObjectNameAutoProxyCreator instead of the TransactionProxyFactoryObject that you referenced.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号