diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/JpaMetamodelImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/JpaMetamodelImpl.java index 12601134a3..ba867dbca7 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/JpaMetamodelImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/JpaMetamodelImpl.java @@ -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 clazz = classLoaderService.classForName( className ); + if ( clazz == null || !clazz.isEnum() ) { + return null; + } + return new EnumJavaType( clazz ); + } + catch (ClassLoadingException e) { + throw new RuntimeException( e ); + } } @Override