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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:01:30+00:00 2026-06-09T04:01:30+00:00

I have gone through number of post regarding tx with spring and AspectJ. Below

  • 0

I have gone through number of post regarding tx with spring and AspectJ. Below is the summary,
Say, I have a service class and its interface

interface TestService {
 void methodA();
 void methodB();
}

class TestServiceImpl implements TesService {

   @Transactional
   void methodA() {
      methodB();
   }

   @Transactional(propagation=Propagation.NEVER)
   void methodB(){}
}

And my configuration

<tx:annotation-driven transaction-manager="jpaTxManager"/>

<bean id="jpaTxManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory"><ref bean="entityManagerFactory"/></property>
<property name="dataSource"><ref bean="dataSource"/></property>
</bean>

<bean id="testService" class="com.motherframework.plugin.test.service.TestServiceImpl">
     <property name="testDAO" ref="testDAO"/>
</bean>

I am calling testService.methodA() from some client class. As per spring’s JDK dynamic proxy usage, it will only care about @Transactional on methodA(), but not @Transactional(propagation=Propagation.NEVER) on methodB(). So the code executes with proper transaction and commits. If we use AspectJ mode then it will also check for @Transactional(propagation=Propagation.NEVER) on methodB() and will throw an exception.

Now my question is, why this limitation is imposed by Spring? Now there are two possibilities for Spring design,

  1. It is a technical limitaion with spring that they can not check annotation in methodB(), though it is public? But if AspectJ can check it, then why not Spring?

  2. Intentionally they have limited this AOP checking for internal method calls. Is this kind of method call (where target method is annotated with different transactionPropagation) is against proper design methodology?

  • 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-09T04:01:32+00:00Added an answer on June 9, 2026 at 4:01 am

    Yes, it’s a technical limitation. When you don’t use AspectJ, the transactional aspect is implemented by returning a proxy around the actual bean class instance and returning/injecting this proxy into other beans. So, when you call testService.methodA(), the following (basically) happens:

    caller ---> transactionalProxy.methodA() ---> testServiceImpl.methodA()
    

    The proxy applies the transactional aspect around the call to testServiceImpl.methodA(): it starts the transaction before, and commits/rollbacks it after.

    If you call this.methodB() from methodA(), the following happens:

    caller ---> transactionalProxy.methodA() ---> testServiceImpl.methodA() ---> testServiceImpl.methodB()
    

    And since you bypass the proxy, no transactional aspect can be applied.

    AspectJ is different because it transforms the byte-code of TestServiceImpl in order to apply aspects around various method invocations.

    I wouldn’t say that applying aspects around internal method calls is not proper design. You just need to be aware that it works only with byte-code instrumentation.

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

Sidebar

Related Questions

I have gone through many posts on SO regarding this issue: Tried everything in
First of all, I have gone through all the questions here regarding the inclusion
I have gone through N number of solutions for creating a dynamic dropdown in
i have gone through a number of tutorials to get an idea as to
Have gone through hibernate api specification on FlushMode but didn't get the exact difference.
I have gone through Google and Stack Overflow search, but nowhere I was able
I have gone through this to change the color of my title bar. I'm
I have gone through this page... http://www.php.net/manual/en/function.hash.php MD5 is 32 characters long while sha1
I have gone through a couple of similar questions but could reach a definite
I have gone through the fadein/fadeout tutorial that is on this page: For 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.