Spring Boot Envers Embedded DB

We successfully use Envers to audit changes to our data but have encountered an odd issue with our integration testing.

We are experimenting with using the Zonky embedded DB (Postgress) to allow test isolation. Our tests fail with:
org.springframework.orm.jpa.JpaSystemException: Negative revision numbers are not allowed

Everything works fine with a normal Postgres instance. I’m not sure if this is an issue with sequencers or a problem with Zonky and its approach to refreshing the DB state between tests.

If you can create a reproducer based on our test case template we can look into this, but it sounds to me like some issue with resetting sequences or the increment configuration of sequences.

Hi, thanks for the reply.

After reading this blog, https://ntsim.uk/posts/how-to-use-hibernate-identifier-sequence-generators-properly, I understood how Hibernate was managing its sequences. Resetting the DB state between each test was throwing out the sequencer value held by the DB and the internal value held by Hibernate.

The answer seems to either dirty the Spring context between each test or physically reset the DB sequencer to the value expected by Hibernate.