Table default schema

We have upgrade the hibernate dependency in our spring boot application from 5.3.7.Final to 5.6.14.Final, and the tables have their schema property as null. We have set the hibernate.default_schema property in the application.yml. It was working fine with the 5.3.7 version.

How can we resolve this?

What database do you use? Maybe you rather need to set the hibernate.default_catalog setting.

We are using both postgres and mssql. hibernate.default_schema was working for us till now. Has it been changed for some databases?

Yes, there was a JIRA issue about this where we made sure to not mix up schema and catalog names. So if you want to support both databases, you might have to set the schema for PostgreSQL and the catalog for SQL Server.

But it is the PostgreSQL environment where the schema doesn’t seem to be working.

And also, the key for default_schema that we are using is: spring.jpa.properties.hibernate.default_schema. Will the key for default_catalog be similar? And also, will both of these keys have the same value?

This is how my application.yml properties look for postgresql

#jpa properties
spring:
  jpa:
    show-sql: false
    database-platform:  org.hibernate.dialect.PostgreSQL95Dialect
    hibernate:  
        ddl-auto: validate
    properties: 
      hibernate:  
        order_inserts:  false
        order_updates:  false
        dialect:  org.hibernate.dialect.PostgreSQL95Dialect
        default_schema: ${spring.application.name}
        default_catalog: ${spring.application.name}
        jdbc: 
          batch_size:  100
          batch_versioned_data: true

Hi @beikov. Can you suggest a solution?

Here is the test case that validates this works as expected in the Hibernate test suite: hibernate-orm/DefaultCatalogAndSchemaTest.java at 5.6 · hibernate/hibernate-orm · GitHub

It works fine with PostgreSQL, so whatever it is that you are having issues with, it is AFAICT not related to Hibernate. If you think there is a bug, please provide a PR against the Hibernate repository with a test that reproduces the issue.

Hi @beikov ,

In version 5.6.1.Final the default schema property is working properly (although there is a circular bean dependency error) but it is not working since 5.6.2.Final. So something must have changed in between, isn’t it?

[HHH-14921] - Hibernate JIRA is the issue under which some of the changes in this area were done, but like I wrote before. We have tests that verify this works properly. If you think there is a bug, create a reproducible test case (hibernate-test-case-templates/JPAUnitTestCase.java at main · hibernate/hibernate-test-case-templates · GitHub) and attach that to a new issue in the issue tracker(https://hibernate.atlassian.net).