Example usage for org.hibernate.boot.model.naming Identifier getText

List of usage examples for org.hibernate.boot.model.naming Identifier getText

Introduction

In this page you can find the example usage for org.hibernate.boot.model.naming Identifier getText.

Prototype

public String getText() 

Source Link

Document

Get the identifiers name (text)

Usage

From source file:org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy.java

License:Apache License

private Identifier apply(Identifier name, JdbcEnvironment jdbcEnvironment) {
    if (name == null) {
        return null;
    }//from   www.j a v  a  2s. com
    StringBuilder builder = new StringBuilder(name.getText().replace('.', '_'));
    for (int i = 1; i < builder.length() - 1; i++) {
        if (isUnderscoreRequired(builder.charAt(i - 1), builder.charAt(i), builder.charAt(i + 1))) {
            builder.insert(i++, '_');
        }
    }
    return getIdentifier(builder.toString(), name.isQuoted(), jdbcEnvironment);
}

From source file:org.wallride.autoconfigure.PhysicalNamingStrategySnakeCaseImpl.java

License:Apache License

private Identifier convert(Identifier identifier) {
    if (identifier == null) {
        return identifier;
    }//w  ww .  ja  v  a  2 s . c om

    String regex = "([a-z])([A-Z])";
    String replacement = "$1_$2";
    String newName = identifier.getText().replaceAll(regex, replacement).toLowerCase();
    return Identifier.toIdentifier(newName, identifier.isQuoted());
}