Try marking your test class as transactional, which will require you to use springs test classes also.
@RunWith(SpringJUnit4ClassRunner.class),
@ContextConfiguration(locations = { "file:war/WEB-INF/application-context.xml" })
@Transactional
public class ServiceImplTest extends AbstractTestNGSpringContextTests
{
@Autowired
private Service service;
@Test
@Rollback(false)
public void testCreate()
{
.....
//save an entity to table_A
service.save(a);
}
}
You could also try using @TransactionConfiguration
, where txMgr is the name of your transaction manager.:
@RunWith(SpringJUnit4ClassRunner.class),
@ContextConfiguration(locations = { "file:war/WEB-INF/application-context.xml" })
@TransactionConfiguration(transactionManager="txMgr", defaultRollback=false)
public class ServiceImplTest extends AbstractTestNGSpringContextTests
{
....
}
The rollback functionality in test is dependent on how you manage your transactions, without that information it is hard to give you a solid answer.