I’m running as unit test and it automatically goes back even if I don’t use the@rollback in spring 3.1.
My test looks like
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:application-context.xml" })
public class PersonServiceTest {
@Test
@Transactional
public void savePerson() {
Person person = createPerson();
personService.savePerson(person);
}
}
Is Rollback behavior is set by default?
By default
SpringJUnit4ClassRunnerwill rollback transactions automatically.To negate the effect, use
@TransactionConfiguration(defaultRollback=false)on your test class or@Rollback(false)on each test.