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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:42:20+00:00 2026-06-01T17:42:20+00:00

I have a service that has several methods marked with @Transactional , including methods

  • 0

I have a service that has several methods marked with @Transactional, including methods a, b and c. These 3 methods are nested in the following way a -> b -> c. Here is a code sample:

@Transactional
public void a() {
    while(condition) {
        try {
            b();
        } catch(MyException e) {
            logger.warn(e.getMessage());
        }
    }
}

Method b however is annotated like this:

@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = {MyException.class})

However, when MyException is thrown from method c, the exception is caught at method a and when that exits, the transaction is comitted and that includes whatever has been done by call to b() that threw the exception and should have been rolled back(?).
I am using sql server 2012 express with spring 3.0.7 and my spring configuration is like this:

<tx:annotation-driven />
<bean class="org.springframework.orm.jpa.JpaTransactionManager" id="transactionManager">
    <qualifier value="txm1"/>
    <property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<bean class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" id="entityManagerFactory">
    <property name="dataSource" ref="dataSource"/>
    <property name="persistenceXmlLocation" value="classpath:META-INF/jpa-persistence.xml"/>
    <property name="persistenceUnitName" value="Unit1" />
</bean>
  • 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-06-01T17:42:21+00:00Added an answer on June 1, 2026 at 5:42 pm

    Method b seems to be in the same class as method a. If you’re not using AspectJ, the @Transactional-annotations are handled by a JDK dynamic proxy, through which your calls from outside the class travel to method a. The call needs to travel through the proxy for the @Transactional-annotations to have effect, see for example here, under ‘Understanding AOP proxies’: http://static.springsource.org/spring/docs/3.0.0.M3/spring-framework-reference/html/ch08s06.html

    The key thing to understand here is that the client code inside the
    main(..) of the Main class has a reference to the proxy. This means
    that method calls on that object reference will be calls on the proxy,
    and as such the proxy will be able to delegate to all of the
    interceptors (advice) that are relevant to that particular method
    call. However, once the call has finally reached the target object,
    the SimplePojo reference in this case, any method calls that it may
    make on itself, such as this.bar() or this.foo(), are going to be
    invoked against the this reference, and not the proxy. This has
    important implications. It means that self-invocation is not going to
    result in the advice associated with a method invocation getting a
    chance to execute.

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

Sidebar

Related Questions

I have a WCF web service that exposes several business methods. I also have
I have a service that has a dependency on SQL server express (2005). Every
I have a windows service that has it's name set by an app.config. I
I have a simple web service that has an API third party developers are
We have an application that has a WCF service (*.svc) running on IIS7 and
I have interface in service layer with several methods starting with Get and FxCop's
I have a service that I would like it to become single instance, because
I have a service that is downloading a file. When the download is done,
I have .Net service that listens on single port over TCP protocol. Clients connect
I have a service that needs to update the registry every 5 minutes (counteract

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.