org.onetwo.jpa.hibernate.ImprovedPhysicalNamingStrategy Maven / Gradle / Ivy
package org.onetwo.jpa.hibernate;
import java.util.Locale;
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
/**
* @author wayshall
*
*/
public class ImprovedPhysicalNamingStrategy implements PhysicalNamingStrategy {
public static final ImprovedPhysicalNamingStrategy INSTANCE = new ImprovedPhysicalNamingStrategy();
@Override
public Identifier toPhysicalCatalogName(Identifier name, JdbcEnvironment jdbcEnvironment) {
return name;
}
@Override
public Identifier toPhysicalSchemaName(Identifier name, JdbcEnvironment jdbcEnvironment) {
return name;
}
@Override
public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment jdbcEnvironment) {
return new Identifier(addUnderscores(name.getText()), name.isQuoted());
}
@Override
public Identifier toPhysicalSequenceName(Identifier name, JdbcEnvironment jdbcEnvironment) {
return new Identifier(addUnderscores(name.getText()), name.isQuoted());
}
@Override
public Identifier toPhysicalColumnName(Identifier name, JdbcEnvironment jdbcEnvironment) {
return new Identifier(addUnderscores(name.getText()), name.isQuoted());
}
protected static String addUnderscores(String name) {
StringBuilder buf = new StringBuilder( name.replace('.', '_') );
for (int i=1; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy