@@ -259,11 +259,15 @@ private void addPropertyToMappedSuperclass(Property prop, XClass declaringClass)
259259 final Value originalValue = prop .getValue ();
260260 if ( originalValue instanceof SimpleValue ) {
261261 // Avoid copying when the property doesn't depend on a type variable
262- if ( inferredData .getTypeName ().equals ( ( ( SimpleValue ) originalValue ). getTypeName ( ) ) ) {
262+ if ( inferredData .getTypeName ().equals ( getTypeName ( originalValue ) ) ) {
263263 superclass .addDeclaredProperty ( prop );
264264 return ;
265265 }
266266 }
267+ if ( originalValue instanceof Component ) {
268+ superclass .addDeclaredProperty ( prop );
269+ return ;
270+ }
267271 // If the property depends on a type variable, we have to copy it and the Value
268272 final Property actualProperty = prop .copy ();
269273 actualProperty .setReturnedClassName ( inferredData .getTypeName () );
@@ -294,6 +298,19 @@ public void doSecondPass(Map persistentClasses) throws MappingException {
294298 else {
295299 setTypeName ( value , inferredData .getTypeName () );
296300 }
301+ // if ( value instanceof Component ) {
302+ // Component component = ( (Component) value );
303+ // Iterator<Property> propertyIterator = component.getPropertyIterator();
304+ // while ( propertyIterator.hasNext() ) {
305+ // Property property = propertyIterator.next();
306+ // try {
307+ // property.getGetter( component.getComponentClass() );
308+ // }
309+ // catch (PropertyNotFoundException e) {
310+ // propertyIterator.remove();
311+ // }
312+ // }
313+ // }
297314 actualProperty .setValue ( value );
298315 superclass .addDeclaredProperty ( actualProperty );
299316 break ;
@@ -302,6 +319,18 @@ public void doSecondPass(Map persistentClasses) throws MappingException {
302319 }
303320 }
304321
322+ private String getTypeName (Value value ) {
323+ if ( value instanceof Component ) {
324+ final Component component = (Component ) value ;
325+ final String typeName = component .getTypeName ();
326+ if ( typeName != null ) {
327+ return typeName ;
328+ }
329+ return component .getComponentClassName ();
330+ }
331+ return ( (SimpleValue ) value ).getTypeName ();
332+ }
333+
305334 private void setTypeName (Value value , String typeName ) {
306335 if ( value instanceof ToOne ) {
307336 final ToOne toOne = (ToOne ) value ;
@@ -311,7 +340,9 @@ private void setTypeName(Value value, String typeName) {
311340 else if ( value instanceof Component ) {
312341 final Component component = (Component ) value ;
313342 component .setComponentClassName ( typeName );
314- component .setTypeName ( typeName );
343+ if ( component .getTypeName () != null ) {
344+ component .setTypeName ( typeName );
345+ }
315346 }
316347 else if ( value instanceof SimpleValue ) {
317348 ( (SimpleValue ) value ).setTypeName ( typeName );
0 commit comments