mercredi 20 février 2019

Can I see uncommited changes in the H2 console?

I am using an H2 database for Testing. Of course tests get rolled back every time they changes some of the data. This is why I cannot see the changes inside of my H2 console. Can I somehow change this, so that I can see temporary changes in the H2 console?

Example:

  • I have the table USERS and my data.sql script creates 5 entires in it.
  • I let run a Test with @Transactional annotation, that deletes one of the USERS.
  • I have a breakpoint inside the test, after the deletion.
  • I reach it, log into the H2 console and still see 5 entries.

I'd like to see only 4. After the test is finished, it should be 5 again so that it does not affect other tests... I could see 2 possible ways:

  • Remove the @Transactional annotation and install another mechanism that re-arranges the data. Do some real commits inside of the tests.
  • Somehow see these uncommited changes inside of the H2 console. I dont know if there is any framework or something that could help me here..?

Aucun commentaire:

Enregistrer un commentaire