【问题标题】:Hibernate could not find table when hibernate.hb2ddl.auto=validate and hibernate.default_schema=xyz in SQL Server当 SQL Server 中的 hibernate.hb2ddl.auto=validate 和 hibernate.default_schema=xyz 时,Hibernate 找不到表
【发布时间】:2018-01-30 17:13:10
【问题描述】:

我有一个可以访问多个数据源的 Spring Boot 应用程序,因此我以编程方式为每个数据库创建了数据源。

我的数据库在 SQL Server 上

我还为每个数据源注入了 LocationContainerEntityManagerFactoryBean。

在 EntityManager 中,我包含了以下 JPA 属性

hibernate.hb2ddl.auto=validate

hibernate.default_schema=xyz

虽然我的实体存在于 db 和模式 xyz 中,但 Hibernate 会抛出未找到表 abc 的模式管理异常。

如果我删除 hibernate.hb2ddl.auto=validate 属性,hibernate 能够识别表。

之前有人遇到过这个问题吗? 感谢任何帮助

【问题讨论】:

    标签: hibernate jpa spring-boot


    【解决方案1】:

    这是我们想出的。

    如果您使用 SQL Server 和架构分离,JPA 还需要设置一个附加属性。

    jpa.properties.hibernate.default_catalog=<your_db_catalog>

    需要设置此属性,并且您的架构分离应该可以正常工作。

    希望这个答案对未来的人有所帮助。

    【讨论】:

      猜你喜欢
      • 2017-05-29
      • 2021-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-11
      • 1970-01-01
      • 2014-07-21
      相关资源
      最近更新 更多