HHH-9602 - Schema validation fails when materialized view is involved
This commit is contained in:
parent
8235721747
commit
69b8202c75
|
@ -733,27 +733,6 @@ public abstract class Dialect implements ConversionContext {
|
|||
return SequenceStyleGenerator.class;
|
||||
}
|
||||
}
|
||||
// Materialized view support
|
||||
|
||||
/**
|
||||
* Does the dialect support materialized view. It's needed for schema validation purposes.
|
||||
* @return True if dialect supports materialized views. False otherwise.
|
||||
*/
|
||||
public boolean supportsMaterializedView() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the dialect support materialized view. It's needed for schema validation purposes.
|
||||
* @return Query string that will be passed as one of {@code String[] types} parameter
|
||||
* to {@link java.sql.DatabaseMetaData#getTables(String, String, String, String[])}. {@code null}
|
||||
* otherwise if dialect is not supported or doesn't need to use explicit type term.
|
||||
*/
|
||||
public String getMaterializedViewTypeTerm() {
|
||||
return null;
|
||||
}
|
||||
|
||||
// End of Materialized view support
|
||||
|
||||
// IDENTITY support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
@ -2750,4 +2729,8 @@ public abstract class Dialect implements ConversionContext {
|
|||
public boolean isJdbcLogWarningsEnabledByDefault() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void augmentRecognizedTableTypes(List<String> tableTypesList) {
|
||||
// noihing to do
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
package org.hibernate.dialect;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* An SQL Dialect for PostgreSQL 9.3 and later. Adds support for Materialized view.
|
||||
*
|
||||
* @author Dionis Argiri
|
||||
*/
|
||||
public class PostgreSQL93Dialect extends PostgreSQL9Dialect {
|
||||
@Override
|
||||
public boolean supportsMaterializedView() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMaterializedViewTypeTerm() {
|
||||
return "MATERIALIZED VIEW";
|
||||
}
|
||||
@Override
|
||||
public void augmentRecognizedTableTypes(List<String> tableTypesList) {
|
||||
super.augmentRecognizedTableTypes( tableTypesList );
|
||||
tableTypesList.add( "MATERIALIZED VIEW" );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.sql.DatabaseMetaData;
|
|||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
@ -28,7 +29,6 @@ import org.hibernate.engine.jdbc.env.spi.IdentifierHelper;
|
|||
import org.hibernate.internal.CoreLogging;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||
import org.hibernate.internal.util.compare.EqualsHelper;
|
||||
import org.hibernate.internal.util.config.ConfigurationHelper;
|
||||
import org.hibernate.tool.schema.extract.spi.ColumnInformation;
|
||||
|
@ -58,7 +58,7 @@ public class InformationExtractorJdbcDatabaseMetaDataImpl implements Information
|
|||
|
||||
public InformationExtractorJdbcDatabaseMetaDataImpl(ExtractionContext extractionContext) {
|
||||
this.extractionContext = extractionContext;
|
||||
|
||||
|
||||
ConfigurationService configService = extractionContext.getServiceRegistry()
|
||||
.getService( ConfigurationService.class );
|
||||
|
||||
|
@ -75,20 +75,18 @@ public class InformationExtractorJdbcDatabaseMetaDataImpl implements Information
|
|||
);
|
||||
}
|
||||
|
||||
final String[] tempTableTypes;
|
||||
final List<String> tableTypesList = new ArrayList<>();
|
||||
tableTypesList.add( "TABLE" );
|
||||
tableTypesList.add( "VIEW" );
|
||||
if ( ConfigurationHelper.getBoolean( AvailableSettings.ENABLE_SYNONYMS, configService.getSettings(), false ) ) {
|
||||
tempTableTypes = new String[] {"TABLE", "VIEW", "SYNONYM"};
|
||||
tableTypesList.add( "SYNONYM" );
|
||||
}
|
||||
else {
|
||||
tempTableTypes = new String[] {"TABLE", "VIEW"};
|
||||
if ( extraPhysicalTableTypes != null ) {
|
||||
Collections.addAll( tableTypesList, extraPhysicalTableTypes );
|
||||
}
|
||||
extractionContext.getJdbcEnvironment().getDialect().augmentRecognizedTableTypes( tableTypesList );
|
||||
|
||||
if ( this.extraPhysicalTableTypes != null ) {
|
||||
this.tableTypes = ArrayHelper.join( tempTableTypes, this.extraPhysicalTableTypes );
|
||||
}
|
||||
else {
|
||||
this.tableTypes = tempTableTypes;
|
||||
}
|
||||
this.tableTypes = tableTypesList.toArray( new String[ tableTypesList.size() ] );
|
||||
}
|
||||
|
||||
protected IdentifierHelper identifierHelper() {
|
||||
|
|
Loading…
Reference in New Issue