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.

HI! I have been having trouble successfully let the hibernate-reactive vertx driver connect to embedded postgres from zonky. I have 2 databases on with hibernate ORM jdbc and then a reactive one.
I do strip the JDBC string from URL before passing it to Mutiny.SessionFactory. Here are my logs

reactiveUrl: postgresql://127.0.0.1:5432/app
2025-08-29 09:14:06 [main] WARN  org.hibernate.orm.deprecation - HHH90000021: Encountered deprecated setting [javax.persistence.provider], use [jakarta.persistence.provider] instead
2025-08-29 09:14:06 [main] INFO  o.h.jpa.internal.util.LogHelper - HHH000204: Processing PersistenceUnitInfo [name: read-reactive]
2025-08-29 09:14:06 [main] INFO  o.h.c.i.RegionFactoryInitiator - HHH000026: Second-level cache disabled
2025-08-29 09:14:06 [main] INFO  o.h.r.pool.impl.DefaultSqlClientPool - HR000011: SQL Client URL [postgresql://127.0.0.1:5432/app]
2025-08-29 09:14:06 [main] INFO  o.h.r.v.impl.DefaultVertxInstance - HR000002: Vert.x not detected, creating a new instance
2025-08-29 09:14:06 [main] INFO  o.h.r.p.i.DefaultSqlClientPoolConfiguration - HR000025: Connection pool size: 5
2025-08-29 09:14:06 [vert.x-eventloop-thread-16] INFO  o.h.r.v.impl.DefaultVertxInstance - HR000003: Vert.x instance stopped
...
...
Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: /127.0.0.1:5432

I also have this annotation to make sure all DB will be replaces
```

@AutoConfigureEmbeddedDatabase(provider = AutoConfigureEmbeddedDatabase.DatabaseProvider.ZONKY, replace = Replace.ANY)