Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 761169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:48:22+00:00 2026-05-14T15:48:22+00:00

i am using Spring.net 1.2 with NHibernate 2.0.1. Within my project i’am facing some

  • 0

i am using Spring.net 1.2 with NHibernate 2.0.1.
Within my project i’am facing some Deadlock issues and besides the database tweaks to minimize the occurence i would like to implement Springs RetryAdvice to handle this.
I can’t find any working example how to configure a this. The reference seems to be clear about how to use it but somehow i can’t get it working.

<!--Used to translate NHibernate exception to Spring.DataAccessExceptions-->    
<object type="Spring.Dao.Attributes.PersistenceExceptionTranslationPostProcessor, Spring.Data"/>

<!--ExceptionHandler performing Retry on Deadlocks-->
<object name="ExceptionHandlingAdvice" type="Spring.Aspects.RetryAdvice, Spring.Aop">
  <property name="retryExpression" value="on exception name DeadLockLoserException retry 3x rate (1*#n + 0.5)"/>
</object>

I have added the [Repository] attribute to my DAOs to get ExceptionTranslation enabled and tried to add the RetryAdvice to the TransactionProxyFactoryObject i am using but it won’t work. I don’t understand where to put this Advice. Do i have to declare a PointCut to add it or how could i get it to work as expected.

Thx in advance – any help appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:48:22+00:00Added an answer on May 14, 2026 at 3:48 pm

    After 1 and a half month of waiting for someone solving my problem i finally found time to elaborate the solution for this by myself. In fact it wasn’t that difficult i thought it was. Maybe thats why i wasn’t able to find any good example.
    So here we go: The following test will show the usage:

    Configuration: (SessionFactory and TransactionManager etc. omitted for brevity)

      <!-- Retries the Tx after DeadlockExceptions -->
      <object name="ExceptionHandlingAdvice" type="Spring.Aspects.RetryAdvice, Spring.Aop">
        <property name="retryExpression" value="on exception name DeadlockLoserDataAccessException retry 3x delay 1s"/>
      </object>
    
      <!--A Transaction-Configuration for our DAO-MOCK-->  
      <object id="TxProxyConfigurationTemplate" abstract="true" type="Spring.Transaction.Interceptor.TransactionProxyFactoryObject, Spring.Data">
        <property name="PlatformTransactionManager" ref="HibernateTransactionManager"/>
    
        <property name="TransactionAttributes">
          <name-values>
            <add key="ThrowDeadLock*" value="PROPAGATION_REQUIRED"/>
          </name-values>
        </property>
      </object>
    
      <object id="MockDaoTxPFO" parent="TxProxyConfigurationTemplate">
        <property name="Target" ref="MockDao"/>
      </object>
    
      <!--The ProxyFactoryObject based on the DAO-Mock interface-->
      <object id="MockDao" type="Spring.Aop.Framework.ProxyFactoryObject, Spring.Aop" >
        <property name="proxyInterfaces" value="RetryAdvice.IDaoMock"/>
        <property name="target" ref="MockDaoImpl"/>
        <property name="interceptorNames">
          <list>
            <value>ExceptionHandlingAdvice</value>
          </list>
        </property>
      </object>
    
      <!--Mocked DAO Implementation -->
      <object id="MockDaoImpl" type="RetryAdvice.DaoMock, RetryAdvice">
        <constructor-arg name="maxExceptionCount" value="2" />
      </object>
    

    Mocked Dao: This DAO will throw DeadLockLooserExceptions twice and then pass.

    public interface IDaoMock
    {
        void ThrowDeadLock();
        int MethodCallCount { get; }
    }
    
    [Repository]
    public class DaoMock : IDaoMock
    {
        private int maxExceptionCount;
        public int MethodCallCount { get; private set; }
    
        public DaoMock(int maxExceptionCount)
        {
            this.maxExceptionCount = maxExceptionCount;
        }
    
        public void ThrowDeadLock()
        {
            MethodCallCount++;
            if (MethodCallCount <= maxExceptionCount)
            {
                throw new DeadlockLoserDataAccessException("FAKE", new HibernateException("This is a fake Exception.", null));
            }
        }
    

    The Test:

    [Test]
    public void RetryAdviceTest()
    {
        IDaoMock mockDao = (IDaoMock)this.appContext.GetObject("MockDaoTxPFO");
        mockDao.ThrowDeadLock();
        Assert.That(mockDao.MethodCallCount, Is.EqualTo(3));
    }
    

    Any hints or remarks appreciated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to develop a .NET Web Project using NHibernate and Spring.NET, but
I am using NHibernate 2.0.1 and .NET I am facing issues with Lazy loading
I'm using Spring.net with NHiberante (HibernateTemplate) to implement my DAO's. I also have some
I'm using Spring.NET 1.3.2, NHibernate 3.1 and the OSIV pattern in a ASP.NET application.
In my previous project we used NHibernate and Spring.NET. Transactions were handled by adding
How can I setup NHibernate Validator with Spring.net as IoC? I am already using
I'm working on a project which currently uses NHibernate 2.1.2, FluentNHibernate 1.1 and Spring.Net
I am using Sping.Net 1.3.1 and Nhibernate 3.0. I use Spring's Transaction Interceptor in
We are using Spring.NET for Dependency Injection and NHibernate as ORM. We use Session
i want to get data from sql server database in asp.net using NHibernate. what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.