【问题标题】:DefaultComponentSafeNamingStrategy with Spring Boot 2 JPA使用 Spring Boot 2 JPA 的 DefaultComponentSafeNamingStrategy
【发布时间】:2018-05-25 15:34:55
【问题描述】:

我正在将旧版 Spring 4.2.4 / Hibernate 4.3 应用程序移植到 Spring Boot 2.0.2。此应用程序使用 Hibernate 的 DefaultComponentSafeNamingStrategy。

Spring Boot 2 / Hibernate 5.2 更改了命名策略。有很多文档解释了新的 Physical 和 Implicit 命名策略,但我没有找到任何关于哪种命名策略可以替代旧的 DefaultComponentSafeNamingStrategy 的信息。

显然,所有表、列等名称都按照它们一直的方式生成,这一点非常重要。如果这不可能,我希望看到一些接近的策略文档,以及它们与过去可用的策略有何不同。到目前为止没有找到任何运气......

从长远来看,这个应用程序的数据库由近 600 个表组成,因此遍历每个表和列的映射需要很长时间:(

是否有任何关于从旧迁移策略迁移的有用文档?我应该求助于创建自己的策略,还是有一个接近并可以扩展的策略?

【问题讨论】:

    标签: hibernate spring-boot spring-data-jpa naming-strategy


    【解决方案1】:

    原来我并不完全理解 Hibernate 5 的命名方法。与 DefaultComponentSafeNamingStrategy 相同的映射策略可以通过配置隐式和物理命名策略来实现:

    spring:
      jpa:
        hibernate:
          naming:
            implicit-strategy: org.hibernate.boot.model.naming.ImplicitNamingStrategyComponentPathImpl
            physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
    

    【讨论】:

      猜你喜欢
      • 2016-09-18
      • 2017-09-02
      • 1970-01-01
      • 1970-01-01
      • 2023-03-10
      • 1970-01-01
      • 2018-07-28
      • 2021-12-15
      • 1970-01-01
      相关资源
      最近更新 更多