Search code examples
hibernatespring-bootspring-data-jpanaming-strategy

DefaultComponentSafeNamingStrategy with Spring Boot 2 JPA


I'm porting a legacy Spring 4.2.4 / Hibernate 4.3 application to Spring Boot 2.0.2. This application uses Hibernate's DefaultComponentSafeNamingStrategy.

Naming strategies have changed with Spring Boot 2 / Hibernate 5.2. There is lots of documentation explaining the new Physical and Implicit naming strategies, but I haven't found any information on which naming strategy is a drop in replacement for good old DefaultComponentSafeNamingStrategy.

It is obviously of great importance that all table, column etc. names are generated as they have always been. If that's not possible I'd like to see some documentation of strategies that come close and how they differ from what has been available in the past. No luck in finding any so far...

To put things in perspective, the database of this application consists of close to 600 tables, so going through the mapping for every table and column would take ages :(

Is there any useful documentation available on migrating from legacy migration strategies? Should I resort to creating my own or is there a strategy that comes close and is open for extension?


Solution

  • Turns out that I didn't fully understand Hibernate 5's approach to naming. The same mapping strategy as DefaultComponentSafeNamingStrategy can be achieved by configuring implicit and physical naming strategies as such:

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