-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
HHH-14270 GroupedSchemaValidatorImpl / NameSpaceTablesInformation does not find different-case table information in case insensitive environment #10429
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?
Conversation
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.
Hello @mehmetali2003, thank you for the contribution, I left a comment on a possibly better approach. I would also ask you to include a test within your PR that asserts that the behavior explained in the linked Jira issue doesn't occur and protects against regressions in the future.
Hello @mbellade, thank you for your feedback. I looked through the issue. Can you tell some details about a better approach, please? |
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.
@mehmetali2003 sorry I though I left an additional comment in the code, you can find it now. Also please try creating a test as well, thanks.
...ate-core/src/main/java/org/hibernate/tool/schema/extract/spi/NameSpaceTablesInformation.java
Outdated
Show resolved
Hide resolved
@@ -22,7 +22,7 @@ public NameSpaceTablesInformation(IdentifierHelper identifierHelper) { | |||
} | |||
|
|||
public void addTableInformation(TableInformation tableInformation) { | |||
tables.put( tableInformation.getName().getTableName().getText(), tableInformation ); | |||
tables.put(identifierHelper.toMetaDataObjectName( tableInformation.getName().getTableName()), tableInformation); |
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.
Much better, let's apply Hibernate's code style:
tables.put(identifierHelper.toMetaDataObjectName( tableInformation.getName().getTableName()), tableInformation); | |
tables.put( identifierHelper.toMetaDataObjectName( tableInformation.getName().getTableName() ), tableInformation ); |
final Table table = new Table( "orm", tableName.getTableName().getText() ); | ||
nameSpaceTablesInformation.getTableInformation( table ); | ||
boolean tableMatched = tableInformation.getName().getTableName().getText().equals( tableName.getTableName().getText() ); | ||
Assert.assertTrue("Table matched: ", tableMatched); |
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.
This test is very "synthetic", and instantiating Hibernate internal classes is not portable as they might change in future versions. A good test reproduces a "real-world" scenario, the one where you experienced this particular bug, ensuring that no regressions are introduced. Could you try to isolate that in a simple reproducer? Thanks.
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.
Hello @mbellade,
I tried to create instances of Hibernate internal class which were not portable. But, tableInformation is null for table PERSON_TABLE. I have supposed that is existing in database. Could I send codes for your review to understand the problem?
Thanks.

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.
Hey @mehmetali2003, I'm not really sure what you mean by your message and what I should look at in this code screenshot. Feel free to send any code for our review and we'll try to help.
In a case-insensitive database, the names in the entity mapping and the database schema should only be compared after converting them to the same case, either upper- or lowercase. For that,
getTableInformation
needs to be rewritten to find the name with either upper or lowercase in the map of tables.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.
https://hibernate.atlassian.net/browse/HHH-14270