HHH-15585 Add support for DB2 aliases for schema validation

This commit is contained in:
Andrea Boriero 2022-10-07 09:55:35 +02:00 committed by Andrea Boriero
parent b1f92863cb
commit fc0b19aceb

View File

@ -25,6 +25,8 @@
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.relational.QualifiedTableName;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.engine.config.spi.StandardConverters;
import org.hibernate.engine.jdbc.env.spi.IdentifierHelper;
@ -95,17 +97,21 @@ public AbstractInformationExtractorImpl(ExtractionContext extractionContext) {
)
);
}
extractionContext.getJdbcEnvironment().getDialect().augmentPhysicalTableTypes( physicalTableTypesList );
final Dialect dialect = extractionContext.getJdbcEnvironment().getDialect();
dialect.augmentPhysicalTableTypes( physicalTableTypesList );
this.extraPhysicalTableTypes = physicalTableTypesList.toArray( new String[0] );
final List<String> tableTypesList = new ArrayList<>();
tableTypesList.add( "TABLE" );
tableTypesList.add( "VIEW" );
if ( ConfigurationHelper.getBoolean( AvailableSettings.ENABLE_SYNONYMS, configService.getSettings(), false ) ) {
if ( dialect instanceof DB2Dialect ) {
tableTypesList.add( "ALIAS" );
}
tableTypesList.add( "SYNONYM" );
}
Collections.addAll( tableTypesList, extraPhysicalTableTypes );
extractionContext.getJdbcEnvironment().getDialect().augmentRecognizedTableTypes( tableTypesList );
dialect.augmentRecognizedTableTypes( tableTypesList );
this.tableTypes = tableTypesList.toArray( new String[0] );
}