And*_*kin 6 java spring hibernate jpa spring-boot
我想让表位于不同的数据库模式中。但不幸的是,我无法通过 Spring Boot 实现这一点。这是重现它的步骤。
在http://start.spring.io版本 2.0.5上创建一个新的 Spring Boot 项目(带有 derby 和 PostgreSQL 依赖项)
创建简单实体
@Entity
@Table(name = "my_table")
public class MyTable {
@Id Integer id;
}
Run Code Online (Sandbox Code Playgroud)
spring.jpa.hibernate.ddl-auto=create
运行生成的测试或主类。确保一切正常。
修改实体,schema为@Table注解添加属性。现在实体看起来像:
@Entity
@Table(name = "my_table", schema = "my_schema")
public class MyTable {
@Id Integer id;
}
Run Code Online (Sandbox Code Playgroud)
java.sql.SQLSyntaxErrorException: Schema 'MY_SCHEMA' does not exist”:完整日志列表可在此处获得:https : //gist.github.com/asaushkin/8d767c92b2e7025dd359f7be43eefdd6
完整日志在这里:https : //gist.github.com/asaushkin/dd0d677964556bf943c4f013d4785372
我的问题是:为什么模式不是由 Spring Boot 创建的?
这些选项也不能解决这个问题:
spring.jpa.properties.javax.persistence.schema-generation.create-database-schemas=true
spring.jpa.properties.hibernate.hbm2dll.create_namespaces=true
Run Code Online (Sandbox Code Playgroud)
链接
更新(2019 年 3 月 11 日):
我刚刚检查了问题的当前行为。我想知道,但目前使用 Derby 驱动程序一切正常,并且该表是使用指定的架构创建的。但是在 PostgreSQL 中,错误仍然存在。
生成的 SQL(用于 PostgreSQL)是:
spring.jpa.properties.javax.persistence.schema-generation.create-database-schemas=true
spring.jpa.properties.hibernate.hbm2dll.create_namespaces=true
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5567 次 |
| 最近记录: |