Also create inverse model parts for nested embeddable attributes
This commit is contained in:
parent
c548a79f0b
commit
7f4a4afd64
|
@ -32,6 +32,7 @@ import org.hibernate.metamodel.mapping.AttributeMapping;
|
|||
import org.hibernate.metamodel.mapping.AttributeMetadata;
|
||||
import org.hibernate.metamodel.mapping.AttributeMetadataAccess;
|
||||
import org.hibernate.metamodel.mapping.EmbeddableMappingType;
|
||||
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
|
||||
import org.hibernate.metamodel.mapping.ForeignKeyDescriptor;
|
||||
import org.hibernate.metamodel.mapping.ManagedMappingType;
|
||||
import org.hibernate.metamodel.mapping.SelectableMapping;
|
||||
|
@ -194,9 +195,18 @@ public abstract class AbstractEmbeddableMapping implements EmbeddableMappingType
|
|||
attributeMapping = toOne;
|
||||
currentIndex += attributeMapping.getJdbcTypeCount();
|
||||
}
|
||||
else if ( attributeMapping instanceof EmbeddedAttributeMapping ) {
|
||||
attributeMapping = ( (EmbeddedAttributeMapping) attributeMapping ).copy( declaringType );
|
||||
currentIndex = attributeMapping.getJdbcTypeCount();
|
||||
else if ( attributeMapping instanceof EmbeddableValuedModelPart ) {
|
||||
final SelectableMapping[] subMappings = new SelectableMapping[attributeMapping.getJdbcTypeCount()];
|
||||
for (int i = 0; i < subMappings.length; i++) {
|
||||
subMappings[i] = selectableMappings.getSelectable( currentIndex++ );
|
||||
}
|
||||
attributeMapping = MappingModelCreationHelper.createInverseModelPart(
|
||||
(EmbeddableValuedModelPart) attributeMapping,
|
||||
declaringType,
|
||||
declaringTableGroupProducer,
|
||||
new SelectableMappingsImpl( subMappings ),
|
||||
creationProcess
|
||||
);
|
||||
}
|
||||
else {
|
||||
throw new UnsupportedMappingException(
|
||||
|
|
|
@ -354,23 +354,6 @@ public class EmbeddedAttributeMapping
|
|||
return "EmbeddedAttributeMapping(" + navigableRole + ")@" + System.identityHashCode( this );
|
||||
}
|
||||
|
||||
public AttributeMapping copy(ManagedMappingType declaringType) {
|
||||
return new EmbeddedAttributeMapping(
|
||||
getAttributeName(),
|
||||
getNavigableRole(),
|
||||
getStateArrayPosition(),
|
||||
tableExpression,
|
||||
getAttributeMetadataAccess(),
|
||||
getParentInjectionAttributePropertyAccess(),
|
||||
getTiming(),
|
||||
getStyle(),
|
||||
getEmbeddableTypeDescriptor(),
|
||||
declaringType,
|
||||
getPropertyAccess(),
|
||||
getValueGeneration()
|
||||
);
|
||||
}
|
||||
|
||||
private static PropertyAccess getPropertyAccess(
|
||||
String parentInjectionAttributeName,
|
||||
EmbeddableMappingType embeddableMappingType) {
|
||||
|
|
|
@ -1527,7 +1527,7 @@ public class MappingModelCreationHelper {
|
|||
);
|
||||
}
|
||||
|
||||
public static EmbeddableValuedModelPart createInverseModelPart(
|
||||
public static EmbeddedAttributeMapping createInverseModelPart(
|
||||
EmbeddableValuedModelPart modelPart,
|
||||
ManagedMappingType keyDeclaringType,
|
||||
TableGroupProducer declaringTableGroupProducer,
|
||||
|
|
|
@ -8,7 +8,6 @@ package org.hibernate.metamodel.mapping.internal;
|
|||
|
||||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.metamodel.mapping.AttributeMapping;
|
||||
import org.hibernate.metamodel.mapping.AttributeMetadataAccess;
|
||||
import org.hibernate.metamodel.mapping.EmbeddableMappingType;
|
||||
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
|
||||
|
@ -99,21 +98,4 @@ public class VirtualEmbeddedAttributeMapping extends EmbeddedAttributeMapping im
|
|||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttributeMapping copy(ManagedMappingType declaringType) {
|
||||
return new VirtualEmbeddedAttributeMapping(
|
||||
getAttributeName(),
|
||||
getNavigableRole(),
|
||||
getStateArrayPosition(),
|
||||
getContainingTableExpression(),
|
||||
getAttributeMetadataAccess(),
|
||||
getParentInjectionAttributePropertyAccess(),
|
||||
getTiming(),
|
||||
getStyle(),
|
||||
getEmbeddableTypeDescriptor(),
|
||||
declaringType,
|
||||
getPropertyAccess(),
|
||||
getValueGeneration()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue