'"spring.jpa.hibernate.ddl-auto=create-drop" no longer does "drop schema" after upgrading from Spring Boot 2.6.1 to 2.6.2

I'm using Maven, Spring Boot, Hibernate, and PostgreSQL 11. My application.properties file includes spring.jpa.hibernate.ddl-auto=create-drop, spring.jpa.properties.hibernate.hbm2dll.create_namespaces=true, and spring.jpa.properties.hibernate.default_schema="my_schema".


Spring Boot 2.6.1 has a dependency on Hibernate 5.6.1.Final. Using this version, here's what Hibernate did on startup:

  1. drop tables if exist (they don't exist)
  2. drop my_schema (which doesn't exist)
  3. create my_schema
  4. create tables
  5. alter tables to add constraints

... and then on shutdown:

  1. drop tables if exist (they do exist now)
  2. drop my_schema (which does exist now)

Spring Boot 2.6.2 has a dependency on Hibernate 5.6.3.Final. Using this version, here's what Hibernate did on startup:

  1. drop tables if exist (they don't exist)
  2. create my_schema
  3. create tables
  4. alter tables to add constraints

... and then on shutdown:

  1. drop tables if exist (they do exist now)

(Spring Boot versions 2.6.2 through 2.6.5 all seem to have the same behavior regarding this.)

Questions:

  1. Is there any documentation explaining this change, which I assume happened in Hibernate 5.6.2 or Hibernate 5.6.3?

  2. How can I get back the "drop schema" step on shutdown, when I'm using spring.jpa.hibernate.ddl-auto=create-drop? (But of course, when I'm using a Spring profile that doesn't have the create-drop setting, then I wouldn't want "drop schema" to happen.)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source