Suspect a bug in Sequence Identity Mismatch handling

So I have been investigating a nasty issue with sequence id collisions after a major Spring Boot upgrade of an application. Ultimately, I traced it back to the database increment size not being the same as the JPA entity’s declared increment size for its sequence.

I tried configuring the application property to treat mismatches as an EXCEPTION but it did not detect the issue. So I started tracing through the code and believe I found a bug.

Basically, the sequence increment validation code tries to look up the database sequence from the database metadata by filtering the list of sequences using a predicate to test for name. However, the name supplied to test for is the declared sequence name in the annotations and not the database identifier name that is what is returned by Postgres.

E.g. nameLookingFor = “ObjectId_seq” but database name = “object_id_seq”

Looking at other places in the code I see the declared sequence name get turned into the database identifier name as follows:

jdbcEnv.getIdentifierHelper().toIdentifier( sequenceName )

So I believe this needs to be done in the SequenceStyleGenerator class in its getSequenceIncrementValue method.

Hi, thank you for reporting this. Could you please open a new Jira in our issue tracker, with a simple test case that reproduces the issue attached it would be great.