diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java index d157f8c59988..3d4a4b243141 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java @@ -2953,6 +2953,10 @@ public boolean isJdbcLogWarningsEnabledByDefault() { return true; } + public void augmentPhysicalTableTypes(List tableTypesList) { + // nothing to do + } + public void augmentRecognizedTableTypes(List tableTypesList) { // noihing to do } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java index ad78c0dc5c34..388834b420c9 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java @@ -8,6 +8,7 @@ import java.sql.SQLException; import java.sql.Types; +import java.util.List; import org.hibernate.JDBCException; import org.hibernate.PessimisticLockException; @@ -75,6 +76,7 @@ public boolean bindLimitParametersInReverseOrder() { private final boolean supportsTuplesInSubqueries; private final boolean requiresParensForTupleDistinctCounts; + private final boolean isVersion2; private final String querySequenceString; private final SequenceInformationExtractor sequenceInformationExtractor; @@ -87,6 +89,7 @@ public H2Dialect() { int buildId = Integer.MIN_VALUE; boolean supportsTuplesInSubqueries = false; boolean requiresParensForTupleDistinctCounts = false; + boolean isVersion2 = false; try { // HHH-2300 @@ -101,6 +104,7 @@ public H2Dialect() { supportsTuplesInSubqueries = majorVersion > 1 || minorVersion > 4 || buildId >= 198; // As of 1.4.200, this is not necessary anymore requiresParensForTupleDistinctCounts = !( majorVersion > 1 || minorVersion > 4 || buildId >= 200 ); + isVersion2 = majorVersion > 1; } catch ( Exception e ) { // probably H2 not in the classpath, though in certain app server environments it might just mean we are @@ -120,6 +124,7 @@ public H2Dialect() { } this.supportsTuplesInSubqueries = supportsTuplesInSubqueries; this.requiresParensForTupleDistinctCounts = requiresParensForTupleDistinctCounts; + this.isVersion2 = isVersion2; registerColumnType( Types.BOOLEAN, "boolean" ); registerColumnType( Types.BIGINT, "bigint" ); @@ -240,6 +245,12 @@ public H2Dialect() { getDefaultProperties().setProperty( AvailableSettings.NON_CONTEXTUAL_LOB_CREATION, "true" ); } + public boolean hasOddDstBehavior() { + // H2 1.4.200 has a bug: https://github.com/h2database/h2database/issues/3184 + // requiresParensForTupleDistinctCounts will be false for 1.4.200+ + return !requiresParensForTupleDistinctCounts; + } + @Override public String getAddColumnString() { return "add column"; @@ -432,6 +443,13 @@ public boolean supportsUnionAll() { // Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + @Override + public void augmentPhysicalTableTypes(List tableTypesList) { + if ( isVersion2 ) { + tableTypesList.add( "BASE TABLE" ); + } + } + @Override public boolean supportsLobValueChangePropogation() { return false; diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/extract/internal/AbstractInformationExtractorImpl.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/extract/internal/AbstractInformationExtractorImpl.java index bd6dc598adf5..3a6961dc9a04 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/extract/internal/AbstractInformationExtractorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/extract/internal/AbstractInformationExtractorImpl.java @@ -84,13 +84,19 @@ public AbstractInformationExtractorImpl(ExtractionContext extractionContext) { "" ) ); + final List physicalTableTypesList = new ArrayList<>(); if ( ! StringHelper.isBlank( extraPhysicalTableTypesConfig ) ) { - this.extraPhysicalTableTypes = StringHelper.splitTrimmingTokens( - ",;", - extraPhysicalTableTypesConfig, - false + Collections.addAll( + physicalTableTypesList, + StringHelper.splitTrimmingTokens( + ",;", + extraPhysicalTableTypesConfig, + false + ) ); } + extractionContext.getJdbcEnvironment().getDialect().augmentPhysicalTableTypes( physicalTableTypesList ); + this.extraPhysicalTableTypes = physicalTableTypesList.toArray( new String[0] ); final List tableTypesList = new ArrayList<>(); tableTypesList.add( "TABLE" ); @@ -98,9 +104,7 @@ public AbstractInformationExtractorImpl(ExtractionContext extractionContext) { if ( ConfigurationHelper.getBoolean( AvailableSettings.ENABLE_SYNONYMS, configService.getSettings(), false ) ) { tableTypesList.add( "SYNONYM" ); } - if ( extraPhysicalTableTypes != null ) { - Collections.addAll( tableTypesList, extraPhysicalTableTypes ); - } + Collections.addAll( tableTypesList, extraPhysicalTableTypes ); extractionContext.getJdbcEnvironment().getDialect().augmentRecognizedTableTypes( tableTypesList ); this.tableTypes = tableTypesList.toArray( new String[ tableTypesList.size() ] );