HHH-17041 Embeddable and Generics throws IllegalArgumentException

This commit is contained in:
Andrea Boriero 2023-08-08 17:16:36 +02:00 committed by Andrea Boriero
parent 0f5008ca3f
commit 18de71edff
2 changed files with 13 additions and 9 deletions

View File

@ -362,12 +362,16 @@ public class ClassPropertyHolder extends AbstractPropertyHolder {
if ( component.isGeneric() ) { if ( component.isGeneric() ) {
actualProperty.setValue( context.getMetadataCollector().getGenericComponent( componentClass ) ); actualProperty.setValue( context.getMetadataCollector().getGenericComponent( componentClass ) );
} }
else {
if ( componentClass == Object.class ) {
// Object is not a valid component class, but that is what we get when using a type variable
component.getProperties().clear();
}
else { else {
final Iterator<Property> propertyIterator = component.getPropertyIterator(); final Iterator<Property> propertyIterator = component.getPropertyIterator();
while ( propertyIterator.hasNext() ) { while ( propertyIterator.hasNext() ) {
Property property = propertyIterator.next();
try { try {
property.getGetter( componentClass ); propertyIterator.next().getGetter( componentClass );
} }
catch (PropertyNotFoundException e) { catch (PropertyNotFoundException e) {
propertyIterator.remove(); propertyIterator.remove();
@ -375,6 +379,7 @@ public class ClassPropertyHolder extends AbstractPropertyHolder {
} }
} }
} }
}
actualProperty.setValue( value ); actualProperty.setValue( value );
propertyConsumer.accept( actualProperty ); propertyConsumer.accept( actualProperty );
break; break;

View File

@ -32,7 +32,6 @@ import org.hibernate.property.access.internal.PropertyAccessStrategyIndexBackRef
import org.hibernate.property.access.spi.BuiltInPropertyAccessStrategies; import org.hibernate.property.access.spi.BuiltInPropertyAccessStrategies;
import org.hibernate.property.access.spi.PropertyAccess; import org.hibernate.property.access.spi.PropertyAccess;
import org.hibernate.property.access.spi.PropertyAccessStrategy; import org.hibernate.property.access.spi.PropertyAccessStrategy;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.type.descriptor.java.JavaType; import org.hibernate.type.descriptor.java.JavaType;
import org.hibernate.type.descriptor.java.spi.JavaTypeRegistry; import org.hibernate.type.descriptor.java.spi.JavaTypeRegistry;
import org.hibernate.type.internal.CompositeUserTypeJavaTypeWrapper; import org.hibernate.type.internal.CompositeUserTypeJavaTypeWrapper;