【发布时间】:2021-10-21 06:20:56
【问题描述】:
最终,我的应用程序会做我想做的事。启动时,它使用我指定为默认模式的名称创建模式,并创建我的表。在关闭时,它会删除表,然后删除模式。这一切都很好。
但是启动时出现错误,然后又恢复了。
在启动时,首先它会为我的表drop table if exists,并且效果很好。
然后它会删除模式“myschema”,这会导致此错误:
通过 JDBC 语句执行 DDL “drop schema “myschema””时出错
引起:org.postgresql.util.PSQLException:错误:模式“myschema”不存在
我真的希望它不要那样做,拜托。即使它最终会恢复。
它能够做到“如果存在则删除表”,那么为什么不能以同样的方式“删除模式”呢?
我指定架构名称的唯一位置是在我的 application.properties 文件中。以下是我设置的一些属性:
logging.level.org.hibernate.SQL = DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder = TRACE
spring.datasource.driver-class-name = org.postgresql.Driver
spring.jpa.hibernate.ddl-auto = create-drop
spring.jpa.open-in-view = false
spring.jpa.properties.hibernate.default_schema = "myschema"
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
spring.jpa.properties.hibernate.hbm2dll.create_namespaces = true
spring.jpa.show-sql = true
版本:
Spring Boot 2.5.3
Java 14
Postgresql jdbc 驱动 42.2.23
Postgresql 数据库 11.4
Maven 3.8.1(嵌入在 Eclipse 2021-06 中)
【问题讨论】:
标签: java spring postgresql spring-boot hibernate