'"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:
- drop tables if exist (they don't exist)
- drop my_schema (which doesn't exist)
- create my_schema
- create tables
- alter tables to add constraints
... and then on shutdown:
- drop tables if exist (they do exist now)
- 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:
- drop tables if exist (they don't exist)
- create my_schema
- create tables
- alter tables to add constraints
... and then on shutdown:
- 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:
Is there any documentation explaining this change, which I assume happened in Hibernate 5.6.2 or Hibernate 5.6.3?
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 thecreate-dropsetting, 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 |
|---|
