티스토리 뷰

그닥 좋은 방법은 아니지만 알아두면 요긴하게 쓰일떄가 있습니다.

제 경우 스키마를 분리하기가 곤란한 환경일때 아래와 같이 사용한 적이 있으니 내용 참고.

class CustomTableStrategy: PhysicalNamingStrategy {
    private val prefix = "dev_"
    override fun toPhysicalCatalogName(logicalName: Identifier?, jdbcEnvironment: JdbcEnvironment?): Identifier? {
        return logicalName
    }

    override fun toPhysicalSchemaName(logicalName: Identifier?, jdbcEnvironment: JdbcEnvironment?): Identifier? {
        return logicalName
    }

    override fun toPhysicalTableName(logicalName: Identifier?, jdbcEnvironment: JdbcEnvironment?): Identifier? {
        return if(logicalName == null ) null else Identifier.toIdentifier(prefix + logicalName.text)
    }

    override fun toPhysicalSequenceName(logicalName: Identifier?, jdbcEnvironment: JdbcEnvironment?): Identifier? {
        return logicalName
    }

    override fun toPhysicalColumnName(logicalName: Identifier?, jdbcEnvironment: JdbcEnvironment?): Identifier? {
        return logicalName
    }
}

application.yml

spring:
  jpa:
    properties:
      hibernate:
        physical_naming_strategy: net.donnert.sample.common.CustomTableStrategy

 

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
글 보관함