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" ) ); + } }