|
54 | 54 | import org.hibernate.type.descriptor.java.JavaType; |
55 | 55 | import org.hibernate.type.descriptor.java.spi.DynamicModelJavaType; |
56 | 56 | import org.hibernate.type.descriptor.java.spi.EntityJavaType; |
| 57 | +import org.hibernate.type.descriptor.java.spi.JavaTypeRegistry; |
57 | 58 | import org.hibernate.type.spi.TypeConfiguration; |
58 | 59 |
|
59 | 60 | import jakarta.persistence.EntityGraph; |
@@ -245,17 +246,29 @@ public Set<String> getAllowedEnumLiteralTexts(String enumValue) { |
245 | 246 |
|
246 | 247 | @Override |
247 | 248 | public EnumJavaType<?> getEnumType(String prefix) { |
| 249 | + final ClassLoaderService classLoaderService = |
| 250 | + getServiceRegistry().requireService(ClassLoaderService.class); |
| 251 | + final JavaTypeRegistry registry = getTypeConfiguration().getJavaTypeRegistry(); |
248 | 252 | try { |
249 | | - final Class<?> namedClass = |
250 | | - getServiceRegistry().requireService( ClassLoaderService.class ) |
251 | | - .classForName( prefix ); |
| 253 | + final Class<?> namedClass = classLoaderService.classForName( prefix ); |
252 | 254 | if ( namedClass != null && namedClass.isEnum() ) { |
253 | | - return (EnumJavaType) getTypeConfiguration() |
254 | | - .getJavaTypeRegistry() |
255 | | - .resolveDescriptor(namedClass); |
| 255 | + return (EnumJavaType) registry.resolveDescriptor(namedClass); |
256 | 256 | } |
257 | 257 | } |
258 | | - catch (Exception ignore) { |
| 258 | + catch (ClassLoadingException classLoadingException) { |
| 259 | + try { |
| 260 | + final int lastDot = prefix.lastIndexOf('.'); |
| 261 | + if ( lastDot>0) { |
| 262 | + final String replaced = |
| 263 | + prefix.substring(0, lastDot) + '$' + prefix.substring(lastDot+1); |
| 264 | + final Class<?> namedClass = classLoaderService.classForName( replaced ); |
| 265 | + if ( namedClass != null && namedClass.isEnum() ) { |
| 266 | + return (EnumJavaType) registry.resolveDescriptor(namedClass); |
| 267 | + } |
| 268 | + } |
| 269 | + } |
| 270 | + catch (ClassLoadingException ignore) { |
| 271 | + } |
259 | 272 | } |
260 | 273 | return null; |
261 | 274 | } |
|
0 commit comments