Fix Hibernate 7.4 dropping primary key on order_type_class_map join table#6139
Open
dkayiwa wants to merge 1 commit into
Open
Fix Hibernate 7.4 dropping primary key on order_type_class_map join table#6139dkayiwa wants to merge 1 commit into
dkayiwa wants to merge 1 commit into
Conversation
d3b7002 to
8486025
Compare
…able Hibernate 7.4 emits a unique constraint instead of a composite primary key when a @jointable's explicit @UniqueConstraint covers exactly the columns that would form the join table's primary key. OrderType was the only @manytomany Set declaring such a redundant @UniqueConstraint, so its order_type_class_map join table lost its primary key under hbm2ddl. This broke the integration tests, whose dbUnit REFRESH operation needs a primary key to update existing rows (NoPrimaryKeyException). Remove the redundant @UniqueConstraint: the two FK columns are the natural key of a Set join table, so hbm2ddl generates the composite primary key again, matching the production schema that already defines it via Liquibase. The annotation only affected hbm2ddl-generated DDL, so production is unaffected. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
8486025 to
340ebc8
Compare
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6139 +/- ##
============================================
+ Coverage 59.04% 59.06% +0.01%
- Complexity 9239 9242 +3
============================================
Files 693 693
Lines 37257 37257
Branches 5485 5485
============================================
+ Hits 21998 22004 +6
+ Misses 13287 13285 -2
+ Partials 1972 1968 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Prepares the codebase for the Hibernate 7.4 upgrade (#6130). On Hibernate 7.4, the integration-test job fails with
org.dbunit.dataset.NoPrimaryKeyException: ORDER_TYPE_CLASS_MAP(97 errors across many ITs).Root cause
The test harness builds the in-memory H2 schema from Hibernate's hbm2ddl, and dbUnit's
REFRESHoperation needs a primary key to update existing rows. In Hibernate 7.4, when a@JoinTable's explicit@UniqueConstraintcovers exactly the columns that would form the join table's composite primary key, Hibernate emits the unique constraint instead of the primary key.OrderType.conceptClasseswas the only@ManyToManySet declaring such a redundant@UniqueConstraint, so itsorder_type_class_mapjoin table lost its primary key (user_roleandlocation_tag_map, which have no explicit unique constraint, kept theirs).Fix
Remove the redundant
@UniqueConstraint. The two FK columns are the natural key of aSetjoin table, so hbm2ddl generates the composite primary key automatically again — matching the production schema, which already defines that PK via Liquibase (liquibase-update-to-latest-2.0.x.xml). The annotation'suniqueConstraintsonly ever affected hbm2ddl-generated DDL, so production is unaffected and the change is harmless on the current Hibernate 7.3.6 too.Testing
Locally bumped Hibernate to 7.4.0 and reran the affected tests:
ConceptIT,ModuleUtilIT,SchedulerServiceIT,S3StorageServiceIT,Database1_9_7UpgradeIT→ 97 errors.ValidateHibernateMappingsDatabaseIT(mapping-vs-schema validation) and the 238OrderServiceTest/OrderTypeTestcases.Once this merges, Dependabot PR #6130 will rebase and pass.
🤖 Generated with Claude Code