I have an interface as shown below
public interface FooDAO {
public void callA(String x);
}
and the implementation, as shown below, deliberately makes readonly true and is not supported
public class FooDAOImpl implements FooDAO {
@Transactional(readOnly = true, propagation = Propagation.NOT_SUPPORTED)
public void callA(String x) {
}
}
In my spring context, I declared a Datasource transaction manager and annotation-driven tx :. I wrote a Junit4 test that looks like
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(...)
@TransactionConfiguration(transactionManager="txManager", defaultRollback=true)
public class MyTest {
@Resource
FooDAO fooDAO;
@Test
public void testRegisterWorker() {
fooDAO.callA("")
}
}
I would expect the record to not be inserted into the database at all. However, I see that the row is being entered into the database. I am using an Oracle database, so I believe that autocommit is set to true by default (I think). But should spring transaction tags not override them?
Can someone tell me what is going wrong here?