diff --git a/hibernate-core/src/main/java/org/hibernate/internal/util/ReflectHelper.java b/hibernate-core/src/main/java/org/hibernate/internal/util/ReflectHelper.java index 7bdf9fc4ee..0258e7e0d0 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/util/ReflectHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/util/ReflectHelper.java @@ -14,6 +14,7 @@ import java.lang.reflect.Member; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.lang.reflect.ParameterizedType; +import java.lang.reflect.WildcardType; import java.util.Locale; import java.util.regex.Pattern; import jakarta.persistence.Transient; @@ -23,7 +24,6 @@ import org.hibernate.MappingException; import org.hibernate.PropertyNotFoundException; import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; -import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.internal.util.collections.ArrayHelper; import org.hibernate.property.access.internal.PropertyAccessStrategyMixedImpl; import org.hibernate.property.access.spi.Getter; @@ -867,6 +867,9 @@ public final class ReflectHelper { else if ( type instanceof ParameterizedType ) { return (Class) ( (ParameterizedType) type ).getRawType(); } + else if ( type instanceof WildcardType ) { + return getClass( ( (WildcardType) type ).getUpperBounds()[0] ); + } throw new UnsupportedOperationException( "Can't get java type class from type: " + type ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/spi/RegistryHelper.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/spi/RegistryHelper.java index 631ed422d4..654c9f0ff6 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/spi/RegistryHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/spi/RegistryHelper.java @@ -7,13 +7,13 @@ package org.hibernate.type.descriptor.java.spi; import java.io.Serializable; -import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.function.Function; import java.util.function.Supplier; import org.hibernate.annotations.Immutable; import org.hibernate.annotations.Mutability; +import org.hibernate.internal.util.ReflectHelper; import org.hibernate.resource.beans.spi.ManagedBean; import org.hibernate.resource.beans.spi.ManagedBeanRegistry; import org.hibernate.type.descriptor.java.EnumJavaType; @@ -106,14 +106,6 @@ public class RegistryHelper { } private Class determineJavaTypeClass(Type javaType) { - final Class javaTypeClass; - if ( javaType instanceof Class ) { - javaTypeClass = (Class) javaType; - } - else { - final ParameterizedType parameterizedType = (ParameterizedType) javaType; - javaTypeClass = (Class) parameterizedType.getRawType(); - } - return javaTypeClass; + return ReflectHelper.getClass( javaType ); } }