HibernateNamingStrategy { public String foreignKeyColumnName(String propertyName, String propertyTableName) { String header = propertyName != null ? NamingStrategyUtils.unqualify(propertyName) : propertyTableName; String result = join(options.getForeignKeyColumnPrefix(), NamingStrategyUtils.addUnderscores(header)); if (needRestrict(options.isRestrictColumnNames())) { return assertName( new NameShorter(options.getMaxLength(), options.hasForeignKeyColumnPrefix()) .columnName(result), joinWithSpace(propertyTableName, propertyName), "@JoinColumn(name=\"fk_name\")"); } return result; } HibernateNamingStrategy(StrategyOptions options); StrategyOptions getOptions(); void setOptions(StrategyOptions options); String classToTableName(String className); String propertyToColumnName(String propertyName); String embeddedPropertyToColumnName(String prefix, String embeddedPropertyName,
            boolean dontTouchPrefix); String joinTableName(String ownerEntityTable, String associatedEntityTable); String joinTableName(String ownerEntityTable, String associatedEntityTable,
            String ownerProperty); String joinKeyColumnName(String joinedColumn, String joinedTable); String foreignKeyColumnName(String propertyName, String propertyTableName); String foreignKeyConstraintName(String tableName, String columnName); String uniqueKeyConstraintName(String tableName, String columnName);  }
@Test public void foreignKeyColumnName() { assertThat(strategy.foreignKeyColumnName("propertyName", "propertyTableName")) .isEqualTo("fk_property_name"); assertThat(strategy.foreignKeyColumnName(null, "propertyTableName")) .isEqualTo("fk_property_table_name"); strategy.getOptions().setForeignKeyColumnPrefix(null); assertThat(strategy.foreignKeyColumnName("propertyName", "propertyTableName")) .isEqualTo("property_name"); assertThat(strategy.foreignKeyColumnName(null, "propertyTableName")) .isEqualTo("property_table_name"); }