【发布时间】:2020-01-02 16:59:53
【问题描述】:
现在我遇到了一个问题,我得到“MySchema”未找到异常:
org.h2.jdbc.JdbcSQLSyntaxErrorException: Schema "MySchema" not found; SQL statement:
select batchstatu0_.batch_key as batch_ke1_0_ from myschema.batch_status batchstatu0_ [90079-199]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:573)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:427)
当我使用相同的凭据从 Oracle SQL Developer 运行生成的 sql 时,select 语句会正确找到架构并运行查询。
我最初尝试成功但不是我想要采用的解决方案的一件事是为指定的架构指定一个全新的 DataSource。这行得通,但是当我们开始添加更多事件模式时会很头疼。我更愿意使用一个数据源并在表注释中指定架构。
@Table(name="BATCH_STATUS", schema ="MySchema")
public class BatchStatus {
...
}
还有属性:
spring.jpa.hibernate.ddl-auto=create
spring.jpa.show-sql=true
hibernate.show_sql=true
spring.datasource.jdbc-url=jdbc:oracle:thin:xxx
spring.datasource.username=xxx
spring.datasource.password=xxx
hibernate.default_schema=MySchema
我认为这一定是某种配置问题,但我无法弄清楚。
【问题讨论】:
-
试试 spring.jpa.properties.hibernate.default_schema=MySchema
标签: spring oracle hibernate spring-data-jpa