-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
HHH-12678 Fix checkColumnDuplication failure for columns with same name from distinct tables #11512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
HHH-12678 Fix checkColumnDuplication failure for columns with same name from distinct tables #11512
Conversation
…me from distinct tables
|
Thanks for your pull request! This pull request appears to follow the contribution rules. › This message was automatically generated. |
.idea/codeStyles/codeStyleConfig.xml
Outdated
| <component name="ProjectCodeStyleConfiguration"> | ||
| <state> | ||
| <option name="USE_PER_PROJECT_SETTINGS" value="true" /> | ||
| <option name="PREFERRED_PROJECT_CODE_STYLE" value="hibernate-style" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please back out this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I have removed the IDE configuration file from the PR.
gavinking
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I left a minor suggestion.
| String tableName = ( getTable() != null ) ? getTable().getName() : ""; | ||
| String uniqueKey = tableName.isEmpty() ? col.getName() : tableName + "." + col.getName(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| String tableName = ( getTable() != null ) ? getTable().getName() : ""; | |
| String uniqueKey = tableName.isEmpty() ? col.getName() : tableName + "." + col.getName(); | |
| final var primaryTable = getTable(); | |
| final String tableName = primaryTable != null ? primaryTable.getName() : ""; | |
| final String uniqueKey = tableName.isEmpty() ? col.getName() : tableName + "." + col.getName(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied. Thanks for the suggestion!
bbbed6d to
8971c53
Compare
|
Hi @gavinking and Team, The OpenJDK 25 jobs (hsqldb, h2, mysql, postgresql, etc.) are currently failing with "There were failing tests" in :hibernate-core:test I’ve seen similar test failures on JDK 25 in other recent PRs as well. Since my change is quite small, I’m wondering
I’m happy to investigate locally if needed, but wanted to check first since my change is minimal. Thanks! |
|
@MohammedAymanKhan The error is: So it's definitely the result of this change. |
| catalog = primaryTable.getCatalog() != null ? Identifier.toIdentifier( primaryTable.getCatalog() ) : null; | ||
| schema = primaryTable.getSchema() != null ? Identifier.toIdentifier( primaryTable.getSchema() ) : null; | ||
| table = primaryTable.getName() != null ? Identifier.toIdentifier( primaryTable.getName() ) : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| catalog = primaryTable.getCatalog() != null ? Identifier.toIdentifier( primaryTable.getCatalog() ) : null; | |
| schema = primaryTable.getSchema() != null ? Identifier.toIdentifier( primaryTable.getSchema() ) : null; | |
| table = primaryTable.getName() != null ? Identifier.toIdentifier( primaryTable.getName() ) : null; | |
| catalog = primaryTable.getCatalogIdentifier(); | |
| schema = primaryTable.getSchemaIdentifier(); | |
| table = primaryTable.getNameIdentifier(); |
| table = primaryTable.getName() != null ? Identifier.toIdentifier( primaryTable.getName() ) : null; | ||
| } | ||
|
|
||
| Identifier columnName = Identifier.toIdentifier( col.getName() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Identifier columnName = Identifier.toIdentifier( col.getName() ); | |
| Identifier columnName = col.getNameIdentifier( getBuildingContext() ); |
| final QualifiedColumnName qualified = new QualifiedColumnName( catalog, schema, table, columnName ); | ||
|
|
||
| if ( !distinctColumns.add( qualified ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| final QualifiedColumnName qualified = new QualifiedColumnName( catalog, schema, table, columnName ); | |
| if ( !distinctColumns.add( qualified ) ) { | |
| if ( !distinctColumns.add( new QualifiedColumnName( catalog, schema, table, columnName ) ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@beikov Thank you for the review! I have updated the code to use the direct identifier getters as suggested.
Issue
Hibernate incorrectly reports duplicate column mappings when the same column name (e.g.
address) is used in different secondary tables of the same entity. This occurs becausecheckColumnDuplication()only considers the column name and ignores the table name.Jira: https://hibernate.atlassian.net/browse/HHH-12678
Changes
tableName.columnName) when building the uniqueness set.This ensures that columns with the same name in distinct tables are no longer treated as duplicates.
Test
TablePerClassColumnDuplicationCheckTestthat reproduces the original failure and now passes with the fix.Credit for the original test case goes to Christian Beikov (from HHH-12678 Add test for table per class column override #11502).
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.