# Table default schema

**URL:** https://discourse.hibernate.org/t/table-default-schema/7322
**Category:** Hibernate ORM
**Created:** [March 2, 2023, 11:12am UTC](https://discourse.hibernate.org/t/table-default-schema/7322 "2023-03-02T11:12:07Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![jainprabhash](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/jainprabhash/32/2289_2.png) [@jainprabhash](https://discourse.hibernate.org/u/jainprabhash)
#### Post date: [March 2, 2023, 11:12am UTC](https://discourse.hibernate.org/t/table-default-schema/7322/1 "2023-03-02T11:12:07Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)
#### Post date: [March 2, 2023, 8:08pm UTC](https://discourse.hibernate.org/t/table-default-schema/7322/2 "2023-03-02T20:08:15Z")

</div>

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

---

<div class="post-metadata">

### Author: ![jainprabhash](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/jainprabhash/32/2289_2.png) [@jainprabhash](https://discourse.hibernate.org/u/jainprabhash)
#### Post date: [March 3, 2023, 5:21am UTC](https://discourse.hibernate.org/t/table-default-schema/7322/3 "2023-03-03T05:21:37Z")

</div>

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

---

<div class="post-metadata">

### Author: ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)
#### Post date: [March 3, 2023, 8:02am UTC](https://discourse.hibernate.org/t/table-default-schema/7322/4 "2023-03-03T08:02:27Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![jainprabhash](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/jainprabhash/32/2289_2.png) [@jainprabhash](https://discourse.hibernate.org/u/jainprabhash)
#### Post date: [March 3, 2023, 8:18am UTC](https://discourse.hibernate.org/t/table-default-schema/7322/5 "2023-03-03T08:18:17Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![jainprabhash](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/jainprabhash/32/2289_2.png) [@jainprabhash](https://discourse.hibernate.org/u/jainprabhash)
#### Post date: [March 4, 2023, 5:19am UTC](https://discourse.hibernate.org/t/table-default-schema/7322/6 "2023-03-04T05:19:07Z")

</div>

This is how my application.yml properties look for postgresql

```auto
#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

```

---

<div class="post-metadata">

### Author: ![jainprabhash](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/jainprabhash/32/2289_2.png) [@jainprabhash](https://discourse.hibernate.org/u/jainprabhash)
#### Post date: [March 6, 2023, 6:03am UTC](https://discourse.hibernate.org/t/table-default-schema/7322/7 "2023-03-06T06:03:33Z")

</div>

Hi @beikov. Can you suggest a solution?

---

<div class="post-metadata">

### Author: ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)
#### Post date: [March 6, 2023, 8:35am UTC](https://discourse.hibernate.org/t/table-default-schema/7322/8 "2023-03-06T08:35:40Z")

</div>

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](https://github.com/hibernate/hibernate-orm/blob/5.6/hibernate-core/src/test/java/org/hibernate/test/boot/database/qualifiedTableNaming/DefaultCatalogAndSchemaTest.java)

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.

---

<div class="post-metadata">

### Author: ![jainprabhash](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/jainprabhash/32/2289_2.png) [@jainprabhash](https://discourse.hibernate.org/u/jainprabhash)
#### Post date: [March 6, 2023, 12:37pm UTC](https://discourse.hibernate.org/t/table-default-schema/7322/9 "2023-03-06T12:37:34Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)
#### Post date: [March 6, 2023, 2:41pm UTC](https://discourse.hibernate.org/t/table-default-schema/7322/10 "2023-03-06T14:41:31Z")

</div>

[[HHH-14921] - Hibernate JIRA](https://hibernate.atlassian.net/browse/HHH-14921) 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](https://github.com/hibernate/hibernate-test-case-templates/blob/master/orm/hibernate-orm-5/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java)) and attach that to a new issue in the issue tracker([https://hibernate.atlassian.net](https://hibernate.atlassian.net)).
