HHH-15552 Embeddable type cannot be cast to org.hibernate.usertype.CompositeUserType if referred to from a mapped superclass with generic parameter
This commit is contained in:
parent
1aafc3c34a
commit
f27b3a956d
|
@ -259,11 +259,15 @@ public class ClassPropertyHolder extends AbstractPropertyHolder {
|
||||||
final Value originalValue = prop.getValue();
|
final Value originalValue = prop.getValue();
|
||||||
if ( originalValue instanceof SimpleValue ) {
|
if ( originalValue instanceof SimpleValue ) {
|
||||||
// Avoid copying when the property doesn't depend on a type variable
|
// Avoid copying when the property doesn't depend on a type variable
|
||||||
if ( inferredData.getTypeName().equals( ( (SimpleValue) originalValue ).getTypeName() ) ) {
|
if ( inferredData.getTypeName().equals( getTypeName( originalValue ) ) ) {
|
||||||
superclass.addDeclaredProperty( prop );
|
superclass.addDeclaredProperty( prop );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( originalValue instanceof Component ) {
|
||||||
|
superclass.addDeclaredProperty( prop );
|
||||||
|
return;
|
||||||
|
}
|
||||||
// If the property depends on a type variable, we have to copy it and the Value
|
// If the property depends on a type variable, we have to copy it and the Value
|
||||||
final Property actualProperty = prop.copy();
|
final Property actualProperty = prop.copy();
|
||||||
actualProperty.setReturnedClassName( inferredData.getTypeName() );
|
actualProperty.setReturnedClassName( inferredData.getTypeName() );
|
||||||
|
@ -294,6 +298,19 @@ public class ClassPropertyHolder extends AbstractPropertyHolder {
|
||||||
else {
|
else {
|
||||||
setTypeName( value, inferredData.getTypeName() );
|
setTypeName( value, inferredData.getTypeName() );
|
||||||
}
|
}
|
||||||
|
// if ( value instanceof Component ) {
|
||||||
|
// Component component = ( (Component) value );
|
||||||
|
// Iterator<Property> propertyIterator = component.getPropertyIterator();
|
||||||
|
// while ( propertyIterator.hasNext() ) {
|
||||||
|
// Property property = propertyIterator.next();
|
||||||
|
// try {
|
||||||
|
// property.getGetter( component.getComponentClass() );
|
||||||
|
// }
|
||||||
|
// catch (PropertyNotFoundException e) {
|
||||||
|
// propertyIterator.remove();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
actualProperty.setValue( value );
|
actualProperty.setValue( value );
|
||||||
superclass.addDeclaredProperty( actualProperty );
|
superclass.addDeclaredProperty( actualProperty );
|
||||||
break;
|
break;
|
||||||
|
@ -302,6 +319,18 @@ public class ClassPropertyHolder extends AbstractPropertyHolder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getTypeName(Value value) {
|
||||||
|
if ( value instanceof Component ) {
|
||||||
|
final Component component = (Component) value;
|
||||||
|
final String typeName = component.getTypeName();
|
||||||
|
if ( typeName != null ) {
|
||||||
|
return typeName;
|
||||||
|
}
|
||||||
|
return component.getComponentClassName();
|
||||||
|
}
|
||||||
|
return ( (SimpleValue) value ).getTypeName();
|
||||||
|
}
|
||||||
|
|
||||||
private void setTypeName(Value value, String typeName) {
|
private void setTypeName(Value value, String typeName) {
|
||||||
if ( value instanceof ToOne ) {
|
if ( value instanceof ToOne ) {
|
||||||
final ToOne toOne = (ToOne) value;
|
final ToOne toOne = (ToOne) value;
|
||||||
|
@ -311,8 +340,10 @@ public class ClassPropertyHolder extends AbstractPropertyHolder {
|
||||||
else if ( value instanceof Component ) {
|
else if ( value instanceof Component ) {
|
||||||
final Component component = (Component) value;
|
final Component component = (Component) value;
|
||||||
component.setComponentClassName( typeName );
|
component.setComponentClassName( typeName );
|
||||||
|
if ( component.getTypeName() != null ) {
|
||||||
component.setTypeName( typeName );
|
component.setTypeName( typeName );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if ( value instanceof SimpleValue ) {
|
else if ( value instanceof SimpleValue ) {
|
||||||
( (SimpleValue) value ).setTypeName( typeName );
|
( (SimpleValue) value ).setTypeName( typeName );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue