I run my test case with @Transactional annotation. In one of my test methods I do something in service layer and this results in storing a new row in the database. But when I want to use that row in same method (just to test the integrity of the data put in the database) it cannot be found. I suppose the database never gets updated before the method ends? How to make this work?

Thanks!

有帮助吗?

解决方案

Add isolation level to the @Transactional attribute as

@Transactional(isolation=Isolation.READ_UNCOMMITTED)

That will allow the uncommitted reads from the database that the test is currently not seeing.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top