Pergunta

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!

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top