HHH-18894 Create and return new EnumJavaType object if class name represents enum that is not currently known

This commit is contained in:
Čedomir Igaly 2024-11-28 18:24:29 +01:00 committed by Christian Beikov
parent 78e6d632f2
commit 816b29d390
1 changed files with 15 additions and 1 deletions

View File

@ -319,7 +319,21 @@ public class JpaMetamodelImpl implements JpaMetamodelImplementor, Serializable {
@Override
public EnumJavaType<?> getEnumType(String className) {
return enumJavaTypes.get( className );
final EnumJavaType<?> enumJavaType = enumJavaTypes.get( className );
if ( enumJavaType != null ) {
return enumJavaType;
}
final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
try {
final Class<Object> clazz = classLoaderService.classForName( className );
if ( clazz == null || !clazz.isEnum() ) {
return null;
}
return new EnumJavaType( clazz );
}
catch (ClassLoadingException e) {
throw new RuntimeException( e );
}
}
@Override