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 7605229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:06:50+00:00 2026-05-31T00:06:50+00:00

I seem to be having a weird problem. In our services layer, we are

  • 0

I seem to be having a weird problem. In our services layer, we are using WCF with nHibernate and Spring.NET 1.3.0.20349. I don’t have the option to upgrade spring to the next version.

I have save methods on a service that has AfterReturningAdvices which are required to make another service call that calls into the Db and uses the ID of the saved object. The problem is that the interceptor is firing before the transaction commits which is causing the next service call to return empty objects

After some reading, my understanding of Springs Interceptors are :

  1. The pre-interceptors beforeadvice methods run
  2. Spring starts the transaction
  3. The post-interceptors beforeadvice methods run
  4. The main service method runs
  5. The post-interceptors afterreturning advice methods run
  6. Spring commits the transaction
  7. The pre-interceptors afterreturning advice methods run

My web.config has the following:

  <object id="InsertPointcut" type="Spring.Aop.Support.NameMatchMethodPointcutAdvisor, Spring.Aop">
    <property name="advice">
      <ref local="afterAddInterceptor"/>
    </property>
    <property name="MappedNames">
      <list>
        <value>AddToEvent</value>
      </list>
    </property>
  </object>

  <object id="UpdatePointcut" type="Spring.Aop.Support.NameMatchMethodPointcutAdvisor, Spring.Aop">
    <property name="advice">
      <ref local="afterUpdateInterceptor"/>
    </property>
    <property name="MappedNames">
      <list>
        <value>Update</value>
      </list>
    </property>
  </object>
      <object id="ServiceProxy" type="Spring.Transaction.Interceptor.TransactionProxyFactoryObject, Spring.Data">
    <property name="PlatformTransactionManager" ref="transactionManager"/>
    <property name="TransactionAttributeSource" ref="attributeTransactionAttributeSource"/>
    <property name="target">
      <object id="Service" type="Service, Service" init-method="init">
        <constructor-arg ref="sessionFactory" />
        <property name="EventRepository" ref="eventRepository" />
      </object>
    </property>
    <property name="preInterceptors">
      <list>
        <ref local="throwsAdvice"/>
        <ref local="InsertPointcut"/>
        <ref local="UpdatePointcut"/>
      </list>
    </property>       
  </object>

Can anyone help?

[Update]

In order to avoid making code changes to my services, I implemented the ITransactionSynchronization interface on my advice and registered it. That way, in the AfterCompletion method, I can do my work after spring & nHibernate has committed. I’m not sure if there is a better way to handle this but it seems to work.

 public class AfterUpdateInterceptor : IAfterReturningAdvice, ITransactionSynchronization
{
    private int id;
    [Transaction]
    public void AfterReturning(object returnValue, MethodInfo method, object[] args, object target)
    {
        TransactionSynchronizationManager.RegisterSynchronization(this);
        if (args == null || args.Length == 0)
        {
            return;
        }

        id = PropertyHelper.GetIdPropertyValue<IUpdateContract>(args);
    }

    public void Suspend()
    {
    }

    public void Resume()
    {
    }

    public void BeforeCommit(bool readOnly)
    {
    }

    public void AfterCommit()
    {
    }

    public void BeforeCompletion()
    {
    }

    public void AfterCompletion(TransactionSynchronizationStatus status)
    {
        if (status != TransactionSynchronizationStatus.Committed) return;//.com msg not sent.

        if (id > 0)
        {
            XmlSender.SendXmlUpdate(MessageType.Update, id);
        }
        id = 0;
    }
}
  • 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-31T00:06:51+00:00Added an answer on May 31, 2026 at 12:06 am

    From looking at the source of the TransactionProxyFactoryObject‘s AfterPropertySet Method, I think that is in fact the order of the applied advices. So you should have a AfterReturningAdvice configured in your pre-interceptors.
    If this isn’t called, it might be a bug and I would suggest to ask in the spring.net forums.

    Another way to get called when an transaction is comitted is the ITransactionSynchronization Interface which can be registered with the TransactionSynchronizationManager.

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

Sidebar

Related Questions

One of my users is having this weird problem that I cannot seem to
I seem to be having a problem with checking for list equality. In my
Okay, I seem to be having a problem. I'm trying to create a twicker
I'm having trouble with MySQL or Python and can't seem to isolate the problem.
I am having a strange problem and I can't seem to figure it out.
Maybe my question might seem a bit weird, but I have an activity in
i having a very weird problem now . I has separate 2 jquery js
I'm having a very weird problem with radio buttons in JQuery Mobile. I'm populating
I'm currently having a really weird issue and I can't seem to figure out
I seem to be having a weird issue here. An extended component has the

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.