How to change Physical Naming strategy used by Spring Boot in Grails (5) app

Viewed 47

Although we can provide a naming strategy that will be used by Gorm interactions, it appears that we cannot influence the underlying naming strategy used by Spring Boot which remains set to the default PhysicalNamingStrategyStandardImpl class.

Why would I need this in a Grails app when we are using Gorm? If we want to use hibernate directly, or use a library that uses hibernate directly for example, envers, then it in turn is directly using jpa via spring boot and does not honour the naming strategy requested.

We can see even if we use a custom naming strategy, our domain objects are first processed via the custom strategy, but then by the default PhysicalNamingStrategyStandardImpl.

How can we provide a different naming strategy implementation when none of the documented properties have any effect?

1 Answers

GORM appears to use the deprecated NamingStrategy. See documentation on custom naming strategy.

In application.yml:

hibernate:
    naming_strategy: 'util.CustomNamingStrategy'

Note that you must implement org.hibernate.cfg.NamingStrategy or extend org.hibernate.cfg.ImprovedNamingStrategy rather than PhysicalNamingStrategyStandardImpl.

Related