From 946b7bedf3d9d6ebb18bb22cfbd2ec5da654c04f Mon Sep 17 00:00:00 2001 From: Benedikt Waldvogel Date: Mon, 19 Aug 2024 11:24:50 +0200 Subject: [PATCH] Mention the "column_ordering_strategy=legacy" workaround in README.md --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index 88764bb..59417eb 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,30 @@ As a developer, you typically follow these steps when you want to change or exte In such cases, you need to adjust the changeset manually. 5. **Re-run the Test**: Re-run the `LiquibaseTest` and check that the test now succeeds. +## Known-Issue: Column Order of Composite Primary Keys + +Unfortunately, Hibernate's schema generation applies an alphabetical ordering to all columns. +This can result in incorrect column order when using composite primary keys. +Our bug report [HHH-17065](https://hibernate.atlassian.net/browse/HHH-17065) was closed as "Won’t Fix" by the Hibernate team. + +Fortunately, there’s a workaround: you can switch the column order strategy back to the previous behavior: + +#### `src/main/resources/liquibase-test-hibernate.properties` +```properties +# This is a workaround for a composite primary key column order regression in Hibernate 6.2 +# See https://hibernate.atlassian.net/browse/HHH-17065 +spring.jpa.properties.hibernate.column_ordering_strategy=legacy +``` + +This property only needs to be set for the configuration class used in the Hibernate-populated Spring context: + +```java +@EntityScan("de.cronn.example") +@PropertySource("classpath:/liquibase-test-hibernate.properties") +static class HibernatePopulatedConfig extends HibernatePopulatedConfigForPostgres { +} +``` + ## Additional Notes The test performs some automatic post-processing of the diff. For example, it overrides the Hibernate-generated