1

Is there any way to change the default column naming strategy for a referenced entity then the default (name of the class). The docs say to call the method setForeignKeyNaming(ForeignKeyNaming.IGNORE_RENAMING) on RelationalMappingContext's NamingStrategy. However, this method is only available on the implementation DefaultNamingStrategy and JdbcMappingContext's naming strategy but it is package private (CachingNamingStrategy). Is there a way around this?

Jens Schauder
  • 77,657
  • 34
  • 181
  • 348

1 Answers1

1
@Bean // in some config class
public JdbcMappingContext jdbcMappingContext() {
    DefaultNamingStrategy namingStrategy = new DefaultNamingStrategy();
    namingStrategy.setForeignKeyNaming(ForeignKeyNaming.IGNORE_RENAMING);
    return new JdbcMappingContext(namingStrategy);
}

And instead of the default plural camelcase class name as a foreign key, name it whatever you want. Just make sure the field has the same name.