HHH-15022 Revert to the legacy behavior of not qualifying temporary ID tables with the default catalog/schema

This commit is contained in:
Yoann Rodière 2022-01-18 12:17:23 +01:00 committed by Christian Beikov
parent 9dea484927
commit 34278588ec
3 changed files with 28 additions and 7 deletions

View File

@ -65,6 +65,15 @@ public interface SqlStringGenerationContext {
*/
String format(QualifiedTableName qualifiedName);
/**
* Render a formatted a table name, ignoring the default catalog/schema.
*
* @param qualifiedName The table name
*
* @return The formatted name
*/
String formatWithoutDefaults(QualifiedTableName qualifiedName);
/**
* Render a formatted sequence name
*

View File

@ -156,6 +156,11 @@ public class SqlStringGenerationContextImpl
return qualifiedObjectNameFormatter.format( withDefaults( qualifiedName ), dialect );
}
@Override
public String formatWithoutDefaults(QualifiedTableName qualifiedName) {
return qualifiedObjectNameFormatter.format( qualifiedName, dialect );
}
@Override
public String format(QualifiedSequenceName qualifiedName) {
return qualifiedObjectNameFormatter.format( withDefaults( qualifiedName ), dialect );

View File

@ -68,11 +68,8 @@ public abstract class AbstractMultiTableBulkIdStrategyImpl<TT extends IdTableInf
continue;
}
final String idTableName = sqlStringGenerationContext.format(
determineIdTableName( jdbcEnvironment, entityBinding )
);
final Table idTable = new Table();
idTable.setName( idTableName );
final QualifiedTableName idTableName = determineIdTableName( jdbcEnvironment, entityBinding );
final Table idTable = new Table( idTableName.getCatalogName(), idTableName.getSchemaName(), idTableName.getTableName(), false );
idTable.setComment( "Used to hold id values for the " + entityBinding.getEntityName() + " entity" );
Iterator itr = entityBinding.getTable().getPrimaryKey().getColumnIterator();
@ -138,7 +135,7 @@ public abstract class AbstractMultiTableBulkIdStrategyImpl<TT extends IdTableInf
StringBuilder buffer = new StringBuilder( getIdTableSupport().getCreateIdTableCommand() )
.append( ' ' )
.append( sqlStringGenerationContext.format( idTable.getQualifiedTableName() ) )
.append( formatIdTableName( idTable.getQualifiedTableName(), sqlStringGenerationContext ) )
.append( " (" );
Iterator<Column> itr = idTable.getColumnIterator();
@ -175,7 +172,17 @@ public abstract class AbstractMultiTableBulkIdStrategyImpl<TT extends IdTableInf
protected String buildIdTableDropStatement(Table idTable, SqlStringGenerationContext sqlStringGenerationContext) {
return getIdTableSupport().getDropIdTableCommand() + " "
+ sqlStringGenerationContext.format( idTable.getQualifiedTableName() );
+ formatIdTableName( idTable.getQualifiedTableName(), sqlStringGenerationContext );
}
protected String formatIdTableName(QualifiedTableName qualifiedTableName,
SqlStringGenerationContext sqlStringGenerationContext) {
// Historically, we've always ignored the default catalog/schema here,
// so for the sake of backwards compatibility, we will continue that way.
// Also, we must not use the default catalog/schema for temporary tables,
// because some vendors don't allow creating temporary tables
// in just any catalog/schema (for postgres, it must be a "temporary schema").
return sqlStringGenerationContext.formatWithoutDefaults( qualifiedTableName );
}
protected void finishPreparation(