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

ⅰ亾dé卋堺 提交于 2019-12-25 12:30:11

问题


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:


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.



来源:https://stackoverflow.com/questions/31031159/why-is-transactionalpropagation-not-supported-not-working-as-expected

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!