diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/ComponentAttributeSourceImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/ComponentAttributeSourceImpl.java index e8d4f319b0..314df75dd4 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/ComponentAttributeSourceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/ComponentAttributeSourceImpl.java @@ -29,6 +29,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.persistence.AccessType; + import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.ValueHolder; import org.hibernate.mapping.PropertyGeneration; @@ -49,6 +51,7 @@ import org.hibernate.metamodel.spi.source.RelationalValueSource; * * @author Steve Ebersole * @author Hardy Ferentschik + * @author Brett Meyer */ public class ComponentAttributeSourceImpl implements ComponentAttributeSource { private static final String PATH_SEPARATOR = "."; @@ -56,12 +59,17 @@ public class ComponentAttributeSourceImpl implements ComponentAttributeSource { private final ValueHolder> classReference; private final Map attributeOverrides; private final String path; + private final AccessType classAccessType; - public ComponentAttributeSourceImpl(EmbeddableClass embeddableClass, String parentPath, Map attributeOverrides) { + public ComponentAttributeSourceImpl(EmbeddableClass embeddableClass, + String parentPath, + Map attributeOverrides, + AccessType classAccessType) { this.embeddableClass = embeddableClass; this.classReference = new ValueHolder>( embeddableClass.getConfiguredClass() ); this.attributeOverrides = attributeOverrides; this.path = StringHelper.isEmpty( parentPath ) ? embeddableClass.getEmbeddedAttributeName() : parentPath + "." + embeddableClass.getEmbeddedAttributeName(); + this.classAccessType = classAccessType; } @Override @@ -101,7 +109,7 @@ public class ComponentAttributeSourceImpl implements ComponentAttributeSource { @Override public String getPropertyAccessorName() { - return embeddableClass.getClassAccessType().toString().toLowerCase(); + return classAccessType.toString().toLowerCase(); } @Override @@ -129,7 +137,8 @@ public class ComponentAttributeSourceImpl implements ComponentAttributeSource { new ComponentAttributeSourceImpl( embeddable, getPath(), - createAggregatedOverrideMap() + createAggregatedOverrideMap(), + classAccessType ) ); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/CompositePluralAttributeElementSourceImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/CompositePluralAttributeElementSourceImpl.java index 679b9738d9..d3fac4075a 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/CompositePluralAttributeElementSourceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/CompositePluralAttributeElementSourceImpl.java @@ -32,7 +32,7 @@ import org.hibernate.metamodel.internal.source.annotations.attribute.Association import org.hibernate.metamodel.internal.source.annotations.attribute.AttributeOverride; import org.hibernate.metamodel.internal.source.annotations.attribute.BasicAttribute; import org.hibernate.metamodel.internal.source.annotations.entity.EmbeddableClass; -import org.hibernate.metamodel.internal.source.annotations.entity.RootEntityClass; +import org.hibernate.metamodel.internal.source.annotations.entity.EntityClass; import org.hibernate.metamodel.spi.binding.CascadeType; import org.hibernate.metamodel.spi.source.AttributeSource; import org.hibernate.metamodel.spi.source.CompositePluralAttributeElementSource; @@ -47,7 +47,7 @@ public class CompositePluralAttributeElementSourceImpl implements CompositePlura private static final String PATH_SEPARATOR = "."; private final AssociationAttribute associationAttribute; - private final RootEntityClass rootEntityClass; + private final EntityClass entityClass; private List attributeSources = new ArrayList(); @@ -56,9 +56,9 @@ public class CompositePluralAttributeElementSourceImpl implements CompositePlura public CompositePluralAttributeElementSourceImpl( AssociationAttribute associationAttribute, - RootEntityClass rootEntityClass ) { + EntityClass rootEntityClass ) { this.associationAttribute = associationAttribute; - this.rootEntityClass = rootEntityClass; + this.entityClass = rootEntityClass; buildAttributeSources(); } @@ -123,7 +123,7 @@ public class CompositePluralAttributeElementSourceImpl implements CompositePlura } private void buildAttributeSources() { - EmbeddableClass embeddableClass = rootEntityClass + EmbeddableClass embeddableClass = entityClass .getCollectionEmbeddedClasses() .get( associationAttribute.getName() ); @@ -133,8 +133,8 @@ public class CompositePluralAttributeElementSourceImpl implements CompositePlura for ( BasicAttribute attribute : embeddableClass.getSimpleAttributes() ) { AttributeOverride attributeOverride = null; String tmp = getPath() + PATH_SEPARATOR + attribute.getName(); - if ( rootEntityClass.getAttributeOverrideMap().containsKey( tmp ) ) { - attributeOverride = rootEntityClass.getAttributeOverrideMap().get( tmp ); + if ( entityClass.getAttributeOverrideMap().containsKey( tmp ) ) { + attributeOverride = entityClass.getAttributeOverrideMap().get( tmp ); } attribute.setNaturalIdMutability( embeddableClass.getNaturalIdMutability() ); attributeSources.add( new SingularAttributeSourceImpl( attribute, attributeOverride ) ); @@ -145,7 +145,8 @@ public class CompositePluralAttributeElementSourceImpl implements CompositePlura new ComponentAttributeSourceImpl( embeddable, getPath(), - createAggregatedOverrideMap( embeddableClass, rootEntityClass.getAttributeOverrideMap() ) + createAggregatedOverrideMap( embeddableClass, entityClass.getAttributeOverrideMap() ), + embeddable.getClassAccessType() ) ); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/EntitySourceImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/EntitySourceImpl.java index 38f8849a9e..13eb00eb32 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/EntitySourceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/EntitySourceImpl.java @@ -223,7 +223,8 @@ public class EntitySourceImpl implements EntitySource { new ComponentAttributeSourceImpl( component, "", - entityClass.getAttributeOverrideMap() + entityClass.getAttributeOverrideMap(), + entityClass.getClassAccessType() ) ); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/PluralAttributeSourceImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/PluralAttributeSourceImpl.java index 889fa5c76e..6f6ecd8823 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/PluralAttributeSourceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/PluralAttributeSourceImpl.java @@ -109,7 +109,7 @@ public class PluralAttributeSourceImpl implements PluralAttributeSource, Orderab case ELEMENT_COLLECTION_EMBEDDABLE: { // TODO: cascadeStyles? return new CompositePluralAttributeElementSourceImpl( - associationAttribute, (RootEntityClass) entityClass ); + associationAttribute, entityClass ); } } throw new AssertionError( "Unexpected attribute nature for a association:" + associationAttribute.getNature() ); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/RootEntitySourceImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/RootEntitySourceImpl.java index 459c3d0a75..af625a7610 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/RootEntitySourceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/RootEntitySourceImpl.java @@ -193,7 +193,7 @@ public class RootEntitySourceImpl extends EntitySourceImpl implements RootEntity // todo : no idea how to obtain overrides here... Map overrides = getEntityClass().getAttributeOverrideMap(); - componentAttributeSource = new ComponentAttributeSourceImpl( embeddableClass, "", overrides ); + componentAttributeSource = new ComponentAttributeSourceImpl( embeddableClass, "", overrides, embeddableClass.getClassAccessType() ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/AbstractComponentAttributeSourceImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/AbstractComponentAttributeSourceImpl.java index d0787c227e..aaea5b9682 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/AbstractComponentAttributeSourceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/AbstractComponentAttributeSourceImpl.java @@ -76,7 +76,7 @@ public abstract class AbstractComponentAttributeSourceImpl extends AbstractHbmSo this.componentClassReference = makeClassReference( componentSourceElement.getClazz() ); this.logicalTableName = logicalTableName; this.path = parentContainer.getPath() + '.' + componentSourceElement.getName(); - + this.subAttributeSources = buildAttributeSources(); }