DB/hibernate
jpa hibernate naming physical-strategy 변경
기계새
2022. 10. 7. 15:02
@Entity 어노테이션 붙은 클래스 필드명을 따라 컬럼명 매칭룰을 적용
이를 커스텀으로 변경
CamelCaseToUnderscoresNamingStrategy 를 상속받아 uppercase로 변경
yml 에선언
spring.jpa.hibernate:
naming:
physical-strategy
public class CustomColumnUppercaseStrategy extends CamelCaseToUnderscoresNamingStrategy {
@Override
protected Identifier getIdentifier(String name, final boolean quoted, final JdbcEnvironment jdbcEnvironment) {
if (isCaseInsensitive(jdbcEnvironment)) {
name = name.toUpperCase(Locale.ROOT);
}
return new Identifier(name, quoted);
}
}