2

When upgrading to Spring Boot 3 and Hibernate 6, it seems like property hibernate.hbm2ddl.schema_filter_provider doesn't work properly. I have a custom implementation of SchemaFilterProvider that excludes my_table from validation, and I set the hibernate.hbm2ddl.schema_filter_provider property to use it. I get this error: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [my_table]

After debugging it, I found that DefaultSchemaFilter.INSTANCE is in use, and the above property is not being considered:

Validation is done here:

    protected void validateTables(
            Metadata metadata,
            DatabaseInformation databaseInformation,
            ExecutionOptions options,
            ContributableMatcher contributableInclusionFilter,
            Dialect dialect, Namespace namespace) {

        final NameSpaceTablesInformation tables = databaseInformation.getTablesInformation( namespace );
        for ( Table table : namespace.getTables() ) {
            if ( options.getSchemaFilter().includeTable( table )
                    && table.isPhysicalTable()
                    && contributableInclusionFilter.matches( table ) ) {
                validateTable(
                        table,
                        tables.getTableInformation( table ),
                        metadata,
                        options,
                        dialect
                );
            }
        }
    }

and options is built here:

    public static ExecutionOptions buildExecutionOptions(
            final Map<String,Object> configurationValues,
            final ExceptionHandler exceptionHandler) {
        return buildExecutionOptions(
                configurationValues,
                DefaultSchemaFilter.INSTANCE,
                exceptionHandler
        );
    }

Meaning DefaultSchemaFilter.INSTANCE will always be in use.

There's an open bug to Hibernate with no response: https://hibernate.atlassian.net/browse/HBX-2476

How should I exclude my_table from validation?

Ayelet
  • 21
  • 2

0 Answers0