Hibernate 6 migration: Using different ID generation strategy for a specific database type (SQL Server)

We are currently migrating a large framework from Hibernate 5 to the newest Hibernate 6 version. Part of our framework is the support of various relational databases, e.g. PostgreSQL, MS SQL Server and Oracle.

With Hibernate 6, there have been major changes to the automatic generation of IDs. On the code side, the IDs of our entities are generated with GenerationStrategy.AUTO. For Postgres, this previously meant that IDs were generated from a single sequence (hibernate_sequence). In SQL Server, we have generated the IDs via auto-increment on the ID column for backward compatibility reasons (using the configuration property “hibernate.id.new_generator_mappings=LegacyFallbackInterpreter”).

Is there a way in Hibernate 6 to override the ID generation strategy for individual database systems (in this case for MS SQL Server)? We would like to continue using auto-increment on the ID column for SQL Server and a single sequence for Postgres (using the new configuration property “hibernate.id.db_structure_naming_strategy=single”.

Thanks in advance for your help :slight_smile: