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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:21:06+00:00 2026-06-11T06:21:06+00:00

I am doing some tests to understand the behaviour of @Transactional in Spring 3.

  • 0

I am doing some tests to understand the behaviour of @Transactional in Spring 3. Though, it is not working as I would expect. If have one method with Propagation.REQUIRED calling another with Propagation.REQUIRES_NEW, will the second method be able to retrieve from the DB the data inserted by the first method?

EDITED:
I AM seeing uncommitted changed in a @Transaction, here is my (nasty looking) code.

@Service
public class FeedManager {
   @Autowired
   JdbcTemplate jdbcTemplate;

   @Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED)
   public boolean createFeed(Feed feed, boolean anonymizeIt) {
      String query = "INSERT INTO feed (name, url, is_active) values (?, ?, ?)";
      int rowsAffected = jdbcTemplate.update(query, feed.getName(), feed.getUrl(), feed.isActive()); 
      boolean success = (rowsAffected == 1); 
      if (anonymizeIt) {
         success = success && this.anonymizeFeedName(feed);
      }
      return success;
   }

   @Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRES_NEW)
   public boolean anonymizeFeedName(Feed feed) {
      String query = "UPDATE feed set name = ? where name = ?";
      int rowsAffected = jdbcTemplate.update(query, feed.getName() + (new Date()).toString(), feed.getName());
      boolean success = (rowsAffected == 1);
      return success;
   }
}

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:mrpomario/springcore/jdbc/jdbc-testenv-config.xml")
public class TransactionalTest {
   @Autowired
   FeedManager feedManager;

   Feed feed;

   @Before
   public void setup() {
      feed = new Feed("RSS", "http://www.feedlink.com", true);
   }

   @Test
   public void test_Create()  {
      assertTrue(feedManager.createFeed(feed, false));
   }

   @Test
   public void test_Anonymize() {
      assertTrue(feedManager.anonymizeFeedName(feed));
   }

   @Test
   public void test_Create_And_Anonymize() {
      Feed feedo = new Feed("AnotherRSS", "http://www.anotherfeedlink.com", true);
      assertTrue(feedManager.createFeed(feedo, true));
   }
}
  • 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-11T06:21:08+00:00Added an answer on June 11, 2026 at 6:21 am

    It should not be able to see any changes made by the first method (as long as your isolation level is READ COMMITTED or above).

    If you get different results, make sure that @Transactional actually takes effect. In particular, make sure that you don’t call another @Transactional method of the same class – due to limitations of Spring proxy-based AOP model transactional aspect is applied only to calls that come from the outside of the class.

    See also:

    • 7.6.1 Understanding AOP proxies
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing some tests, but I see no difference when I use or not
I was previously working with Ember.StateManager and now I'm doing some tests before I
I'm developing an application with Spring 3. I'm doing some tests with spring batch.
I execute some tests within my application, but before doing that I have to
currently I am working on a spring based application. I do have some unit
I'm doing some tests with new features of CSS3, but this combination only works
I am doing some tests, just to learn (normally i do this in ajax
I'm basically just doing some tests to figure out a good way to write
I'm new in Silverlight and i am doing some tests. With my current test
I'm doing some unit tests for an EntityEventListener from NHibernate, and I'm got stuck

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.