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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:35:15+00:00 2026-06-06T22:35:15+00:00

I am in reference to Spring Roo In Action (book from Manning). Somewhere in

  • 0

I am in reference to Spring Roo In Action (book from Manning). Somewhere in the book it says “Roo marks the test class as @Transactional so that the unit tests automatically roll back any change.

Here is the illustrating method:

@Test
@Transactional
  public void addAndFetchCourseViaRepo() {
    Course c = new Course();
    c.setCourseType(CourseTypeEnum.CONTINUING_EDUCATION);
    c.setName("Stand-up Comedy");
    c.setDescription(
      "You'll laugh, you'll cry, it will become a part of you.");
    c.setMaxiumumCapacity(10);

    c.persist();
    c.flush();
    c.clear();  
    Assert.assertNotNull(c.getId());

    Course c2 = Course.findCourse(c.getId());
    Assert.assertNotNull(c2);
    Assert.assertEquals(c.getName(), c2.getName());
    Assert.assertEquals(c2.getDescription(), c.getDescription());
    Assert.assertEquals(
      c.getMaxiumumCapacity(), c2.getMaxiumumCapacity());
    Assert.assertEquals(c.getCourseType(), c2.getCourseType());
  }

However, I don’t understand why changes in this method would be automatically rolled back if no RuntimeException occurs…

  • 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-06T22:35:16+00:00Added an answer on June 6, 2026 at 10:35 pm

    Quote from documentation:

    By default, the framework will create and roll back a transaction for each test. You simply write code that can assume the existence of a transaction. […] In addition, if test methods delete the contents of selected tables while running within a transaction, the transaction will roll back by default, and the database will return to its state prior to execution of the test. Transactional support is provided to your test class via a PlatformTransactionManager bean defined in the test’s application context.

    So, in other words, SpringJUnit4ClassRunner who runs your tests always do transaction rollback after test execution.

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

Sidebar

Related Questions

It is given in the STL reference that string class is in string header,then
I am learning spring by reference documentation of 3.0 and i wanted to test
Here are the questions resulted from reading the Spring Reference, please help. (1) Do
I have this code (like in Spring's reference): <bean id=multipartResolver class=org.springframework.web.multipart.commons.CommonsMultipartResolver> <!-- one of
What does spring mean in reference to Spring Framework? I don't think that this
So I went through the steps to build a basic roo application here: http://static.springsource.org/spring-roo/reference/html/beginning.html
I've got an Image entity (Spring Roo / JPA) that references images stored on
I had made Web Application on Spring and Hibernate by taking reference from Vaannila
Following the spring-security documentation: http://static.springsource.org/spring-security/site/docs/3.0.x/reference/ldap.html I am trying to set up ldap authentication (very
I want to use Spring 3 for validation. In the reference documentation, section 6.2

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.