Need help in implementing ImplicitNamingStrategy for foreign key column names in Hibernate 5
<p>I am trying to add underscores for the foreign key column names by overriding the method determineForeignKeyName in ImplicitNamingStrategyJpaCompliantImpl class, but somehow its not working. Below is the class i created,</p>

<pre><code>public class CustomNamingStrategy extends ImplicitNamingStrategyJpaCompliantImpl implements Serializable{

    public static final CustomNamingStrategy INSTANCE=new CustomNamingStrategy ();



    /**
     * Produces a plural table name from the given class name
     * @return a pluralized version of the class name using underscores instead of mixed case.
     */
    @Override
    protected String transformEntityName(EntityNaming entityNaming) {
        return Noun.pluralOf(addUnderscores(StringHelper.unqualify(entityNaming.getEntityName())));
    }

    protected static String addUnderscores(String name) {
        StringBuilder buf = new StringBuilder(name.replace('.', '_'));
        for (int i = 1; i &lt; buf.length() - 1; i++) {
            if (
                    Character.isLowerCase(buf.charAt(i - 1)) &amp;&amp;
                            Character.isUpperCase(buf.charAt(i)) &amp;&amp;
                            Character.isLowerCase(buf.charAt(i + 1))
                    ) {
                buf.insert(i++, '_');
            }
        }
        return buf.toString().toLowerCase(Locale.ROOT);
    }

    @Override
    public Identifier determineForeignKeyName(ImplicitForeignKeyNameSource source) {

        return toIdentifier(
                NamingHelper.INSTANCE.generateHashedFkName(
                        "FK",
                        source.getTableName(),
                        source.getReferencedTableName(),
                        addUnderscorestocolumns(source.getColumnNames())
                ),
                source.getBuildingContext()
        );
    }


    public List&lt;Identifier&gt; addUnderscorestocolumns(List&lt;Identifier&gt; columnNamesList) {

        List&lt;Identifier&gt; underscorecolumns = new ArrayList&lt;Identifier&gt;();

        for (int i = 0; i &lt; columnNamesList.size(); i++) {
                        underscorecolumns.add(Identifier.toIdentifier(addUnderscores(columnNamesList.get(i).getText())))  ;
        }
        return underscorecolumns;
    }



   @Override
    public Identifier determineBasicColumnName(ImplicitBasicColumnNameSource source) {

        return toIdentifier(transformAttributePathCustom(source.getAttributePath()), source.getBuildingContext());
    }

    protected String transformAttributePathCustom(AttributePath attributePath) {
        return addUnderscores(attributePath.getProperty());
    }

  }
</code></pre>

<p>So, except the determineForeignKeyName method, others methods are working as expected, like adding plural names and underscore for the tables. When i debug through the code, i can see the control going into the determineForeignKeyName method for the foreign key columns and underscores are added, but when the control goes to InflightMetadataCollectorImpl class (org.hibernate.boot.internal), i can see only referenced column is added, but not the underscores for the column name.</p>

<p>Is there any other method i need to implement for foreign key column names or i there any error in my implementation? Please suggest.</p>