I'm trying to code this up, but it is difficult because there are no docs or comments in the code for either interface that describe roughly how to map the 2 very different designs. This is a significant problem for anyone who has existing databases and there are comments from Spring users facing the same issue
It would help greatly if you can give me an idea which ImplicitNamingStrategy equates to the old ImprovedNamingStrategy. I tried a couple w/o luck. I can then code up the PhysicalNamingStrategy side to something like this (does not work because I'm not sure what some of the toPhysical???? methods are responsible for. I might not need the 'unqualify" piece depending on what the Implcit strategy does
public static class ImprovedNamingStrategy implements PhysicalNamingStrategy { @Override public Identifier toPhysicalCatalogName(final Identifier identifier, final JdbcEnvironment jdbcEnv) { return convert(identifier, true); } @Override public Identifier toPhysicalColumnName(final Identifier identifier, final JdbcEnvironment jdbcEnv) { return convert(identifier, true); }
@Override public Identifier toPhysicalSchemaName(final Identifier identifier, final JdbcEnvironment jdbcEnv) { return convert(identifier, false); } @Override public Identifier toPhysicalSequenceName(final Identifier identifier, final JdbcEnvironment jdbcEnv) { return convert(identifier, false); }
@Override public Identifier toPhysicalTableName(final Identifier identifier, final JdbcEnvironment jdbcEnv) { return convert(identifier, true); }
private Identifier convert(final Identifier identifier, final boolean unqualify) { if (identifier == null) return identifier;
String s = identifier.getText();
if (unqualify) s = StringHelper.unqualify(s);
StringBuilder buf = new StringBuilder(s.replace('.', '_'));
for (int i = 1; i < buf.length() - 1; i++) { if (Character.isLowerCase(buf.charAt(i - 1)) && Character.isUpperCase(buf.charAt ) && Character.isLowerCase(buf.charAt(i + 1))) { buf.insert(i++, '_'); }
} return Identifier.toIdentifier(buf.toString().toLowerCase()); } }
|