HHH-7523 : Misc changes for composite IDs; mostly class/enum name changes
This commit is contained in:
parent
ceec7423dc
commit
b7cc064058
|
@ -45,7 +45,7 @@ import org.hibernate.jpa.metamodel.internal.MappedSuperclassTypeImpl;
|
|||
import org.hibernate.jpa.metamodel.internal.PluralAttributeImpl;
|
||||
import org.hibernate.jpa.metamodel.internal.SingularAttributeImpl;
|
||||
import org.hibernate.jpa.metamodel.internal.UnsupportedFeature;
|
||||
import org.hibernate.metamodel.spi.binding.AbstractCompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.AggregatedCompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.AttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.IndexedPluralAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.PluralAttributeBinding;
|
||||
|
@ -55,6 +55,7 @@ import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
|
|||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.tuple.entity.EntityMetamodel;
|
||||
import org.hibernate.type.ComponentType;
|
||||
import org.hibernate.type.EmbeddedComponentType;
|
||||
import org.hibernate.type.EntityType;
|
||||
|
||||
import static javax.persistence.metamodel.Attribute.PersistentAttributeType;
|
||||
|
@ -238,8 +239,10 @@ public class AttributeBuilder {
|
|||
(ComponentType) attributeTypeDescriptor.getHibernateType()
|
||||
);
|
||||
context.registerEmbeddedableType( embeddableType );
|
||||
AbstractCompositeAttributeBinding compositeAttributeBinding =
|
||||
(AbstractCompositeAttributeBinding) attributeTypeDescriptor.getAttributeMetadata().getAttributeBinding();
|
||||
AggregatedCompositeAttributeBinding compositeAttributeBinding =
|
||||
(AggregatedCompositeAttributeBinding) attributeTypeDescriptor
|
||||
.getAttributeMetadata()
|
||||
.getAttributeBinding();
|
||||
for ( AttributeBinding subAttributeBinding : compositeAttributeBinding.attributeBindings() ) {
|
||||
final Attribute<Y, Object> attribute = buildAttribute( embeddableType, subAttributeBinding );
|
||||
if ( attribute != null ) {
|
||||
|
@ -302,7 +305,7 @@ public class AttributeBuilder {
|
|||
final SingularAttributeBinding singularAttributeBinding = (SingularAttributeBinding) attributeBinding;
|
||||
|
||||
final PersistentAttributeType jpaAttributeType;
|
||||
if ( singularAttributeBinding.getAttribute().getSingularAttributeType().isComposite() ) {
|
||||
if ( singularAttributeBinding.getAttribute().getSingularAttributeType().isAggregate() ) {
|
||||
jpaAttributeType = PersistentAttributeType.EMBEDDED;
|
||||
}
|
||||
else if ( singularAttributeBinding.getAttribute().getSingularAttributeType().isAssociation() ) {
|
||||
|
@ -337,7 +340,7 @@ public class AttributeBuilder {
|
|||
elementPersistentAttributeType = PersistentAttributeType.BASIC;
|
||||
persistentAttributeType = PersistentAttributeType.ELEMENT_COLLECTION;
|
||||
}
|
||||
else if ( elementNature == PluralAttributeElementBinding.Nature.COMPOSITE ) {
|
||||
else if ( elementNature == PluralAttributeElementBinding.Nature.AGGREGATION ) {
|
||||
elementPersistentAttributeType = PersistentAttributeType.EMBEDDED;
|
||||
persistentAttributeType = PersistentAttributeType.ELEMENT_COLLECTION;
|
||||
}
|
||||
|
@ -362,7 +365,7 @@ public class AttributeBuilder {
|
|||
else if ( indexNature == PluralAttributeIndexBinding.Nature.MANY_TO_MANY ) {
|
||||
keyPersistentAttributeType = Attribute.PersistentAttributeType.MANY_TO_ONE;
|
||||
}
|
||||
else if ( indexNature == PluralAttributeIndexBinding.Nature.COMPOSITE ) {
|
||||
else if ( indexNature == PluralAttributeIndexBinding.Nature.AGGREGATION ) {
|
||||
keyPersistentAttributeType = Attribute.PersistentAttributeType.EMBEDDED;
|
||||
}
|
||||
else {
|
||||
|
@ -446,11 +449,18 @@ public class AttributeBuilder {
|
|||
final IdentifiableType identifiableType = (IdentifiableType) owner;
|
||||
final EntityMetamodel entityMetamodel = getDeclarerEntityMetamodel( identifiableType );
|
||||
if ( ! entityMetamodel.getIdentifierProperty().isVirtual() ) {
|
||||
throw new IllegalArgumentException( "expecting non-aggregated identifier mapping" );
|
||||
throw new IllegalArgumentException( "expecting a virtual (non-aggregated composite) identifier mapping" );
|
||||
}
|
||||
org.hibernate.type.Type type = entityMetamodel.getIdentifierProperty().getType();
|
||||
if ( ! ComponentType.class.isInstance( type ) ) {
|
||||
throw new IllegalArgumentException( "expecting non-aggregated identifier mapping" );
|
||||
if ( entityMetamodel.getIdentifierProperty().hasIdentifierMapper() ) {
|
||||
if ( ! ComponentType.class.isInstance( type ) ) {
|
||||
throw new IllegalArgumentException( "expecting an idclass identifier mapping" );
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( ! EmbeddedComponentType.class.isInstance( type ) ) {
|
||||
throw new IllegalArgumentException( "expecting a non-aggregated composite identifier mapping" );
|
||||
}
|
||||
}
|
||||
|
||||
final ComponentType componentType = (ComponentType) type;
|
||||
|
|
|
@ -36,7 +36,6 @@ import org.jboss.logging.Logger;
|
|||
|
||||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.EntityMode;
|
||||
import org.hibernate.FetchMode;
|
||||
import org.hibernate.MultiTenancyStrategy;
|
||||
import org.hibernate.TruthValue;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
|
@ -56,7 +55,7 @@ import org.hibernate.internal.util.ValueHolder;
|
|||
import org.hibernate.metamodel.internal.HibernateTypeHelper.ReflectedCollectionJavaTypes;
|
||||
import org.hibernate.metamodel.spi.MetadataImplementor;
|
||||
import org.hibernate.metamodel.spi.binding.AbstractPluralAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.CompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.AggregatedCompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.AttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.AttributeBindingContainer;
|
||||
import org.hibernate.metamodel.spi.binding.BasicAttributeBinding;
|
||||
|
@ -83,8 +82,8 @@ import org.hibernate.metamodel.spi.binding.RelationalValueBinding;
|
|||
import org.hibernate.metamodel.spi.binding.SecondaryTable;
|
||||
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.TypeDefinition;
|
||||
import org.hibernate.metamodel.spi.domain.Aggregate;
|
||||
import org.hibernate.metamodel.spi.domain.Attribute;
|
||||
import org.hibernate.metamodel.spi.domain.Composite;
|
||||
import org.hibernate.metamodel.spi.domain.Entity;
|
||||
import org.hibernate.metamodel.spi.domain.PluralAttribute;
|
||||
import org.hibernate.metamodel.spi.domain.SingularAttribute;
|
||||
|
@ -278,8 +277,8 @@ public class Binder {
|
|||
EntityBinding rootEntityBinding,
|
||||
AggregatedCompositeIdentifierSource identifierSource ) {
|
||||
// locate the attribute binding
|
||||
final CompositeAttributeBinding idAttributeBinding =
|
||||
(CompositeAttributeBinding) bindIdentifierAttribute(
|
||||
final AggregatedCompositeAttributeBinding idAttributeBinding =
|
||||
(AggregatedCompositeAttributeBinding) bindIdentifierAttribute(
|
||||
rootEntityBinding, identifierSource.getIdentifierAttributeSource()
|
||||
);
|
||||
|
||||
|
@ -574,16 +573,16 @@ public class Binder {
|
|||
}
|
||||
}
|
||||
|
||||
private CompositeAttributeBinding bindAggregatedCompositeAttribute(
|
||||
private AggregatedCompositeAttributeBinding bindAggregatedCompositeAttribute(
|
||||
final MutableAttributeBindingContainer attributeBindingContainer,
|
||||
final ComponentAttributeSource attributeSource,
|
||||
SingularAttribute attribute,
|
||||
boolean isAttributeIdentifier) {
|
||||
final Composite composite;
|
||||
final Aggregate composite;
|
||||
ValueHolder<Class<?>> defaultJavaClassReference = null;
|
||||
if ( attribute == null ) {
|
||||
if ( attributeSource.getClassName() != null ) {
|
||||
composite = new Composite(
|
||||
composite = new Aggregate(
|
||||
attributeSource.getPath(),
|
||||
attributeSource.getClassName(),
|
||||
attributeSource.getClassReference() != null ?
|
||||
|
@ -597,7 +596,7 @@ public class Binder {
|
|||
defaultJavaClassReference = createSingularAttributeJavaType(
|
||||
attributeBindingContainer.getClassReference(), attributeSource.getName()
|
||||
);
|
||||
composite = new Composite(
|
||||
composite = new Aggregate(
|
||||
attributeSource.getPath(),
|
||||
defaultJavaClassReference.getValue().getName(),
|
||||
defaultJavaClassReference,
|
||||
|
@ -610,7 +609,7 @@ public class Binder {
|
|||
);
|
||||
}
|
||||
else {
|
||||
composite = (Composite) attribute.getSingularAttributeType();
|
||||
composite = (Aggregate) attribute.getSingularAttributeType();
|
||||
}
|
||||
|
||||
final SingularAttribute referencingAttribute =
|
||||
|
@ -618,7 +617,7 @@ public class Binder {
|
|||
null :
|
||||
composite.createSingularAttribute( attributeSource.getParentReferenceAttributeName() );
|
||||
final SingularAttributeBinding.NaturalIdMutability naturalIdMutability = attributeSource.getNaturalIdMutability();
|
||||
final CompositeAttributeBinding attributeBinding =
|
||||
final AggregatedCompositeAttributeBinding attributeBinding =
|
||||
attributeBindingContainer.makeAggregatedCompositeAttributeBinding(
|
||||
attribute,
|
||||
referencingAttribute,
|
||||
|
@ -1232,10 +1231,8 @@ public class Binder {
|
|||
final EntityBinding referencedEntityBinding,
|
||||
final String defaultElementJavaTypeName) {
|
||||
|
||||
//referencedEntityBinding.getHierarchyDetails().getEntityIdentifier().getValueBinding().addEntityReferencingAttributeBinding( );
|
||||
|
||||
elementBinding.setRelationalValueBindings(
|
||||
referencedEntityBinding.getHierarchyDetails().getEntityIdentifier().getAttributeBinding().getRelationalValueBindings()
|
||||
elementBinding.setElementEntityIdentifier(
|
||||
referencedEntityBinding.getHierarchyDetails().getEntityIdentifier()
|
||||
);
|
||||
final HibernateTypeDescriptor hibernateTypeDescriptor = elementBinding.getHibernateTypeDescriptor();
|
||||
bindHibernateTypeDescriptor(
|
||||
|
@ -1502,6 +1499,8 @@ public class Binder {
|
|||
attribute
|
||||
);
|
||||
case COMPOSITE:
|
||||
// TODO: should this deal with both aggregated and non-aggegated
|
||||
// attribute bindings?
|
||||
return bindAggregatedCompositeAttribute(
|
||||
attributeBindingContainer,
|
||||
ComponentAttributeSource.class.cast( attributeSource ),
|
||||
|
@ -2307,7 +2306,7 @@ public class Binder {
|
|||
pluralAttributeBinding.getAttribute().getName(),
|
||||
getReferencedPropertyNameIfNotId( pluralAttributeBinding ),
|
||||
pluralAttributeBinding.getPluralAttributeElementBinding()
|
||||
.getNature() == PluralAttributeElementBinding.Nature.COMPOSITE
|
||||
.getNature() == PluralAttributeElementBinding.Nature.AGGREGATION
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2318,7 +2317,7 @@ public class Binder {
|
|||
final TypeFactory typeFactory = metadata.getTypeResolver().getTypeFactory();
|
||||
final String role = pluralAttributeBinding.getAttribute().getRole();
|
||||
final String propertyRef = getReferencedPropertyNameIfNotId( pluralAttributeBinding );
|
||||
final boolean embedded = pluralAttributeBinding.getPluralAttributeElementBinding().getNature() == PluralAttributeElementBinding.Nature.COMPOSITE;
|
||||
final boolean embedded = pluralAttributeBinding.getPluralAttributeElementBinding().getNature() == PluralAttributeElementBinding.Nature.AGGREGATION;
|
||||
switch ( nature ){
|
||||
case BAG:
|
||||
return typeFactory.bag( role, propertyRef, embedded );
|
||||
|
|
|
@ -38,7 +38,7 @@ import org.hibernate.internal.util.ReflectHelper;
|
|||
import org.hibernate.internal.util.beans.BeanInfoHelper;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.metamodel.spi.MetadataImplementor;
|
||||
import org.hibernate.metamodel.spi.binding.AbstractCompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.CompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.AttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.BasicAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.HibernateTypeDescriptor;
|
||||
|
@ -278,10 +278,10 @@ public class HibernateTypeHelper {
|
|||
resolvedHibernateType
|
||||
);
|
||||
}
|
||||
else if ( AbstractCompositeAttributeBinding.class.isInstance( attributeBinding ) ) {
|
||||
else if ( CompositeAttributeBinding.class.isInstance( attributeBinding ) ) {
|
||||
pushHibernateTypeInformationDown(
|
||||
(ComponentAttributeSource) attributeSource,
|
||||
(AbstractCompositeAttributeBinding) attributeBinding,
|
||||
(CompositeAttributeBinding) attributeBinding,
|
||||
resolvedHibernateType
|
||||
);
|
||||
}
|
||||
|
@ -305,7 +305,7 @@ public class HibernateTypeHelper {
|
|||
@SuppressWarnings( {"UnusedParameters"})
|
||||
private void pushHibernateTypeInformationDown(
|
||||
ComponentAttributeSource attributeSource,
|
||||
AbstractCompositeAttributeBinding attributeBinding,
|
||||
CompositeAttributeBinding attributeBinding,
|
||||
Type resolvedHibernateType) {
|
||||
final HibernateTypeDescriptor hibernateTypeDescriptor = attributeBinding.getHibernateTypeDescriptor();
|
||||
final SingularAttribute singularAttribute = SingularAttribute.class.cast( attributeBinding.getAttribute() );
|
||||
|
|
|
@ -50,7 +50,7 @@ public class PluralAttributeIndexSourceImpl implements PluralAttributeIndexSourc
|
|||
case BASIC:
|
||||
return PluralAttributeIndexBinding.Nature.BASIC;
|
||||
case COMPONENT:
|
||||
return PluralAttributeIndexBinding.Nature.COMPOSITE;
|
||||
return PluralAttributeIndexBinding.Nature.AGGREGATION;
|
||||
case MANY_TO_ANY:
|
||||
return PluralAttributeIndexBinding.Nature.MANY_TO_ANY;
|
||||
case MANY_TO_MANY:
|
||||
|
|
|
@ -30,7 +30,6 @@ import java.util.Set;
|
|||
|
||||
import org.jboss.jandex.AnnotationInstance;
|
||||
|
||||
import org.hibernate.FetchMode;
|
||||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.engine.spi.CascadeStyle;
|
||||
|
@ -41,9 +40,8 @@ import org.hibernate.metamodel.internal.source.annotations.attribute.MappedAttri
|
|||
import org.hibernate.metamodel.internal.source.annotations.util.EnumConversionHelper;
|
||||
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
|
||||
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
|
||||
import org.hibernate.metamodel.spi.binding.AggregatedCompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.AttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.CompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.relational.Value;
|
||||
import org.hibernate.metamodel.spi.source.ForeignKeyContributingSource;
|
||||
import org.hibernate.metamodel.spi.source.RelationalValueSource;
|
||||
|
@ -88,8 +86,8 @@ public class ToOneAttributeSourceImpl extends SingularAttributeSourceImpl implem
|
|||
@Override
|
||||
public List<Binder.DefaultNamingStrategy> getDefaultNamingStrategies(
|
||||
final String entityName, final String tableName, final AttributeBinding referencedAttributeBinding) {
|
||||
if ( CompositeAttributeBinding.class.isInstance( referencedAttributeBinding ) ) {
|
||||
CompositeAttributeBinding compositeAttributeBinding = CompositeAttributeBinding.class.cast(
|
||||
if ( AggregatedCompositeAttributeBinding.class.isInstance( referencedAttributeBinding ) ) {
|
||||
AggregatedCompositeAttributeBinding compositeAttributeBinding = AggregatedCompositeAttributeBinding.class.cast(
|
||||
referencedAttributeBinding
|
||||
);
|
||||
List<Binder.DefaultNamingStrategy> result = new ArrayList<Binder.DefaultNamingStrategy>( );
|
||||
|
|
|
@ -46,7 +46,7 @@ import org.hibernate.internal.util.collections.CollectionHelper;
|
|||
import org.hibernate.metamodel.internal.source.annotations.AnnotationBindingContext;
|
||||
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
|
||||
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
|
||||
import org.hibernate.metamodel.spi.binding.AbstractCompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.CompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.AttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.EntityBinding;
|
||||
import org.hibernate.metamodel.spi.binding.ManyToOneAttributeBinding;
|
||||
|
@ -209,8 +209,8 @@ public class SqlResultSetProcessor {
|
|||
String reducedName = name.substring( 0, dotIndex );
|
||||
AttributeBinding attributeBinding = entityBinding.locateAttributeBinding( reducedName );
|
||||
Iterable<? extends AttributeBinding> attributeBindings = null;
|
||||
if ( AbstractCompositeAttributeBinding.class.isInstance( attributeBinding ) ) {
|
||||
AbstractCompositeAttributeBinding compositeAttributeBinding = AbstractCompositeAttributeBinding.class.cast(
|
||||
if ( CompositeAttributeBinding.class.isInstance( attributeBinding ) ) {
|
||||
CompositeAttributeBinding compositeAttributeBinding = CompositeAttributeBinding.class.cast(
|
||||
attributeBinding
|
||||
);
|
||||
attributeBindings = compositeAttributeBinding.attributeBindings();
|
||||
|
@ -241,8 +241,8 @@ public class SqlResultSetProcessor {
|
|||
SingularNonAssociationAttributeBinding identifierAttributeBinding = referencedEntityBinding.getHierarchyDetails()
|
||||
.getEntityIdentifier()
|
||||
.getAttributeBinding();
|
||||
if ( AbstractCompositeAttributeBinding.class.isInstance( identifierAttributeBinding ) ) {
|
||||
attributeBindings = AbstractCompositeAttributeBinding.class.cast( identifierAttributeBinding )
|
||||
if ( CompositeAttributeBinding.class.isInstance( identifierAttributeBinding ) ) {
|
||||
attributeBindings = CompositeAttributeBinding.class.cast( identifierAttributeBinding )
|
||||
.attributeBindings();
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -85,7 +85,7 @@ import org.hibernate.jaxb.spi.hbm.JaxbUnionSubclassElement;
|
|||
import org.hibernate.jaxb.spi.hbm.QuerySourceElement;
|
||||
import org.hibernate.jaxb.spi.hbm.ReturnElement;
|
||||
import org.hibernate.metamodel.spi.MetadataImplementor;
|
||||
import org.hibernate.metamodel.spi.binding.AbstractCompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.CompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.AttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.EntityBinding;
|
||||
import org.hibernate.metamodel.spi.binding.FetchProfile;
|
||||
|
@ -549,8 +549,8 @@ public class HibernateMappingProcessor {
|
|||
String reducedName = name.substring( 0, dotIndex );
|
||||
AttributeBinding value = getRecursiveAttributeBinding( entityBinding, reducedName );
|
||||
Iterable<AttributeBinding> parentPropIter;
|
||||
if ( AbstractCompositeAttributeBinding.class.isInstance( value ) ) {
|
||||
AbstractCompositeAttributeBinding comp = (AbstractCompositeAttributeBinding) value;
|
||||
if ( CompositeAttributeBinding.class.isInstance( value ) ) {
|
||||
CompositeAttributeBinding comp = (CompositeAttributeBinding) value;
|
||||
parentPropIter = comp.attributeBindings();
|
||||
}
|
||||
else if ( SingularAssociationAttributeBinding.class.isInstance( value ) ) {
|
||||
|
@ -558,7 +558,7 @@ public class HibernateMappingProcessor {
|
|||
EntityBinding referencedEntityBinding = toOne.getReferencedEntityBinding();
|
||||
SingularAttributeBinding referencedAttributeBinding = toOne.getReferencedAttributeBinding();
|
||||
try {
|
||||
parentPropIter = AbstractCompositeAttributeBinding.class.cast( referencedAttributeBinding )
|
||||
parentPropIter = CompositeAttributeBinding.class.cast( referencedAttributeBinding )
|
||||
.attributeBindings();
|
||||
}
|
||||
catch ( ClassCastException e ) {
|
||||
|
|
|
@ -26,7 +26,6 @@ package org.hibernate.metamodel.internal.source.hbm;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.FetchMode;
|
||||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.engine.spi.CascadeStyle;
|
||||
|
@ -34,8 +33,8 @@ import org.hibernate.jaxb.spi.hbm.JaxbColumnElement;
|
|||
import org.hibernate.jaxb.spi.hbm.JaxbManyToOneElement;
|
||||
import org.hibernate.mapping.PropertyGeneration;
|
||||
import org.hibernate.metamodel.internal.Binder;
|
||||
import org.hibernate.metamodel.spi.binding.AggregatedCompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.AttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.CompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.relational.Value;
|
||||
import org.hibernate.metamodel.spi.source.ExplicitHibernateTypeSource;
|
||||
|
@ -268,8 +267,8 @@ class ManyToOneAttributeSourceImpl extends AbstractHbmSourceNode implements ToOn
|
|||
|
||||
@Override
|
||||
public List<Binder.DefaultNamingStrategy> getDefaultNamingStrategies(final String entityName, final String tableName, final AttributeBinding referencedAttributeBinding) {
|
||||
if ( CompositeAttributeBinding.class.isInstance( referencedAttributeBinding ) ) {
|
||||
CompositeAttributeBinding compositeAttributeBinding = CompositeAttributeBinding.class.cast(
|
||||
if ( AggregatedCompositeAttributeBinding.class.isInstance( referencedAttributeBinding ) ) {
|
||||
AggregatedCompositeAttributeBinding compositeAttributeBinding = AggregatedCompositeAttributeBinding.class.cast(
|
||||
referencedAttributeBinding
|
||||
);
|
||||
List<Binder.DefaultNamingStrategy> result = new ArrayList<Binder.DefaultNamingStrategy>();
|
||||
|
|
|
@ -36,7 +36,7 @@ import org.hibernate.metamodel.spi.source.MetaAttributeContext;
|
|||
*/
|
||||
public abstract class AbstractCompositeAttributeBinding
|
||||
extends AbstractSingularAttributeBinding
|
||||
implements SingularNonAssociationAttributeBinding, AttributeBindingContainer {
|
||||
implements CompositeAttributeBinding {
|
||||
private final String path;
|
||||
|
||||
protected AbstractCompositeAttributeBinding(
|
||||
|
@ -92,8 +92,6 @@ public abstract class AbstractCompositeAttributeBinding
|
|||
return (AttributeContainer) getAttribute().getSingularAttributeType();
|
||||
}
|
||||
|
||||
public abstract boolean isAggregated();
|
||||
|
||||
@Override
|
||||
public boolean isAssociation() {
|
||||
return false;
|
||||
|
@ -174,6 +172,7 @@ public abstract class AbstractCompositeAttributeBinding
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int attributeBindingSpan() {
|
||||
return attributeBindingMapInternal().size();
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ public abstract class AbstractPluralAttributeBinding extends AbstractAttributeBi
|
|||
case BASIC: {
|
||||
return new BasicPluralAttributeElementBinding( this );
|
||||
}
|
||||
case COMPOSITE: {
|
||||
case AGGREGATION: {
|
||||
return new CompositePluralAttributeElementBinding( this );
|
||||
}
|
||||
case ONE_TO_MANY: {
|
||||
|
|
|
@ -34,7 +34,6 @@ import java.util.List;
|
|||
public abstract class AbstractPluralAttributeElementBinding implements PluralAttributeElementBinding {
|
||||
private final AbstractPluralAttributeBinding pluralAttributeBinding;
|
||||
private final HibernateTypeDescriptor hibernateTypeDescriptor = new HibernateTypeDescriptor();
|
||||
private List<RelationalValueBinding> relationalValueBindings;
|
||||
|
||||
AbstractPluralAttributeElementBinding(AbstractPluralAttributeBinding pluralAttributeBinding) {
|
||||
this.pluralAttributeBinding = pluralAttributeBinding;
|
||||
|
@ -49,13 +48,4 @@ public abstract class AbstractPluralAttributeElementBinding implements PluralAtt
|
|||
public HibernateTypeDescriptor getHibernateTypeDescriptor() {
|
||||
return hibernateTypeDescriptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RelationalValueBinding> getRelationalValueBindings() {
|
||||
return relationalValueBindings;
|
||||
}
|
||||
|
||||
public void setRelationalValueBindings(List<RelationalValueBinding> relationalValueBindings) {
|
||||
this.relationalValueBindings = Collections.unmodifiableList( relationalValueBindings );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,262 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2012, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.spi.binding;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.mapping.PropertyGeneration;
|
||||
import org.hibernate.metamodel.spi.domain.Aggregate;
|
||||
import org.hibernate.metamodel.spi.domain.PluralAttribute;
|
||||
import org.hibernate.metamodel.spi.domain.SingularAttribute;
|
||||
import org.hibernate.metamodel.spi.source.MetaAttributeContext;
|
||||
|
||||
/**
|
||||
* A composite attribute binding for an attribute that can be mapped
|
||||
* to a single entity attribute by means of an actual component class
|
||||
* that aggregates the tuple values.
|
||||
*
|
||||
* @todo should this be named something like AggregationAttributebinding instead?
|
||||
*
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class AggregatedCompositeAttributeBinding
|
||||
extends AbstractCompositeAttributeBinding
|
||||
implements MutableAttributeBindingContainer {
|
||||
private final Map<String, AttributeBinding> attributeBindingMap = new LinkedHashMap<String, AttributeBinding>();
|
||||
private final SingularAttribute parentReference;
|
||||
|
||||
public AggregatedCompositeAttributeBinding(
|
||||
AttributeBindingContainer container,
|
||||
SingularAttribute attribute,
|
||||
String propertyAccessorName,
|
||||
boolean includedInOptimisticLocking,
|
||||
boolean lazy,
|
||||
NaturalIdMutability naturalIdMutability,
|
||||
MetaAttributeContext metaAttributeContext,
|
||||
SingularAttribute parentReference) {
|
||||
super(
|
||||
container,
|
||||
attribute,
|
||||
propertyAccessorName,
|
||||
includedInOptimisticLocking,
|
||||
lazy,
|
||||
naturalIdMutability,
|
||||
metaAttributeContext
|
||||
);
|
||||
if ( ! attribute.getSingularAttributeType().isAggregate() ) {
|
||||
throw new IllegalArgumentException( "Expected the attribute type to be a component" );
|
||||
}
|
||||
this.parentReference = parentReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAggregated() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Aggregate getComposite() {
|
||||
return (Aggregate) getAttribute().getSingularAttributeType();
|
||||
}
|
||||
|
||||
public SingularAttribute getParentReference() {
|
||||
return parentReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, AttributeBinding> attributeBindingMapInternal() {
|
||||
return attributeBindingMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicAttributeBinding makeBasicAttributeBinding(
|
||||
SingularAttribute attribute,
|
||||
List<RelationalValueBinding> relationalValueBindings,
|
||||
String propertyAccessorName,
|
||||
boolean includedInOptimisticLocking,
|
||||
boolean lazy,
|
||||
NaturalIdMutability naturalIdMutability,
|
||||
MetaAttributeContext metaAttributeContext,
|
||||
PropertyGeneration generation) {
|
||||
final BasicAttributeBinding binding = new BasicAttributeBinding(
|
||||
this,
|
||||
attribute,
|
||||
relationalValueBindings,
|
||||
propertyAccessorName,
|
||||
includedInOptimisticLocking,
|
||||
lazy,
|
||||
naturalIdMutability,
|
||||
metaAttributeContext,
|
||||
generation
|
||||
);
|
||||
registerAttributeBinding( binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
protected void registerAttributeBinding(AttributeBinding attributeBinding) {
|
||||
// todo : hook this into the EntityBinding notion of "entity referencing attribute bindings"
|
||||
attributeBindingMap.put( attributeBinding.getAttribute().getName(), attributeBinding );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AggregatedCompositeAttributeBinding makeAggregatedCompositeAttributeBinding(
|
||||
SingularAttribute attribute,
|
||||
SingularAttribute parentReferenceAttribute,
|
||||
String propertyAccessorName,
|
||||
boolean includedInOptimisticLocking,
|
||||
boolean lazy,
|
||||
NaturalIdMutability naturalIdMutability,
|
||||
MetaAttributeContext metaAttributeContext) {
|
||||
final AggregatedCompositeAttributeBinding binding = new AggregatedCompositeAttributeBinding(
|
||||
this,
|
||||
attribute,
|
||||
propertyAccessorName,
|
||||
includedInOptimisticLocking,
|
||||
lazy,
|
||||
naturalIdMutability,
|
||||
metaAttributeContext,
|
||||
parentReferenceAttribute
|
||||
);
|
||||
registerAttributeBinding( binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManyToOneAttributeBinding makeManyToOneAttributeBinding(
|
||||
SingularAttribute attribute,
|
||||
String propertyAccessorName,
|
||||
boolean includedInOptimisticLocking,
|
||||
boolean lazy,
|
||||
NaturalIdMutability naturalIdMutability,
|
||||
MetaAttributeContext metaAttributeContext,
|
||||
EntityBinding referencedEntityBinding,
|
||||
SingularAttributeBinding referencedAttributeBinding,
|
||||
List<RelationalValueBinding> valueBindings) {
|
||||
final ManyToOneAttributeBinding binding = new ManyToOneAttributeBinding(
|
||||
this,
|
||||
attribute,
|
||||
propertyAccessorName,
|
||||
includedInOptimisticLocking,
|
||||
lazy,
|
||||
naturalIdMutability,
|
||||
metaAttributeContext,
|
||||
referencedEntityBinding,
|
||||
referencedAttributeBinding,
|
||||
valueBindings
|
||||
);
|
||||
registerAttributeBinding( binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BagBinding makeBagAttributeBinding(
|
||||
PluralAttribute attribute,
|
||||
PluralAttributeElementBinding.Nature nature,
|
||||
SingularAttributeBinding referencedAttributeBinding,
|
||||
String propertyAccessorName,
|
||||
boolean includedInOptimisticLocking,
|
||||
MetaAttributeContext metaAttributeContext) {
|
||||
Helper.checkPluralAttributeNature( attribute, PluralAttribute.Nature.BAG );
|
||||
final BagBinding binding = new BagBinding(
|
||||
this,
|
||||
attribute,
|
||||
nature,
|
||||
referencedAttributeBinding,
|
||||
propertyAccessorName,
|
||||
includedInOptimisticLocking,
|
||||
metaAttributeContext
|
||||
);
|
||||
registerAttributeBinding( binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListBinding makeListAttributeBinding(
|
||||
PluralAttribute attribute,
|
||||
PluralAttributeElementBinding.Nature nature,
|
||||
SingularAttributeBinding referencedAttributeBinding,
|
||||
String propertyAccessorName,
|
||||
boolean includedInOptimisticLocking,
|
||||
MetaAttributeContext metaAttributeContext,
|
||||
int base) {
|
||||
Helper.checkPluralAttributeNature( attribute, PluralAttribute.Nature.LIST );
|
||||
final ListBinding binding = new ListBinding(
|
||||
this,
|
||||
attribute,
|
||||
nature,
|
||||
referencedAttributeBinding,
|
||||
propertyAccessorName,
|
||||
includedInOptimisticLocking,
|
||||
metaAttributeContext,
|
||||
base );
|
||||
registerAttributeBinding( binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapBinding makeMapAttributeBinding(
|
||||
PluralAttribute attribute,
|
||||
PluralAttributeElementBinding.Nature elementNature,
|
||||
PluralAttributeIndexBinding.Nature indexNature,
|
||||
SingularAttributeBinding referencedAttributeBinding,
|
||||
String propertyAccessorName,
|
||||
boolean includedInOptimisticLocking,
|
||||
MetaAttributeContext metaAttributeContext) {
|
||||
Helper.checkPluralAttributeNature( attribute, PluralAttribute.Nature.MAP );
|
||||
final MapBinding binding = new MapBinding(
|
||||
this,
|
||||
attribute,
|
||||
elementNature,
|
||||
indexNature,
|
||||
referencedAttributeBinding,
|
||||
propertyAccessorName,
|
||||
includedInOptimisticLocking,
|
||||
metaAttributeContext );
|
||||
registerAttributeBinding( binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SetBinding makeSetAttributeBinding(
|
||||
PluralAttribute attribute,
|
||||
PluralAttributeElementBinding.Nature nature,
|
||||
SingularAttributeBinding referencedAttributeBinding,
|
||||
String propertyAccessorName,
|
||||
boolean includedInOptimisticLocking,
|
||||
MetaAttributeContext metaAttributeContext) {
|
||||
Helper.checkPluralAttributeNature( attribute, PluralAttribute.Nature.SET );
|
||||
final SetBinding binding = new SetBinding(
|
||||
this,
|
||||
attribute,
|
||||
nature,
|
||||
referencedAttributeBinding,
|
||||
propertyAccessorName,
|
||||
includedInOptimisticLocking,
|
||||
metaAttributeContext
|
||||
);
|
||||
registerAttributeBinding( binding );
|
||||
return binding;
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ import org.hibernate.metamodel.spi.relational.Value;
|
|||
import org.hibernate.metamodel.spi.source.MetaAttributeContext;
|
||||
|
||||
/**
|
||||
* Common contract for {@link EntityBinding} and {@link AbstractCompositeAttributeBinding} in so far as they are both
|
||||
* Common contract for {@link EntityBinding} and {@link CompositeAttributeBinding} in so far as they are both
|
||||
* containers for {@link AttributeBinding} descriptors
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
|
@ -57,6 +57,15 @@ public interface AttributeBindingContainer {
|
|||
*/
|
||||
public Iterable<AttributeBinding> attributeBindings();
|
||||
|
||||
/**
|
||||
* Return the number of attribute bindings returned by
|
||||
* {@link #attributeBindings()}.
|
||||
*
|
||||
* @return the number of attribute bindings returned by
|
||||
* {@link #attributeBindings()}.
|
||||
*/
|
||||
public int attributeBindingSpan();
|
||||
|
||||
/**
|
||||
* Locate a specific attribute binding, by its local name.
|
||||
*
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.spi.binding;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -35,6 +36,7 @@ public class BasicPluralAttributeElementBinding extends AbstractPluralAttributeE
|
|||
|
||||
private boolean hasDerivedValue;
|
||||
private boolean isNullable = true;
|
||||
private List<RelationalValueBinding> relationalValueBindings;
|
||||
|
||||
public BasicPluralAttributeElementBinding(AbstractPluralAttributeBinding binding) {
|
||||
super( binding );
|
||||
|
@ -45,8 +47,13 @@ public class BasicPluralAttributeElementBinding extends AbstractPluralAttributeE
|
|||
return Nature.BASIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RelationalValueBinding> getRelationalValueBindings() {
|
||||
return relationalValueBindings;
|
||||
}
|
||||
|
||||
public void setRelationalValueBindings(List<RelationalValueBinding> relationalValueBindings) {
|
||||
super.setRelationalValueBindings( relationalValueBindings );
|
||||
this.relationalValueBindings = Collections.unmodifiableList( relationalValueBindings );
|
||||
for ( RelationalValueBinding relationalValueBinding : getRelationalValueBindings() ) {
|
||||
this.hasDerivedValue = this.hasDerivedValue || relationalValueBinding.isDerived();
|
||||
this.isNullable = this.isNullable && relationalValueBinding.isNullable();
|
||||
|
|
|
@ -23,234 +23,29 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.spi.binding;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.mapping.PropertyGeneration;
|
||||
import org.hibernate.metamodel.spi.domain.Composite;
|
||||
import org.hibernate.metamodel.spi.domain.PluralAttribute;
|
||||
import org.hibernate.metamodel.spi.domain.SingularAttribute;
|
||||
import org.hibernate.metamodel.spi.source.MetaAttributeContext;
|
||||
|
||||
/**
|
||||
* A specialized binding contract for a singular attribute binding that
|
||||
* contains other attribute bindings.
|
||||
*
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class CompositeAttributeBinding
|
||||
extends AbstractCompositeAttributeBinding
|
||||
implements MutableAttributeBindingContainer {
|
||||
private final Map<String, AttributeBinding> attributeBindingMap = new LinkedHashMap<String, AttributeBinding>();
|
||||
private final SingularAttribute parentReference;
|
||||
public interface CompositeAttributeBinding
|
||||
extends SingularNonAssociationAttributeBinding, AttributeBindingContainer {
|
||||
|
||||
public CompositeAttributeBinding(
|
||||
AttributeBindingContainer container,
|
||||
SingularAttribute attribute,
|
||||
String propertyAccessorName,
|
||||
boolean includedInOptimisticLocking,
|
||||
boolean lazy,
|
||||
NaturalIdMutability naturalIdMutability,
|
||||
MetaAttributeContext metaAttributeContext,
|
||||
SingularAttribute parentReference) {
|
||||
super(
|
||||
container,
|
||||
attribute,
|
||||
propertyAccessorName,
|
||||
includedInOptimisticLocking,
|
||||
lazy,
|
||||
naturalIdMutability,
|
||||
metaAttributeContext
|
||||
);
|
||||
if ( ! attribute.getSingularAttributeType().isComposite() ) {
|
||||
throw new IllegalArgumentException( "Expected the attribute type to be a component" );
|
||||
}
|
||||
this.parentReference = parentReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAggregated() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Composite getComposite() {
|
||||
return (Composite) getAttribute().getSingularAttributeType();
|
||||
}
|
||||
|
||||
public SingularAttribute getParentReference() {
|
||||
return parentReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, AttributeBinding> attributeBindingMapInternal() {
|
||||
return attributeBindingMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicAttributeBinding makeBasicAttributeBinding(
|
||||
SingularAttribute attribute,
|
||||
List<RelationalValueBinding> relationalValueBindings,
|
||||
String propertyAccessorName,
|
||||
boolean includedInOptimisticLocking,
|
||||
boolean lazy,
|
||||
NaturalIdMutability naturalIdMutability,
|
||||
MetaAttributeContext metaAttributeContext,
|
||||
PropertyGeneration generation) {
|
||||
final BasicAttributeBinding binding = new BasicAttributeBinding(
|
||||
this,
|
||||
attribute,
|
||||
relationalValueBindings,
|
||||
propertyAccessorName,
|
||||
includedInOptimisticLocking,
|
||||
lazy,
|
||||
naturalIdMutability,
|
||||
metaAttributeContext,
|
||||
generation
|
||||
);
|
||||
registerAttributeBinding( binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
protected void registerAttributeBinding(AttributeBinding attributeBinding) {
|
||||
// todo : hook this into the EntityBinding notion of "entity referencing attribute bindings"
|
||||
attributeBindingMap.put( attributeBinding.getAttribute().getName(), attributeBinding );
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompositeAttributeBinding makeAggregatedCompositeAttributeBinding(
|
||||
SingularAttribute attribute,
|
||||
SingularAttribute parentReferenceAttribute,
|
||||
String propertyAccessorName,
|
||||
boolean includedInOptimisticLocking,
|
||||
boolean lazy,
|
||||
NaturalIdMutability naturalIdMutability,
|
||||
MetaAttributeContext metaAttributeContext) {
|
||||
final CompositeAttributeBinding binding = new CompositeAttributeBinding(
|
||||
this,
|
||||
attribute,
|
||||
propertyAccessorName,
|
||||
includedInOptimisticLocking,
|
||||
lazy,
|
||||
naturalIdMutability,
|
||||
metaAttributeContext,
|
||||
parentReferenceAttribute
|
||||
);
|
||||
registerAttributeBinding( binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManyToOneAttributeBinding makeManyToOneAttributeBinding(
|
||||
SingularAttribute attribute,
|
||||
String propertyAccessorName,
|
||||
boolean includedInOptimisticLocking,
|
||||
boolean lazy,
|
||||
NaturalIdMutability naturalIdMutability,
|
||||
MetaAttributeContext metaAttributeContext,
|
||||
EntityBinding referencedEntityBinding,
|
||||
SingularAttributeBinding referencedAttributeBinding,
|
||||
List<RelationalValueBinding> valueBindings) {
|
||||
final ManyToOneAttributeBinding binding = new ManyToOneAttributeBinding(
|
||||
this,
|
||||
attribute,
|
||||
propertyAccessorName,
|
||||
includedInOptimisticLocking,
|
||||
lazy,
|
||||
naturalIdMutability,
|
||||
metaAttributeContext,
|
||||
referencedEntityBinding,
|
||||
referencedAttributeBinding,
|
||||
valueBindings
|
||||
);
|
||||
registerAttributeBinding( binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BagBinding makeBagAttributeBinding(
|
||||
PluralAttribute attribute,
|
||||
PluralAttributeElementBinding.Nature nature,
|
||||
SingularAttributeBinding referencedAttributeBinding,
|
||||
String propertyAccessorName,
|
||||
boolean includedInOptimisticLocking,
|
||||
MetaAttributeContext metaAttributeContext) {
|
||||
Helper.checkPluralAttributeNature( attribute, PluralAttribute.Nature.BAG );
|
||||
final BagBinding binding = new BagBinding(
|
||||
this,
|
||||
attribute,
|
||||
nature,
|
||||
referencedAttributeBinding,
|
||||
propertyAccessorName,
|
||||
includedInOptimisticLocking,
|
||||
metaAttributeContext
|
||||
);
|
||||
registerAttributeBinding( binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListBinding makeListAttributeBinding(
|
||||
PluralAttribute attribute,
|
||||
PluralAttributeElementBinding.Nature nature,
|
||||
SingularAttributeBinding referencedAttributeBinding,
|
||||
String propertyAccessorName,
|
||||
boolean includedInOptimisticLocking,
|
||||
MetaAttributeContext metaAttributeContext,
|
||||
int base) {
|
||||
Helper.checkPluralAttributeNature( attribute, PluralAttribute.Nature.LIST );
|
||||
final ListBinding binding = new ListBinding(
|
||||
this,
|
||||
attribute,
|
||||
nature,
|
||||
referencedAttributeBinding,
|
||||
propertyAccessorName,
|
||||
includedInOptimisticLocking,
|
||||
metaAttributeContext,
|
||||
base );
|
||||
registerAttributeBinding( binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapBinding makeMapAttributeBinding(
|
||||
PluralAttribute attribute,
|
||||
PluralAttributeElementBinding.Nature elementNature,
|
||||
PluralAttributeIndexBinding.Nature indexNature,
|
||||
SingularAttributeBinding referencedAttributeBinding,
|
||||
String propertyAccessorName,
|
||||
boolean includedInOptimisticLocking,
|
||||
MetaAttributeContext metaAttributeContext) {
|
||||
Helper.checkPluralAttributeNature( attribute, PluralAttribute.Nature.MAP );
|
||||
final MapBinding binding = new MapBinding(
|
||||
this,
|
||||
attribute,
|
||||
elementNature,
|
||||
indexNature,
|
||||
referencedAttributeBinding,
|
||||
propertyAccessorName,
|
||||
includedInOptimisticLocking,
|
||||
metaAttributeContext );
|
||||
registerAttributeBinding( binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SetBinding makeSetAttributeBinding(
|
||||
PluralAttribute attribute,
|
||||
PluralAttributeElementBinding.Nature nature,
|
||||
SingularAttributeBinding referencedAttributeBinding,
|
||||
String propertyAccessorName,
|
||||
boolean includedInOptimisticLocking,
|
||||
MetaAttributeContext metaAttributeContext) {
|
||||
Helper.checkPluralAttributeNature( attribute, PluralAttribute.Nature.SET );
|
||||
final SetBinding binding = new SetBinding(
|
||||
this,
|
||||
attribute,
|
||||
nature,
|
||||
referencedAttributeBinding,
|
||||
propertyAccessorName,
|
||||
includedInOptimisticLocking,
|
||||
metaAttributeContext
|
||||
);
|
||||
registerAttributeBinding( binding );
|
||||
return binding;
|
||||
}
|
||||
/**
|
||||
* Can the composite attribute be mapped to a single entity
|
||||
* attribute by means of an actual component class that aggregates
|
||||
* the tuple values?
|
||||
*
|
||||
* If {@code true} is returned, this instance can safely be cast
|
||||
* to an {@link AggregatedCompositeAttributeBinding}.
|
||||
*
|
||||
* If {@code false} is returned, this instance can safely be cast
|
||||
* to a {@link NonAggregatedCompositeAttributeBinding}.
|
||||
*
|
||||
* @return true, if the attribute can be mapped to a single entity
|
||||
* attribute by means of an actual component class that aggregates
|
||||
* the tuple values; false, otherwise.
|
||||
*/
|
||||
boolean isAggregated();
|
||||
}
|
||||
|
|
|
@ -23,8 +23,10 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.spi.binding;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Describes plural attributes of {@link org.hibernate.metamodel.spi.binding.PluralAttributeElementBinding.Nature#COMPOSITE} elements
|
||||
* Describes plural attributes of {@link org.hibernate.metamodel.spi.binding.PluralAttributeElementBinding.Nature#AGGREGATION} elements
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
* @author Gail Badner
|
||||
|
@ -36,6 +38,11 @@ public class CompositePluralAttributeElementBinding extends AbstractPluralAttrib
|
|||
|
||||
@Override
|
||||
public Nature getNature() {
|
||||
return Nature.COMPOSITE;
|
||||
return Nature.AGGREGATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RelationalValueBinding> getRelationalValueBindings() {
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -508,7 +508,7 @@ public class EntityBinding implements MutableAttributeBindingContainer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CompositeAttributeBinding makeAggregatedCompositeAttributeBinding(
|
||||
public AggregatedCompositeAttributeBinding makeAggregatedCompositeAttributeBinding(
|
||||
SingularAttribute attribute,
|
||||
SingularAttribute parentReferenceAttribute,
|
||||
String propertyAccessorName,
|
||||
|
@ -516,7 +516,7 @@ public class EntityBinding implements MutableAttributeBindingContainer {
|
|||
boolean lazy,
|
||||
SingularAttributeBinding.NaturalIdMutability naturalIdMutability,
|
||||
MetaAttributeContext metaAttributeContext) {
|
||||
final CompositeAttributeBinding binding = new CompositeAttributeBinding(
|
||||
final AggregatedCompositeAttributeBinding binding = new AggregatedCompositeAttributeBinding(
|
||||
this,
|
||||
attribute,
|
||||
propertyAccessorName,
|
||||
|
@ -717,6 +717,11 @@ public class EntityBinding implements MutableAttributeBindingContainer {
|
|||
return attributeBindingMap.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int attributeBindingSpan() {
|
||||
return attributeBindingMap.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of attribute bindings defined on this class, including the
|
||||
* identifier attribute binding and attribute bindings defined
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.spi.binding;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Describes plural attributes of {@link org.hibernate.metamodel.spi.binding.PluralAttributeElementBinding.Nature#MANY_TO_ANY} elements
|
||||
*
|
||||
|
@ -38,4 +40,9 @@ public class ManyToAnyPluralAttributeElementBinding extends AbstractPluralAttrib
|
|||
public Nature getNature() {
|
||||
return Nature.MANY_TO_ANY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RelationalValueBinding> getRelationalValueBindings() {
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
package org.hibernate.metamodel.spi.binding;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.metamodel.spi.relational.Value;
|
||||
|
||||
|
@ -49,6 +50,11 @@ public class ManyToManyPluralAttributeElementBinding extends AbstractPluralAttri
|
|||
return Nature.MANY_TO_MANY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RelationalValueBinding> getRelationalValueBindings() {
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public String getManyToManyWhere() {
|
||||
return manyToManyWhere;
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public interface MutableAttributeBindingContainer extends AttributeBindingContai
|
|||
*
|
||||
* @return The attribute binding instance.
|
||||
*/
|
||||
public CompositeAttributeBinding makeAggregatedCompositeAttributeBinding(
|
||||
public AggregatedCompositeAttributeBinding makeAggregatedCompositeAttributeBinding(
|
||||
SingularAttribute attribute,
|
||||
SingularAttribute parentReferenceAttribute,
|
||||
String propertyAccessorName,
|
||||
|
|
|
@ -33,6 +33,13 @@ import org.hibernate.metamodel.spi.domain.SingularAttribute;
|
|||
import org.hibernate.metamodel.spi.source.MetaAttributeContext;
|
||||
|
||||
/**
|
||||
* A composite attribute binding that contains an immutable tuple
|
||||
* of attribute bindings that are mapped directly to the
|
||||
* attribute binding's container. In other words, the tuple cannot
|
||||
* be mapped to a single entity attribute.
|
||||
*
|
||||
* @todo should this be named something like TupleAttributebinding instead?
|
||||
*
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class NonAggregatedCompositeAttributeBinding extends AbstractCompositeAttributeBinding {
|
||||
|
@ -55,7 +62,7 @@ public class NonAggregatedCompositeAttributeBinding extends AbstractCompositeAtt
|
|||
metaAttributeContext
|
||||
);
|
||||
if ( !AttributeContainer.class.isInstance( attribute.getSingularAttributeType() ) ||
|
||||
attribute.getSingularAttributeType().isComposite() ) {
|
||||
attribute.getSingularAttributeType().isAggregate() ) {
|
||||
throw new IllegalArgumentException(
|
||||
"Expected the attribute type to be an non-component attribute container"
|
||||
);
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.spi.binding;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Describes plural attributes of {@link org.hibernate.metamodel.spi.binding.PluralAttributeElementBinding.Nature#ONE_TO_MANY} elements
|
||||
*
|
||||
|
@ -30,6 +32,8 @@ package org.hibernate.metamodel.spi.binding;
|
|||
* @author Gail Badner
|
||||
*/
|
||||
public class OneToManyPluralAttributeElementBinding extends AbstractPluralAttributeAssociationElementBinding {
|
||||
private EntityIdentifier elementEntityIdentifier;
|
||||
|
||||
OneToManyPluralAttributeElementBinding(AbstractPluralAttributeBinding binding) {
|
||||
super( binding );
|
||||
}
|
||||
|
@ -38,4 +42,14 @@ public class OneToManyPluralAttributeElementBinding extends AbstractPluralAttrib
|
|||
public Nature getNature() {
|
||||
return Nature.ONE_TO_MANY;
|
||||
}
|
||||
|
||||
public void setElementEntityIdentifier(EntityIdentifier elementEntityIdentifier) {
|
||||
this.elementEntityIdentifier = elementEntityIdentifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RelationalValueBinding> getRelationalValueBindings() {
|
||||
// TODO: ugh, can't call this until after the EntityIdentifier is completely bound...
|
||||
return elementEntityIdentifier.getAttributeBinding().getRelationalValueBindings();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public interface PluralAttributeElementBinding {
|
|||
/**
|
||||
* The collection elements are compositions.
|
||||
*/
|
||||
COMPOSITE( false ),
|
||||
AGGREGATION( false ),
|
||||
/**
|
||||
* The collection elements represent entity's in a one-to-many association.
|
||||
*/
|
||||
|
|
|
@ -51,9 +51,9 @@ public interface PluralAttributeIndexBinding {
|
|||
*/
|
||||
BASIC,
|
||||
/**
|
||||
* The map key is a composite
|
||||
* The map key is an aggregated composite
|
||||
*/
|
||||
COMPOSITE,
|
||||
AGGREGATION,
|
||||
/**
|
||||
* The map key is an association identified by a column(s) on the collection table.
|
||||
*/
|
||||
|
|
|
@ -163,7 +163,7 @@ public abstract class AbstractAttributeContainer implements AttributeContainer,
|
|||
}
|
||||
|
||||
@Override
|
||||
public SingularAttribute createCompositeAttribute(String name, Composite composite) {
|
||||
public SingularAttribute createCompositeAttribute(String name, Aggregate composite) {
|
||||
SingularAttributeImpl attribute = new SingularAttributeImpl( this, name, false );
|
||||
attribute.resolveType( composite );
|
||||
addAttribute( attribute );
|
||||
|
|
|
@ -32,8 +32,8 @@ import org.hibernate.internal.util.ValueHolder;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class Composite extends AbstractAttributeContainer {
|
||||
public Composite(String name, String className, ValueHolder<Class<?>> classReference, Hierarchical superType) {
|
||||
public class Aggregate extends AbstractAttributeContainer {
|
||||
public Aggregate(String name, String className, ValueHolder<Class<?>> classReference, Hierarchical superType) {
|
||||
super( name, className, classReference, superType );
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class Composite extends AbstractAttributeContainer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isComposite() {
|
||||
public boolean isAggregate() {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -66,7 +66,7 @@ public interface AttributeContainer extends Type {
|
|||
public IndexedPluralAttribute locateMap(String name);
|
||||
|
||||
public SingularAttribute createSingularAttribute(String name);
|
||||
public SingularAttribute createCompositeAttribute(String name, Composite composite);
|
||||
public SingularAttribute createCompositeAttribute(String name, Aggregate composite);
|
||||
public PluralAttribute createBag(String name);
|
||||
public PluralAttribute createSet(String name);
|
||||
public IndexedPluralAttribute createList(String name);
|
||||
|
|
|
@ -65,7 +65,7 @@ public class BasicType implements Type {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isComposite() {
|
||||
public boolean isAggregate() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class Entity extends AbstractAttributeContainer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isComposite() {
|
||||
public boolean isAggregate() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public class NonEntity extends AbstractAttributeContainer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isComposite() {
|
||||
public boolean isAggregate() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public class Superclass extends AbstractAttributeContainer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isComposite() {
|
||||
public boolean isAggregate() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,5 +60,11 @@ public interface Type {
|
|||
|
||||
public boolean isAssociation();
|
||||
|
||||
public boolean isComposite();
|
||||
/**
|
||||
* Is this attribute an aggregated composite (what JPA calls an Embeddable)?
|
||||
*
|
||||
* @return true, if this attribute is an aggregated composite;
|
||||
* false, otherwise.
|
||||
*/
|
||||
public boolean isAggregate();
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ package org.hibernate.metamodel.spi.domain;
|
|||
*/
|
||||
public enum TypeNature {
|
||||
BASIC( "basic" ),
|
||||
COMPOSITE( "composite" ),
|
||||
AGGREGATION( "aggregation" ),
|
||||
ENTITY( "entity" ),
|
||||
SUPERCLASS( "superclass" ),
|
||||
NON_ENTITY( "non-entity" );
|
||||
|
|
|
@ -101,7 +101,7 @@ import org.hibernate.mapping.PersistentClass;
|
|||
import org.hibernate.mapping.Property;
|
||||
import org.hibernate.mapping.Selectable;
|
||||
import org.hibernate.metadata.ClassMetadata;
|
||||
import org.hibernate.metamodel.spi.binding.AbstractCompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.CompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.AttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.BasicAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.EntityBinding;
|
||||
|
@ -2363,8 +2363,8 @@ public abstract class AbstractEntityPersister
|
|||
}
|
||||
SingularAttributeBinding singularProp = (SingularAttributeBinding) prop;
|
||||
String propname = path == null ? prop.getAttribute().getName() : path + "." + prop.getAttribute().getName();
|
||||
if ( prop instanceof AbstractCompositeAttributeBinding ) {
|
||||
AbstractCompositeAttributeBinding component = (AbstractCompositeAttributeBinding) prop;
|
||||
if ( prop instanceof CompositeAttributeBinding ) {
|
||||
CompositeAttributeBinding component = (CompositeAttributeBinding) prop;
|
||||
internalInitSubclassPropertyAliasesMap( propname, component.attributeBindings() );
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -577,7 +577,7 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
|||
discriminatorInsertable = false;
|
||||
}
|
||||
else if ( entityBinding.isDiscriminatorMatchValueNotNull() ) {
|
||||
discriminatorValue = NULL_DISCRIMINATOR;
|
||||
discriminatorValue = NOT_NULL_DISCRIMINATOR;
|
||||
discriminatorSQLValue = InFragment.NOT_NULL;
|
||||
discriminatorInsertable = false;
|
||||
}
|
||||
|
|
|
@ -31,8 +31,8 @@ import org.hibernate.HibernateException;
|
|||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.mapping.Component;
|
||||
import org.hibernate.mapping.Property;
|
||||
import org.hibernate.metamodel.spi.binding.AbstractCompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.AttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.CompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.EntityIdentifier;
|
||||
import org.hibernate.property.Getter;
|
||||
import org.hibernate.property.Setter;
|
||||
|
@ -76,8 +76,12 @@ public abstract class AbstractComponentTuplizer implements ComponentTuplizer {
|
|||
hasCustomAccessors = foundCustomAccessor;
|
||||
}
|
||||
|
||||
// TODO: Get rid of the need for isIdentifierMapper arg.
|
||||
// Instead the CompositeAttributeBinding should be wrapped (e.g., by a proxy)
|
||||
// so it can provide the information needed to create getters and setters
|
||||
// for an identifier mapper.
|
||||
protected AbstractComponentTuplizer(
|
||||
AbstractCompositeAttributeBinding compositeAttributeBinding,
|
||||
CompositeAttributeBinding compositeAttributeBinding,
|
||||
boolean isIdentifierMapper
|
||||
) {
|
||||
propertySpan = compositeAttributeBinding.attributeBindingSpan();
|
||||
|
@ -86,7 +90,12 @@ public abstract class AbstractComponentTuplizer implements ComponentTuplizer {
|
|||
|
||||
boolean foundCustomAccessor=false;
|
||||
int i = 0;
|
||||
// TODO: when compositeAttributeBinding is wrapped for an identifier mapper
|
||||
// there will be no need for PropertyFactory.getIdentifierMapperGetter()
|
||||
// and PropertyFactory.getIdentifierMapperSetter
|
||||
if ( isIdentifierMapper ) {
|
||||
// HACK ALERT: when isIdentifierMapper is true, the entity identifier
|
||||
// must be completely bound when this method is called.
|
||||
final EntityMode entityMode =
|
||||
compositeAttributeBinding.getContainer().seekEntityBinding().getHierarchyDetails().getEntityMode();
|
||||
final EntityIdentifier entityIdentifier =
|
||||
|
|
|
@ -32,8 +32,8 @@ import org.hibernate.EntityMode;
|
|||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.mapping.Component;
|
||||
import org.hibernate.mapping.Property;
|
||||
import org.hibernate.metamodel.spi.binding.AbstractCompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.AttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.CompositeAttributeBinding;
|
||||
import org.hibernate.tuple.PropertyFactory;
|
||||
import org.hibernate.tuple.StandardProperty;
|
||||
|
||||
|
@ -84,7 +84,7 @@ public class ComponentMetamodel implements Serializable {
|
|||
}
|
||||
|
||||
public ComponentMetamodel(
|
||||
AbstractCompositeAttributeBinding component,
|
||||
CompositeAttributeBinding component,
|
||||
boolean isIdentifierAttributeBinding,
|
||||
boolean isIdentifierMapper) {
|
||||
this.isKey = isIdentifierAttributeBinding;
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.hibernate.EntityMode;
|
|||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.internal.util.ReflectHelper;
|
||||
import org.hibernate.mapping.Component;
|
||||
import org.hibernate.metamodel.spi.binding.AbstractCompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.CompositeAttributeBinding;
|
||||
|
||||
/**
|
||||
* A registry allowing users to define the default {@link ComponentTuplizer} class to use per {@link EntityMode}.
|
||||
|
@ -42,7 +42,7 @@ import org.hibernate.metamodel.spi.binding.AbstractCompositeAttributeBinding;
|
|||
public class ComponentTuplizerFactory implements Serializable {
|
||||
private static final Class[] COMPONENT_TUP_CTOR_SIG = new Class[] { Component.class };
|
||||
private static final Class[] COMPONENT_TUP_CTOR_SIG_NEW = new Class[] {
|
||||
AbstractCompositeAttributeBinding.class,
|
||||
CompositeAttributeBinding.class,
|
||||
boolean.class
|
||||
};
|
||||
|
||||
|
@ -102,7 +102,7 @@ public class ComponentTuplizerFactory implements Serializable {
|
|||
@SuppressWarnings({ "unchecked" })
|
||||
public ComponentTuplizer constructTuplizer(
|
||||
String tuplizerClassName,
|
||||
AbstractCompositeAttributeBinding metadata,
|
||||
CompositeAttributeBinding metadata,
|
||||
boolean isIdentifierMapper) {
|
||||
try {
|
||||
Class<? extends ComponentTuplizer> tuplizerClass = ReflectHelper.classForName( tuplizerClassName );
|
||||
|
@ -146,7 +146,7 @@ public class ComponentTuplizerFactory implements Serializable {
|
|||
*/
|
||||
public ComponentTuplizer constructTuplizer(
|
||||
Class<? extends ComponentTuplizer> tuplizerClass,
|
||||
AbstractCompositeAttributeBinding metadata,
|
||||
CompositeAttributeBinding metadata,
|
||||
boolean isIdentifierMapper) {
|
||||
Constructor<? extends ComponentTuplizer> constructor = getProperConstructor( tuplizerClass, COMPONENT_TUP_CTOR_SIG_NEW );
|
||||
assert constructor != null : "Unable to locate proper constructor for tuplizer [" + tuplizerClass.getName() + "]";
|
||||
|
@ -191,7 +191,7 @@ public class ComponentTuplizerFactory implements Serializable {
|
|||
*/
|
||||
public ComponentTuplizer constructDefaultTuplizer(
|
||||
EntityMode entityMode,
|
||||
AbstractCompositeAttributeBinding metadata,
|
||||
CompositeAttributeBinding metadata,
|
||||
boolean isIdentifierMapper) {
|
||||
Class<? extends ComponentTuplizer> tuplizerClass = defaultImplClassByMode.get( entityMode );
|
||||
if ( tuplizerClass == null ) {
|
||||
|
|
|
@ -36,7 +36,7 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
|
|||
import org.hibernate.internal.util.ReflectHelper;
|
||||
import org.hibernate.mapping.Component;
|
||||
import org.hibernate.mapping.Property;
|
||||
import org.hibernate.metamodel.spi.binding.AbstractCompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.AggregatedCompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.CompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.EntityIdentifier;
|
||||
import org.hibernate.property.BackrefPropertyAccessor;
|
||||
|
@ -99,7 +99,7 @@ public class PojoComponentTuplizer extends AbstractComponentTuplizer {
|
|||
}
|
||||
|
||||
public PojoComponentTuplizer(
|
||||
AbstractCompositeAttributeBinding component,
|
||||
CompositeAttributeBinding component,
|
||||
boolean isIdentifierMapper) {
|
||||
super( component, isIdentifierMapper );
|
||||
|
||||
|
@ -122,8 +122,8 @@ public class PojoComponentTuplizer extends AbstractComponentTuplizer {
|
|||
|
||||
final String parentPropertyName =
|
||||
component.isAggregated() &&
|
||||
( (CompositeAttributeBinding) component ).getParentReference() != null ?
|
||||
( (CompositeAttributeBinding) component ).getParentReference().getName() :
|
||||
( (AggregatedCompositeAttributeBinding) component ).getParentReference() != null ?
|
||||
( (AggregatedCompositeAttributeBinding) component ).getParentReference().getName() :
|
||||
null;
|
||||
if ( parentPropertyName == null ) {
|
||||
parentSetter = null;
|
||||
|
|
|
@ -52,13 +52,13 @@ import org.hibernate.mapping.Component;
|
|||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.Property;
|
||||
import org.hibernate.mapping.PropertyGeneration;
|
||||
import org.hibernate.metamodel.spi.binding.AbstractCompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.AttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.CompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.EntityBinding;
|
||||
import org.hibernate.metamodel.spi.binding.EntityIdentifier;
|
||||
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.domain.Aggregate;
|
||||
import org.hibernate.metamodel.spi.domain.Attribute;
|
||||
import org.hibernate.metamodel.spi.domain.Composite;
|
||||
import org.hibernate.metamodel.spi.domain.SingularAttribute;
|
||||
import org.hibernate.tuple.IdentifierProperty;
|
||||
import org.hibernate.tuple.PropertyFactory;
|
||||
|
@ -404,7 +404,7 @@ public class EntityMetamodel implements Serializable {
|
|||
}
|
||||
else if ( rootEntityIdentifier.isNonAggregatedComposite() ) {
|
||||
identifierAttributeBindingSpan =
|
||||
( (AbstractCompositeAttributeBinding) rootEntityIdentifier.getAttributeBinding() ).attributeBindingSpan();
|
||||
( (CompositeAttributeBinding) rootEntityIdentifier.getAttributeBinding() ).attributeBindingSpan();
|
||||
}
|
||||
else {
|
||||
identifierAttributeBindingSpan = 1;
|
||||
|
@ -708,9 +708,9 @@ public class EntityMetamodel implements Serializable {
|
|||
private void mapPropertyToIndex(Attribute attribute, int i) {
|
||||
propertyIndexes.put( attribute.getName(), i );
|
||||
if ( attribute.isSingular() &&
|
||||
( ( SingularAttribute ) attribute ).getSingularAttributeType().isComposite() ) {
|
||||
Composite composite =
|
||||
(Composite) ( (SingularAttribute) attribute ).getSingularAttributeType();
|
||||
( ( SingularAttribute ) attribute ).getSingularAttributeType().isAggregate() ) {
|
||||
Aggregate composite =
|
||||
(Aggregate) ( (SingularAttribute) attribute ).getSingularAttributeType();
|
||||
for ( Attribute subAttribute : composite.attributes() ) {
|
||||
propertyIndexes.put(
|
||||
attribute.getName() + '.' + subAttribute.getName(),
|
||||
|
|
|
@ -35,8 +35,8 @@ import org.junit.Test;
|
|||
|
||||
import org.hibernate.annotations.Parent;
|
||||
import org.hibernate.annotations.Target;
|
||||
import org.hibernate.metamodel.spi.binding.AbstractCompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.CompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.AggregatedCompositeAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.BasicAttributeBinding;
|
||||
import org.hibernate.metamodel.spi.binding.EntityBinding;
|
||||
import org.hibernate.testing.junit4.BaseAnnotationBindingTestCase;
|
||||
|
@ -75,8 +75,8 @@ public class EmbeddableBindingTest extends BaseAnnotationBindingTestCase {
|
|||
|
||||
final String componentName = "phone";
|
||||
assertNotNull( binding.locateAttributeBinding( componentName ) );
|
||||
assertTrue( binding.locateAttributeBinding( componentName ) instanceof AbstractCompositeAttributeBinding );
|
||||
AbstractCompositeAttributeBinding compositeBinding = (AbstractCompositeAttributeBinding) binding.locateAttributeBinding(
|
||||
assertTrue( binding.locateAttributeBinding( componentName ) instanceof CompositeAttributeBinding );
|
||||
CompositeAttributeBinding compositeBinding = (CompositeAttributeBinding) binding.locateAttributeBinding(
|
||||
componentName
|
||||
);
|
||||
|
||||
|
@ -116,8 +116,8 @@ public class EmbeddableBindingTest extends BaseAnnotationBindingTestCase {
|
|||
|
||||
final String componentName = "embedded";
|
||||
assertNotNull( binding.locateAttributeBinding( componentName ) );
|
||||
assertTrue( binding.locateAttributeBinding( componentName ) instanceof AbstractCompositeAttributeBinding );
|
||||
AbstractCompositeAttributeBinding compositeBinding = (AbstractCompositeAttributeBinding) binding.locateAttributeBinding(
|
||||
assertTrue( binding.locateAttributeBinding( componentName ) instanceof CompositeAttributeBinding );
|
||||
CompositeAttributeBinding compositeBinding = (CompositeAttributeBinding) binding.locateAttributeBinding(
|
||||
componentName
|
||||
);
|
||||
|
||||
|
@ -171,8 +171,8 @@ public class EmbeddableBindingTest extends BaseAnnotationBindingTestCase {
|
|||
|
||||
final String addressComponentName = "address";
|
||||
assertNotNull( binding.locateAttributeBinding( addressComponentName ) );
|
||||
assertTrue( binding.locateAttributeBinding( addressComponentName ) instanceof AbstractCompositeAttributeBinding );
|
||||
AbstractCompositeAttributeBinding attributeCompositeBinding = (AbstractCompositeAttributeBinding) binding.locateAttributeBinding(
|
||||
assertTrue( binding.locateAttributeBinding( addressComponentName ) instanceof CompositeAttributeBinding );
|
||||
CompositeAttributeBinding attributeCompositeBinding = (CompositeAttributeBinding) binding.locateAttributeBinding(
|
||||
addressComponentName
|
||||
);
|
||||
|
||||
|
@ -195,8 +195,8 @@ public class EmbeddableBindingTest extends BaseAnnotationBindingTestCase {
|
|||
|
||||
final String zipComponentName = "zipcode";
|
||||
assertNotNull( attributeCompositeBinding.locateAttributeBinding( zipComponentName ) );
|
||||
assertTrue( attributeCompositeBinding.locateAttributeBinding( zipComponentName ) instanceof AbstractCompositeAttributeBinding );
|
||||
AbstractCompositeAttributeBinding zipCompositeBinding = (AbstractCompositeAttributeBinding) attributeCompositeBinding.locateAttributeBinding(
|
||||
assertTrue( attributeCompositeBinding.locateAttributeBinding( zipComponentName ) instanceof CompositeAttributeBinding );
|
||||
CompositeAttributeBinding zipCompositeBinding = (CompositeAttributeBinding) attributeCompositeBinding.locateAttributeBinding(
|
||||
zipComponentName
|
||||
);
|
||||
|
||||
|
@ -265,15 +265,15 @@ public class EmbeddableBindingTest extends BaseAnnotationBindingTestCase {
|
|||
|
||||
final String aComponentName = "a";
|
||||
assertNotNull( binding.locateAttributeBinding( aComponentName ) );
|
||||
assertTrue( binding.locateAttributeBinding( aComponentName ) instanceof AbstractCompositeAttributeBinding );
|
||||
AbstractCompositeAttributeBinding aCompositeBinding = (AbstractCompositeAttributeBinding) binding.locateAttributeBinding(
|
||||
assertTrue( binding.locateAttributeBinding( aComponentName ) instanceof CompositeAttributeBinding );
|
||||
CompositeAttributeBinding aCompositeBinding = (CompositeAttributeBinding) binding.locateAttributeBinding(
|
||||
aComponentName
|
||||
);
|
||||
|
||||
final String bComponentName = "b";
|
||||
assertNotNull( aCompositeBinding.locateAttributeBinding( bComponentName ) );
|
||||
assertTrue( aCompositeBinding.locateAttributeBinding( bComponentName ) instanceof AbstractCompositeAttributeBinding );
|
||||
AbstractCompositeAttributeBinding bCompositeBinding = (AbstractCompositeAttributeBinding) aCompositeBinding.locateAttributeBinding(
|
||||
assertTrue( aCompositeBinding.locateAttributeBinding( bComponentName ) instanceof CompositeAttributeBinding );
|
||||
CompositeAttributeBinding bCompositeBinding = (CompositeAttributeBinding) aCompositeBinding.locateAttributeBinding(
|
||||
bComponentName
|
||||
);
|
||||
|
||||
|
@ -331,8 +331,8 @@ public class EmbeddableBindingTest extends BaseAnnotationBindingTestCase {
|
|||
|
||||
final String componentName = "embedded";
|
||||
assertNotNull( binding.locateAttributeBinding( componentName ) );
|
||||
assertTrue( binding.locateAttributeBinding( componentName ) instanceof AbstractCompositeAttributeBinding );
|
||||
CompositeAttributeBinding compositeBinding = (CompositeAttributeBinding) binding.locateAttributeBinding(
|
||||
assertTrue( binding.locateAttributeBinding( componentName ) instanceof CompositeAttributeBinding );
|
||||
AggregatedCompositeAttributeBinding compositeBinding = (AggregatedCompositeAttributeBinding) binding.locateAttributeBinding(
|
||||
componentName
|
||||
);
|
||||
|
||||
|
@ -385,8 +385,8 @@ public class EmbeddableBindingTest extends BaseAnnotationBindingTestCase {
|
|||
|
||||
final String componentName = "car";
|
||||
assertNotNull( binding.locateAttributeBinding( componentName ) );
|
||||
assertTrue( binding.locateAttributeBinding( componentName ) instanceof AbstractCompositeAttributeBinding );
|
||||
AbstractCompositeAttributeBinding compositeBinding = (AbstractCompositeAttributeBinding) binding.locateAttributeBinding(
|
||||
assertTrue( binding.locateAttributeBinding( componentName ) instanceof CompositeAttributeBinding );
|
||||
CompositeAttributeBinding compositeBinding = (CompositeAttributeBinding) binding.locateAttributeBinding(
|
||||
componentName
|
||||
);
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ public abstract class AbstractBasicBindingTests extends BaseUnitTestCase {
|
|||
assertEquals( referencedEntityName, simpleEntityAttributeType.getName() );
|
||||
Assert.assertEquals( referencedEntityName, simpleEntityAttributeType.getClassName());
|
||||
Assert.assertTrue( simpleEntityAttributeType.isAssociation() );
|
||||
assertFalse( simpleEntityAttributeType.isComposite() );
|
||||
assertFalse( simpleEntityAttributeType.isAggregate() );
|
||||
|
||||
// relational
|
||||
List<RelationalValueBinding> relationalValueBindings = manyToOneAttributeBinding.getRelationalValueBindings();
|
||||
|
@ -240,8 +240,8 @@ public abstract class AbstractBasicBindingTests extends BaseUnitTestCase {
|
|||
assertRoot( metadata, entityBinding );
|
||||
assertIdAndSimpleProperty( entityBinding );
|
||||
|
||||
CompositeAttributeBinding compositeAttributeBinding =
|
||||
(CompositeAttributeBinding) entityBinding.locateAttributeBinding( "simpleComponent" );
|
||||
AggregatedCompositeAttributeBinding compositeAttributeBinding =
|
||||
(AggregatedCompositeAttributeBinding) entityBinding.locateAttributeBinding( "simpleComponent" );
|
||||
assertNotNull( compositeAttributeBinding );
|
||||
assertSame( compositeAttributeBinding.getAttribute().getSingularAttributeType(), compositeAttributeBinding.getAttributeContainer() );
|
||||
assertEquals( SimpleEntityWithSimpleComponent.class.getName() + ".simpleComponent", compositeAttributeBinding.getPathBase() );
|
||||
|
|
Loading…
Reference in New Issue