@Test public void embeddedPropertyToColumnName() { final boolean dontTouchPrefix = false; strategy.getOptions().setMaxLength(19); assertThat(strategy.embeddedPropertyToColumnName("preFix", "someProperty", dontTouchPrefix)) .isEqualTo("f_pre_fx_sme_prprty"); strategy.getOptions().setMaxLength(22); assertThat(strategy.embeddedPropertyToColumnName("preFix", "someProperty", dontTouchPrefix)) .isEqualTo("f_pre_fx_some_property"); strategy.getOptions().setMaxLength(17); strategy.getOptions().setColumnPrefix(null); assertThat(strategy.embeddedPropertyToColumnName("preFix", "someProperty", dontTouchPrefix)) .isEqualTo("pre_fx_sme_prprty"); }
public String embeddedPropertyToColumnName(String prefix, String embeddedPropertyName, boolean dontTouchPrefix) { String columnPrefix = dontTouchPrefix ? prefix : propertyToName(prefix); String columnPostfix = propertyToName(embeddedPropertyName); String fullColumnPrefix = join(options.getColumnPrefix(), columnPrefix); if (!needRestrict(options.isRestrictEmbeddedColumnNames())) { return concat(fullColumnPrefix, columnPostfix); } String result = null; if (dontTouchPrefix) { final boolean dontTouchFirst = false; int maxPostfixLength = options.getMaxLength() - (fullColumnPrefix.length() + 1); result = concat(fullColumnPrefix, new NameShorter(maxPostfixLength, dontTouchFirst) .embeddedColumnName(columnPostfix)); } else { result = join(options.getColumnPrefix(), embeddedColumnName(columnPrefix, columnPostfix, options.getMaxLength() - options.getColumnPrefixLength())); } return assertName(result, joinWithSpace(prefix, embeddedPropertyName), "@AttributeOverrides({@AttributeOverride(name=\"propertyName\", " + "column=@Column(\"f_column_name\"))"); }
HibernateNamingStrategy { public String embeddedPropertyToColumnName(String prefix, String embeddedPropertyName, boolean dontTouchPrefix) { String columnPrefix = dontTouchPrefix ? prefix : propertyToName(prefix); String columnPostfix = propertyToName(embeddedPropertyName); String fullColumnPrefix = join(options.getColumnPrefix(), columnPrefix); if (!needRestrict(options.isRestrictEmbeddedColumnNames())) { return concat(fullColumnPrefix, columnPostfix); } String result = null; if (dontTouchPrefix) { final boolean dontTouchFirst = false; int maxPostfixLength = options.getMaxLength() - (fullColumnPrefix.length() + 1); result = concat(fullColumnPrefix, new NameShorter(maxPostfixLength, dontTouchFirst) .embeddedColumnName(columnPostfix)); } else { result = join(options.getColumnPrefix(), embeddedColumnName(columnPrefix, columnPostfix, options.getMaxLength() - options.getColumnPrefixLength())); } return assertName(result, joinWithSpace(prefix, embeddedPropertyName), "@AttributeOverrides({@AttributeOverride(name=\"propertyName\", " + "column=@Column(\"f_column_name\"))"); } }
HibernateNamingStrategy { public String embeddedPropertyToColumnName(String prefix, String embeddedPropertyName, boolean dontTouchPrefix) { String columnPrefix = dontTouchPrefix ? prefix : propertyToName(prefix); String columnPostfix = propertyToName(embeddedPropertyName); String fullColumnPrefix = join(options.getColumnPrefix(), columnPrefix); if (!needRestrict(options.isRestrictEmbeddedColumnNames())) { return concat(fullColumnPrefix, columnPostfix); } String result = null; if (dontTouchPrefix) { final boolean dontTouchFirst = false; int maxPostfixLength = options.getMaxLength() - (fullColumnPrefix.length() + 1); result = concat(fullColumnPrefix, new NameShorter(maxPostfixLength, dontTouchFirst) .embeddedColumnName(columnPostfix)); } else { result = join(options.getColumnPrefix(), embeddedColumnName(columnPrefix, columnPostfix, options.getMaxLength() - options.getColumnPrefixLength())); } return assertName(result, joinWithSpace(prefix, embeddedPropertyName), "@AttributeOverrides({@AttributeOverride(name=\"propertyName\", " + "column=@Column(\"f_column_name\"))"); } HibernateNamingStrategy(StrategyOptions options); }
HibernateNamingStrategy { public String embeddedPropertyToColumnName(String prefix, String embeddedPropertyName, boolean dontTouchPrefix) { String columnPrefix = dontTouchPrefix ? prefix : propertyToName(prefix); String columnPostfix = propertyToName(embeddedPropertyName); String fullColumnPrefix = join(options.getColumnPrefix(), columnPrefix); if (!needRestrict(options.isRestrictEmbeddedColumnNames())) { return concat(fullColumnPrefix, columnPostfix); } String result = null; if (dontTouchPrefix) { final boolean dontTouchFirst = false; int maxPostfixLength = options.getMaxLength() - (fullColumnPrefix.length() + 1); result = concat(fullColumnPrefix, new NameShorter(maxPostfixLength, dontTouchFirst) .embeddedColumnName(columnPostfix)); } else { result = join(options.getColumnPrefix(), embeddedColumnName(columnPrefix, columnPostfix, options.getMaxLength() - options.getColumnPrefixLength())); } return assertName(result, joinWithSpace(prefix, embeddedPropertyName), "@AttributeOverrides({@AttributeOverride(name=\"propertyName\", " + "column=@Column(\"f_column_name\"))"); } 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); }
HibernateNamingStrategy { public String embeddedPropertyToColumnName(String prefix, String embeddedPropertyName, boolean dontTouchPrefix) { String columnPrefix = dontTouchPrefix ? prefix : propertyToName(prefix); String columnPostfix = propertyToName(embeddedPropertyName); String fullColumnPrefix = join(options.getColumnPrefix(), columnPrefix); if (!needRestrict(options.isRestrictEmbeddedColumnNames())) { return concat(fullColumnPrefix, columnPostfix); } String result = null; if (dontTouchPrefix) { final boolean dontTouchFirst = false; int maxPostfixLength = options.getMaxLength() - (fullColumnPrefix.length() + 1); result = concat(fullColumnPrefix, new NameShorter(maxPostfixLength, dontTouchFirst) .embeddedColumnName(columnPostfix)); } else { result = join(options.getColumnPrefix(), embeddedColumnName(columnPrefix, columnPostfix, options.getMaxLength() - options.getColumnPrefixLength())); } return assertName(result, joinWithSpace(prefix, embeddedPropertyName), "@AttributeOverrides({@AttributeOverride(name=\"propertyName\", " + "column=@Column(\"f_column_name\"))"); } 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);  }