From 8813f1c809e5f01e81ae37f4d5ea243cd02f286c Mon Sep 17 00:00:00 2001 From: anuragkumawat Date: Mon, 6 Jun 2022 22:07:37 +0530 Subject: [PATCH] JAVA-11558 Update article - Hibernate 5 Naming Strategy Configuration --- .../hibernate/namingstrategy/CustomPhysicalNamingStrategy.java | 2 +- .../src/test/resources/hibernate-namingstrategy.properties | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/namingstrategy/CustomPhysicalNamingStrategy.java b/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/namingstrategy/CustomPhysicalNamingStrategy.java index 74bcb9e411..d0cc6e8be6 100644 --- a/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/namingstrategy/CustomPhysicalNamingStrategy.java +++ b/persistence-modules/hibernate5/src/main/java/com/baeldung/hibernate/namingstrategy/CustomPhysicalNamingStrategy.java @@ -41,7 +41,7 @@ public class CustomPhysicalNamingStrategy implements PhysicalNamingStrategy { final String newName = identifier.getText() .replaceAll(regex, replacement) .toLowerCase(); - return Identifier.toIdentifier(newName); + return Identifier.toIdentifier(newName, identifier.isQuoted()); } } diff --git a/persistence-modules/hibernate5/src/test/resources/hibernate-namingstrategy.properties b/persistence-modules/hibernate5/src/test/resources/hibernate-namingstrategy.properties index 263033823c..d0e068d13f 100644 --- a/persistence-modules/hibernate5/src/test/resources/hibernate-namingstrategy.properties +++ b/persistence-modules/hibernate5/src/test/resources/hibernate-namingstrategy.properties @@ -5,6 +5,7 @@ hibernate.dialect=org.hibernate.dialect.H2Dialect hibernate.show_sql=false hibernate.hbm2ddl.auto=create-drop +hibernate.globally_quoted_identifiers=true hibernate.physical_naming_strategy=com.baeldung.hibernate.namingstrategy.CustomPhysicalNamingStrategy hibernate.implicit_naming_strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl \ No newline at end of file