Why is @Transactional(Propagation.NOT_SUPPORTED) not working as expected?

2.7k views Asked by At

Given the following:

  1. An integration test is started using @Transactional(Propagation.REQUIRED) at class level.
  2. Some reference data is inserted with Propagation.NOT_SUPPORTED specified at method level.
  3. A service method marked as @Transactional(Propagation.REQUIRED) attempts to look up some reference data inserted in step 2.

The service method can't see the reference data!

My understanding was that if data is inserted outside the transaction, it would be instantly accessible to another method whether it is inside or outside the transaction. Could anyone explain?

1

There are 1 answers

0
Steve Chambers On BEST ANSWER

Not a complete answer but I think these woes are partially caused by running integration tests inside an overarching transaction - this article explains why this is a bad idea. Am going to attempt to rewrite all the data population to be non-transactional and cleared up manually at the end of each test.