HHH-14059 Cannot use full qualified enum name which has two uppercase alphabet prefix

This commit is contained in:
yuanhang zheng 2020-06-11 17:00:18 +08:00 committed by Andrea Boriero
parent 8c8349d4a4
commit 27bb8980d0
2 changed files with 12 additions and 1 deletions

View File

@ -39,7 +39,7 @@ import org.hibernate.type.Type;
public final class ReflectHelper { public final class ReflectHelper {
private static final Pattern JAVA_CONSTANT_PATTERN = Pattern.compile( private static final Pattern JAVA_CONSTANT_PATTERN = Pattern.compile(
"[a-z\\d]+\\.([A-Z]{1}[a-z\\d]+)+\\$?([A-Z]{1}[a-z\\d]+)*\\.[A-Z_\\$]+", Pattern.UNICODE_CHARACTER_CLASS); "[a-z\\d]+\\.([A-Z]+[a-z\\d]+)+\\$?([A-Z]{1}[a-z\\d]+)*\\.[A-Z_\\$]+", Pattern.UNICODE_CHARACTER_CLASS);
public static final Class[] NO_PARAM_SIGNATURE = new Class[0]; public static final Class[] NO_PARAM_SIGNATURE = new Class[0];
public static final Object[] NO_PARAMS = new Object[0]; public static final Object[] NO_PARAMS = new Object[0];

View File

@ -230,4 +230,15 @@ public class ReflectHelperTest {
public void test_setMethod_nestedInterfaces_on_superclasses() { public void test_setMethod_nestedInterfaces_on_superclasses() {
assertNotNull( ReflectHelper.findSetterMethod( E.class, "id", String.class ) ); assertNotNull( ReflectHelper.findSetterMethod( E.class, "id", String.class ) );
} }
@TestForIssue(jiraKey = "HHH-14059")
@Test
public void test_getConstantValue_UpperCaseEnum() {
when( sessionFactoryOptionsMock.isConventionalJavaConstants() ).thenReturn( true );
when( classLoaderServiceMock.classForName( "com.example.UStatus" ) ).thenReturn( (Class) Status.class );
Object value = ReflectHelper.getConstantValue( "com.example.UStatus.OFF", sessionFactoryImplementorMock);
assertEquals( OFF, value );
verify(classLoaderServiceMock, times(1)).classForName( eq("com.example.UStatus") );
}
} }