For Hibernate < 5.x I implemented the following naming strategy which converts all names to lower case and uses the format "foreigntablename_referencedcolumnname" for foreign key columns:
Code:
public class LowerCaseDefaultNamingStrategy extends DefaultNamingStrategy {
...
@Override
public String foreignKeyColumnName(String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName) {
String foreignKeyColumnName = new StringBuffer(propertyTableName).append("_").append(referencedColumnName).toString().toLowerCase();
return foreignKeyColumnName;
}
...
}
In Hibernate >= 5.x one can use PhysicalNamingStrategy for the lower case names part, works fine. But I can't figure out how/where (ImplicitNamingStrategy?) to replace/implement the method above so that foreign key column names are converted to the mentioned format.
Any hints would be greatly appreciated.
Cheers