From 1d956eb40028793333d1bbc87cb6355879ffe330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9da=20Housni=20Alaoui?= Date: Fri, 1 Dec 2023 19:20:30 +0100 Subject: [PATCH] HHH-17494 Metamodel generator produce an uncompilable class when an EntityGraph name contains a comma --- .../main/java/org/hibernate/jpamodelgen/util/StringUtil.java | 2 +- .../java/org/hibernate/jpamodelgen/test/StringUtilTest.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/util/StringUtil.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/util/StringUtil.java index 0f61539ee8..d2af84553e 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/util/StringUtil.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/util/StringUtil.java @@ -99,7 +99,7 @@ public final class StringUtil { } public static String nameToMethodName(String name) { - return name.replaceAll("[\\s.\\-!@#%=+/*^&|(){}\\[\\]]", "_"); + return name.replaceAll("[\\s.\\-!@#%=+/*^&|(){}\\[\\],]", "_"); } public static String getUpperUnderscoreCaseFromLowerCamelCase(String lowerCamelCaseString){ diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/StringUtilTest.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/StringUtilTest.java index 6a118993ae..383748162d 100644 --- a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/StringUtilTest.java +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/StringUtilTest.java @@ -41,4 +41,9 @@ public class StringUtilTest { public void testGetUpperUnderscoreCaseFromLowerCamelCase(){ assertEquals("USER_PARENT_NAME", StringUtil.getUpperUnderscoreCaseFromLowerCamelCase("userParentName")); } + + @Test + public void testNameToMethodNameWithComma() { + assertEquals( "entity_Graph", StringUtil.nameToMethodName( "entity,Graph" ) ); + } }