문제

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