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

  • Home
  • SEARCH
  • 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 3611204
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:50:52+00:00 2026-05-18T21:50:52+00:00

If I have a @Transactional annotation on a private method in a Spring bean,

  • 0

If I have a @Transactional annotation on a private method in a Spring bean, does the annotation have any effect?

If the @Transactional annotation is on a public method, it works and opens a transaction.

public class Bean {
  public void doStuff() {
     doPrivateStuff();
  }
  @Transactional
  private void doPrivateStuff() {

  }
}

...

Bean bean = (Bean)appContext.getBean("bean");
bean.doStuff();
  • 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-18T21:50:53+00:00Added an answer on May 18, 2026 at 9:50 pm

    The Question is not private or public, the question is: How is it invoked and which AOP implementation you use!

    If you use (default) Spring Proxy AOP, then all AOP functionality provided by Spring (like @Transactional) will only be taken into account if the call goes through the proxy. — This is normally the case if the annotated method is invoked from another bean.

    This has two implications:

    • Because private methods must not be invoked from another bean (the exception is reflection), their @Transactional Annotation is not taken into account.
    • If the method is public, but it is invoked from the same bean, it will not be taken into account either (this statement is only correct if (default) Spring Proxy AOP is used).

    @See Spring Reference: Chapter 9.6 9.6 Proxying mechanisms

    IMHO you should use the aspectJ mode, instead of the Spring Proxies, that will overcome the problem. And the AspectJ Transactional Aspects are woven even into private methods (checked for Spring 3.0).

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

Sidebar

Related Questions

I have a Spring bean, let's say: @TransactionAttribute(TransactionAttributeType.REQUIRED) public class AImpl implements A {
We have: @Transactional(propagation = Propagation.REQUIRED) public class MyClass implementes MyInterface { ... MyInterface has
i have a service method addAgent defined as @Override @Transactional(readOnly=false) public void addAgent(Agent agent,
We have a Hibernate/Spring application that have the following Spring beans: <bean id=transactionManager class=org.springframework.orm.hibernate3.HibernateTransactionManager
I have a WCF service that posts messages to a private, non-transactional MSMQ queue.
I have a spring bean that I have configured in applicationContext like below: <bean
I've a problem with the annotation @Transactional . I've a method doing some stuff,
I am using annotation based declarative approach for spring aop. sample code ClassA{ @Transactional(readOnly
I have two Service classes which implement the same interface ServiceClass1 @Service public class
How far does the spring framework go with transaction handling? My reading of 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.