Domanda

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!

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top