Skip to content

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Member

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:

Suggested change
tables.put(identifierHelper.toMetaDataObjectName( tableInformation.getName().getTableName()), tableInformation);
tables.put( identifierHelper.toMetaDataObjectName( tableInformation.getName().getTableName() ), tableInformation );

}

public TableInformation getTableInformation(Table table) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.tool.schema.extract.spi;

import org.hibernate.boot.model.relational.QualifiedTableName;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.mapping.Table;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.util.ServiceRegistryUtil;
import org.junit.Assert;
import org.junit.jupiter.api.Test;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
import org.hibernate.engine.jdbc.env.spi.IdentifierHelper;
import org.hibernate.tool.schema.extract.internal.TableInformationImpl;
import org.hibernate.boot.model.relational.Namespace.Name;
import org.hibernate.boot.model.naming.Identifier;
import org.mockito.Mockito;


public class NameSpaceTablesInformationTest {

@Test
@JiraKey(value = "HHH-14270")
public void testNameSpaceTablesInformation() {
StandardServiceRegistry ssr = ServiceRegistryUtil.serviceRegistry();
JdbcEnvironment jdbcEnvironment = ssr.getService( JdbcEnvironment.class );
IdentifierHelper identifierHelper = jdbcEnvironment.getIdentifierHelper();

NameSpaceTablesInformation nameSpaceTablesInformation = new NameSpaceTablesInformation(identifierHelper);
Name schemaName = new Name( new Identifier( "-", false ), new Identifier( "-", false ) );
InformationExtractor informationExtractor = Mockito.mock( InformationExtractor.class );
QualifiedTableName tableName = new QualifiedTableName( schemaName, new Identifier( "-", false ) );

TableInformation tableInformation = new TableInformationImpl( informationExtractor, identifierHelper, tableName, false, null );
nameSpaceTablesInformation.addTableInformation( 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);
Copy link
Member

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.

Copy link
Author

@mehmetali2003 mehmetali2003 Aug 5, 2025

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.

image

Copy link
Member

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @mbellade,

Thanks for your feedback. I have send a new commit. Can you check, please?

}
}