From 7a2a611b963ac80d9f46f5b2aed1d0c2ed2703b4 Mon Sep 17 00:00:00 2001 From: yeseul106 <20191037@sungshin.ac.kr> Date: Mon, 4 Dec 2023 20:30:43 +0900 Subject: [PATCH] =?UTF-8?q?[#89]=20fix:=20hibernate=206=EC=97=90=20?= =?UTF-8?q?=EB=A7=9E=EC=B6=B0=EC=84=9C=20PhysicalNamingStrategyStandardImp?= =?UTF-8?q?l=20=EB=84=A4=EC=9D=B4=EB=B0=8D=20=EC=A0=84=EB=9E=B5=EC=9D=B4?= =?UTF-8?q?=20=EB=90=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/CamelCaseNamingStrategy.java | 40 +++++++++++++++++++ main/src/main/resources/application-dev.yml | 4 +- 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 main/src/main/java/org/sopt/makers/crew/main/common/config/CamelCaseNamingStrategy.java diff --git a/main/src/main/java/org/sopt/makers/crew/main/common/config/CamelCaseNamingStrategy.java b/main/src/main/java/org/sopt/makers/crew/main/common/config/CamelCaseNamingStrategy.java new file mode 100644 index 00000000..99684108 --- /dev/null +++ b/main/src/main/java/org/sopt/makers/crew/main/common/config/CamelCaseNamingStrategy.java @@ -0,0 +1,40 @@ +package org.sopt.makers.crew.main.common.config; + +import org.hibernate.boot.model.naming.Identifier; +import org.hibernate.boot.model.naming.PhysicalNamingStrategy; +import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment; + +public class CamelCaseNamingStrategy implements PhysicalNamingStrategy { + + @Override + public Identifier toPhysicalCatalogName(Identifier name, JdbcEnvironment jdbcEnvironment) { + return apply(name, jdbcEnvironment); + } + + @Override + public Identifier toPhysicalSchemaName(Identifier name, JdbcEnvironment jdbcEnvironment) { + return apply(name, jdbcEnvironment); + } + + @Override + public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment jdbcEnvironment) { + return apply(name, jdbcEnvironment); + } + + @Override + public Identifier toPhysicalSequenceName(Identifier name, JdbcEnvironment jdbcEnvironment) { + return apply(name, jdbcEnvironment); + } + + @Override + public Identifier toPhysicalColumnName(Identifier name, JdbcEnvironment jdbcEnvironment) { + return apply(name, jdbcEnvironment); + } + + private Identifier apply(Identifier identifier, JdbcEnvironment jdbcEnvironment) { + if (identifier == null) { + return null; + } + return Identifier.toIdentifier(identifier.getText(), true); + } +} diff --git a/main/src/main/resources/application-dev.yml b/main/src/main/resources/application-dev.yml index b274c5fe..2b279c58 100644 --- a/main/src/main/resources/application-dev.yml +++ b/main/src/main/resources/application-dev.yml @@ -13,9 +13,9 @@ spring: password: ${DEV_DB_PASSWORD} jpa: hibernate: - ddl-auto: validate naming: - physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl + physical-strategy: org.sopt.makers.crew.main.common.config.CamelCaseNamingStrategy + ddl-auto: validate properties: hibernate: show_sql: true