HHH-7075 - Use the term 'composition' and 'composite' to refer to components/embeddables
This commit is contained in:
parent
71539da942
commit
9c0d625235
|
@ -49,7 +49,7 @@ import org.hibernate.metamodel.spi.binding.AttributeBinding;
|
||||||
import org.hibernate.metamodel.spi.binding.AttributeBindingContainer;
|
import org.hibernate.metamodel.spi.binding.AttributeBindingContainer;
|
||||||
import org.hibernate.metamodel.spi.binding.BasicAttributeBinding;
|
import org.hibernate.metamodel.spi.binding.BasicAttributeBinding;
|
||||||
import org.hibernate.metamodel.spi.binding.BasicPluralAttributeElementBinding;
|
import org.hibernate.metamodel.spi.binding.BasicPluralAttributeElementBinding;
|
||||||
import org.hibernate.metamodel.spi.binding.CompositionAttributeBinding;
|
import org.hibernate.metamodel.spi.binding.CompositeAttributeBinding;
|
||||||
import org.hibernate.metamodel.spi.binding.EntityBinding;
|
import org.hibernate.metamodel.spi.binding.EntityBinding;
|
||||||
import org.hibernate.metamodel.spi.binding.EntityDiscriminator;
|
import org.hibernate.metamodel.spi.binding.EntityDiscriminator;
|
||||||
import org.hibernate.metamodel.spi.binding.IdGenerator;
|
import org.hibernate.metamodel.spi.binding.IdGenerator;
|
||||||
|
@ -61,7 +61,7 @@ import org.hibernate.metamodel.spi.binding.RelationalValueBinding;
|
||||||
import org.hibernate.metamodel.spi.binding.SingularAssociationAttributeBinding;
|
import org.hibernate.metamodel.spi.binding.SingularAssociationAttributeBinding;
|
||||||
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
|
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
|
||||||
import org.hibernate.metamodel.spi.domain.Attribute;
|
import org.hibernate.metamodel.spi.domain.Attribute;
|
||||||
import org.hibernate.metamodel.spi.domain.Composition;
|
import org.hibernate.metamodel.spi.domain.Composite;
|
||||||
import org.hibernate.metamodel.spi.domain.Entity;
|
import org.hibernate.metamodel.spi.domain.Entity;
|
||||||
import org.hibernate.metamodel.spi.domain.PluralAttribute;
|
import org.hibernate.metamodel.spi.domain.PluralAttribute;
|
||||||
import org.hibernate.metamodel.spi.domain.SingularAttribute;
|
import org.hibernate.metamodel.spi.domain.SingularAttribute;
|
||||||
|
@ -722,8 +722,8 @@ public class Binder {
|
||||||
final SingularAttributeBinding referencedAttributeBinding = (SingularAttributeBinding) referencedEntityBinding.locateAttributeBinding(
|
final SingularAttributeBinding referencedAttributeBinding = (SingularAttributeBinding) referencedEntityBinding.locateAttributeBinding(
|
||||||
attributeSource.getReferencedEntityAttributeName()
|
attributeSource.getReferencedEntityAttributeName()
|
||||||
);
|
);
|
||||||
if ( CompositionAttributeBinding.class.isInstance( referencedAttributeBinding ) ) {
|
if ( CompositeAttributeBinding.class.isInstance( referencedAttributeBinding ) ) {
|
||||||
collectValues( (CompositionAttributeBinding) referencedAttributeBinding, targetColumns );
|
collectValues( (CompositeAttributeBinding) referencedAttributeBinding, targetColumns );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for ( RelationalValueBinding valueBinding :( (BasicAttributeBinding) referencedAttributeBinding ).getRelationalValueBindings() ) {
|
for ( RelationalValueBinding valueBinding :( (BasicAttributeBinding) referencedAttributeBinding ).getRelationalValueBindings() ) {
|
||||||
|
@ -748,8 +748,8 @@ public class Binder {
|
||||||
return foreignKey;
|
return foreignKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void collectValues(CompositionAttributeBinding compositionAttributeBinding, List<Value> targetColumns) {
|
private void collectValues(CompositeAttributeBinding compositeAttributeBinding, List<Value> targetColumns) {
|
||||||
for ( AttributeBinding attributeBinding : compositionAttributeBinding.attributeBindings() ) {
|
for ( AttributeBinding attributeBinding : compositeAttributeBinding.attributeBindings() ) {
|
||||||
if ( BasicAttributeBinding.class.isInstance( attributeBinding ) ) {
|
if ( BasicAttributeBinding.class.isInstance( attributeBinding ) ) {
|
||||||
for ( RelationalValueBinding valueBinding :( (BasicAttributeBinding) attributeBinding ).getRelationalValueBindings() ) {
|
for ( RelationalValueBinding valueBinding :( (BasicAttributeBinding) attributeBinding ).getRelationalValueBindings() ) {
|
||||||
targetColumns.add( valueBinding.getValue() );
|
targetColumns.add( valueBinding.getValue() );
|
||||||
|
@ -760,8 +760,8 @@ public class Binder {
|
||||||
targetColumns.add( valueBinding.getValue() );
|
targetColumns.add( valueBinding.getValue() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( CompositionAttributeBinding.class.isInstance( attributeBinding ) ) {
|
else if ( CompositeAttributeBinding.class.isInstance( attributeBinding ) ) {
|
||||||
collectValues( (CompositionAttributeBinding) attributeBinding, targetColumns );
|
collectValues( (CompositeAttributeBinding) attributeBinding, targetColumns );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -818,19 +818,19 @@ public class Binder {
|
||||||
AttributeBindingContainer container,
|
AttributeBindingContainer container,
|
||||||
Deque<TableSpecification> tableStack) {
|
Deque<TableSpecification> tableStack) {
|
||||||
final String attributeName = attributeSource.getName();
|
final String attributeName = attributeSource.getName();
|
||||||
SingularAttribute attribute = container.getAttributeContainer().locateCompositionAttribute( attributeName );
|
SingularAttribute attribute = container.getAttributeContainer().locateCompositeAttribute( attributeName );
|
||||||
final Composition composition;
|
final Composite composite;
|
||||||
if ( attribute == null ) {
|
if ( attribute == null ) {
|
||||||
composition = new Composition(
|
composite = new Composite(
|
||||||
attributeSource.getPath(),
|
attributeSource.getPath(),
|
||||||
attributeSource.getClassName(),
|
attributeSource.getClassName(),
|
||||||
attributeSource.getClassReference(),
|
attributeSource.getClassReference(),
|
||||||
null // composition inheritance not YET supported
|
null // composition inheritance not YET supported
|
||||||
);
|
);
|
||||||
attribute = container.getAttributeContainer().createCompositionAttribute( attributeName, composition );
|
attribute = container.getAttributeContainer().createCompositeAttribute( attributeName, composite );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
composition = (Composition) attribute.getSingularAttributeType();
|
composite = (Composite) attribute.getSingularAttributeType();
|
||||||
}
|
}
|
||||||
|
|
||||||
final String propertyAccessorName = Helper.getPropertyAccessorName(
|
final String propertyAccessorName = Helper.getPropertyAccessorName(
|
||||||
|
@ -845,13 +845,13 @@ public class Binder {
|
||||||
|
|
||||||
final SingularAttribute parentReferenceAttribute;
|
final SingularAttribute parentReferenceAttribute;
|
||||||
if ( StringHelper.isNotEmpty( attributeSource.getParentReferenceAttributeName() ) ) {
|
if ( StringHelper.isNotEmpty( attributeSource.getParentReferenceAttributeName() ) ) {
|
||||||
parentReferenceAttribute = composition.createSingularAttribute( attributeSource.getParentReferenceAttributeName() );
|
parentReferenceAttribute = composite.createSingularAttribute( attributeSource.getParentReferenceAttributeName() );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
parentReferenceAttribute = null;
|
parentReferenceAttribute = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
CompositionAttributeBinding compositionAttributeBinding = container.makeComponentAttributeBinding(
|
CompositeAttributeBinding compositeAttributeBinding = container.makeComponentAttributeBinding(
|
||||||
attribute,
|
attribute,
|
||||||
parentReferenceAttribute,
|
parentReferenceAttribute,
|
||||||
propertyAccessorName,
|
propertyAccessorName,
|
||||||
|
@ -860,7 +860,7 @@ public class Binder {
|
||||||
metaAttributeContext
|
metaAttributeContext
|
||||||
);
|
);
|
||||||
|
|
||||||
bindAttributes( attributeSource, compositionAttributeBinding, tableStack );
|
bindAttributes( attributeSource, compositeAttributeBinding, tableStack );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bindPersistentCollection(
|
private void bindPersistentCollection(
|
||||||
|
|
|
@ -39,7 +39,7 @@ import org.hibernate.metamodel.spi.binding.AbstractPluralAttributeBinding;
|
||||||
import org.hibernate.metamodel.spi.binding.AttributeBinding;
|
import org.hibernate.metamodel.spi.binding.AttributeBinding;
|
||||||
import org.hibernate.metamodel.spi.binding.BasicAttributeBinding;
|
import org.hibernate.metamodel.spi.binding.BasicAttributeBinding;
|
||||||
import org.hibernate.metamodel.spi.binding.BasicPluralAttributeElementBinding;
|
import org.hibernate.metamodel.spi.binding.BasicPluralAttributeElementBinding;
|
||||||
import org.hibernate.metamodel.spi.binding.CompositionAttributeBinding;
|
import org.hibernate.metamodel.spi.binding.CompositeAttributeBinding;
|
||||||
import org.hibernate.metamodel.spi.binding.HibernateTypeDescriptor;
|
import org.hibernate.metamodel.spi.binding.HibernateTypeDescriptor;
|
||||||
import org.hibernate.metamodel.spi.binding.IndexedPluralAttributeBinding;
|
import org.hibernate.metamodel.spi.binding.IndexedPluralAttributeBinding;
|
||||||
import org.hibernate.metamodel.spi.binding.PluralAttributeBinding;
|
import org.hibernate.metamodel.spi.binding.PluralAttributeBinding;
|
||||||
|
@ -305,9 +305,9 @@ public class HibernateTypeHelper {
|
||||||
resolvedHibernateType
|
resolvedHibernateType
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if ( CompositionAttributeBinding.class.isInstance( attributeBinding ) ) {
|
else if ( CompositeAttributeBinding.class.isInstance( attributeBinding ) ) {
|
||||||
pushHibernateTypeInformationDown(
|
pushHibernateTypeInformationDown(
|
||||||
(CompositionAttributeBinding) attributeBinding,
|
(CompositeAttributeBinding) attributeBinding,
|
||||||
resolvedHibernateType
|
resolvedHibernateType
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -330,7 +330,7 @@ public class HibernateTypeHelper {
|
||||||
|
|
||||||
@SuppressWarnings( {"UnusedParameters"})
|
@SuppressWarnings( {"UnusedParameters"})
|
||||||
private void pushHibernateTypeInformationDown(
|
private void pushHibernateTypeInformationDown(
|
||||||
CompositionAttributeBinding attributeBinding,
|
CompositeAttributeBinding attributeBinding,
|
||||||
Type resolvedHibernateType) {
|
Type resolvedHibernateType) {
|
||||||
final HibernateTypeDescriptor hibernateTypeDescriptor = attributeBinding.getHibernateTypeDescriptor();
|
final HibernateTypeDescriptor hibernateTypeDescriptor = attributeBinding.getHibernateTypeDescriptor();
|
||||||
final SingularAttribute singularAttribute = SingularAttribute.class.cast( attributeBinding.getAttribute() );
|
final SingularAttribute singularAttribute = SingularAttribute.class.cast( attributeBinding.getAttribute() );
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.hibernate.metamodel.spi.domain.SingularAttribute;
|
||||||
import org.hibernate.metamodel.spi.source.MetaAttributeContext;
|
import org.hibernate.metamodel.spi.source.MetaAttributeContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common contract for {@link EntityBinding} and {@link CompositionAttributeBinding} 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
|
* containers for {@link AttributeBinding} descriptors
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
|
@ -92,7 +92,7 @@ public interface AttributeBindingContainer {
|
||||||
*
|
*
|
||||||
* @return The attribute binding instance.
|
* @return The attribute binding instance.
|
||||||
*/
|
*/
|
||||||
public CompositionAttributeBinding makeComponentAttributeBinding(
|
public CompositeAttributeBinding makeComponentAttributeBinding(
|
||||||
SingularAttribute attribute,
|
SingularAttribute attribute,
|
||||||
SingularAttribute parentReferenceAttribute,
|
SingularAttribute parentReferenceAttribute,
|
||||||
String propertyAccessorName,
|
String propertyAccessorName,
|
||||||
|
|
|
@ -31,7 +31,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.hibernate.mapping.PropertyGeneration;
|
import org.hibernate.mapping.PropertyGeneration;
|
||||||
import org.hibernate.metamodel.spi.domain.AttributeContainer;
|
import org.hibernate.metamodel.spi.domain.AttributeContainer;
|
||||||
import org.hibernate.metamodel.spi.domain.Composition;
|
import org.hibernate.metamodel.spi.domain.Composite;
|
||||||
import org.hibernate.metamodel.spi.domain.PluralAttribute;
|
import org.hibernate.metamodel.spi.domain.PluralAttribute;
|
||||||
import org.hibernate.metamodel.spi.domain.PluralAttributeNature;
|
import org.hibernate.metamodel.spi.domain.PluralAttributeNature;
|
||||||
import org.hibernate.metamodel.spi.domain.SingularAttribute;
|
import org.hibernate.metamodel.spi.domain.SingularAttribute;
|
||||||
|
@ -40,14 +40,14 @@ import org.hibernate.metamodel.spi.source.MetaAttributeContext;
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class CompositionAttributeBinding
|
public class CompositeAttributeBinding
|
||||||
extends AbstractSingularAttributeBinding
|
extends AbstractSingularAttributeBinding
|
||||||
implements AttributeBindingContainer {
|
implements AttributeBindingContainer {
|
||||||
private final String path;
|
private final String path;
|
||||||
private final SingularAttribute parentReference;
|
private final SingularAttribute parentReference;
|
||||||
private Map<String, AttributeBinding> attributeBindingMap = new HashMap<String, AttributeBinding>();
|
private Map<String, AttributeBinding> attributeBindingMap = new HashMap<String, AttributeBinding>();
|
||||||
|
|
||||||
public CompositionAttributeBinding(
|
public CompositeAttributeBinding(
|
||||||
AttributeBindingContainer container,
|
AttributeBindingContainer container,
|
||||||
SingularAttribute attribute,
|
SingularAttribute attribute,
|
||||||
String propertyAccessorName,
|
String propertyAccessorName,
|
||||||
|
@ -98,8 +98,8 @@ public class CompositionAttributeBinding
|
||||||
return getComponent();
|
return getComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Composition getComponent() {
|
public Composite getComponent() {
|
||||||
return (Composition) getAttribute().getSingularAttributeType();
|
return (Composite) getAttribute().getSingularAttributeType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -158,14 +158,14 @@ public class CompositionAttributeBinding
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompositionAttributeBinding makeComponentAttributeBinding(
|
public CompositeAttributeBinding makeComponentAttributeBinding(
|
||||||
SingularAttribute attribute,
|
SingularAttribute attribute,
|
||||||
SingularAttribute parentReferenceAttribute,
|
SingularAttribute parentReferenceAttribute,
|
||||||
String propertyAccessorName,
|
String propertyAccessorName,
|
||||||
boolean includedInOptimisticLocking,
|
boolean includedInOptimisticLocking,
|
||||||
boolean lazy,
|
boolean lazy,
|
||||||
MetaAttributeContext metaAttributeContext) {
|
MetaAttributeContext metaAttributeContext) {
|
||||||
final CompositionAttributeBinding binding = new CompositionAttributeBinding(
|
final CompositeAttributeBinding binding = new CompositeAttributeBinding(
|
||||||
this,
|
this,
|
||||||
attribute,
|
attribute,
|
||||||
propertyAccessorName,
|
propertyAccessorName,
|
|
@ -512,14 +512,14 @@ public class EntityBinding implements AttributeBindingContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompositionAttributeBinding makeComponentAttributeBinding(
|
public CompositeAttributeBinding makeComponentAttributeBinding(
|
||||||
SingularAttribute attribute,
|
SingularAttribute attribute,
|
||||||
SingularAttribute parentReferenceAttribute,
|
SingularAttribute parentReferenceAttribute,
|
||||||
String propertyAccessorName,
|
String propertyAccessorName,
|
||||||
boolean includedInOptimisticLocking,
|
boolean includedInOptimisticLocking,
|
||||||
boolean lazy,
|
boolean lazy,
|
||||||
MetaAttributeContext metaAttributeContext) {
|
MetaAttributeContext metaAttributeContext) {
|
||||||
final CompositionAttributeBinding binding = new CompositionAttributeBinding(
|
final CompositeAttributeBinding binding = new CompositeAttributeBinding(
|
||||||
this,
|
this,
|
||||||
attribute,
|
attribute,
|
||||||
propertyAccessorName,
|
propertyAccessorName,
|
||||||
|
|
|
@ -112,14 +112,14 @@ public abstract class AbstractAttributeContainer implements AttributeContainer,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SingularAttribute locateCompositionAttribute(String name) {
|
public SingularAttribute locateCompositeAttribute(String name) {
|
||||||
return (SingularAttributeImpl) locateAttribute( name );
|
return (SingularAttributeImpl) locateAttribute( name );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SingularAttribute createCompositionAttribute(String name, Composition composition) {
|
public SingularAttribute createCompositeAttribute(String name, Composite composite) {
|
||||||
SingularAttributeImpl attribute = new SingularAttributeImpl( name, this );
|
SingularAttributeImpl attribute = new SingularAttributeImpl( name, this );
|
||||||
attribute.resolveType( composition );
|
attribute.resolveType( composite );
|
||||||
addAttribute( attribute );
|
addAttribute( attribute );
|
||||||
return attribute;
|
return attribute;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,8 +62,8 @@ public interface AttributeContainer extends Type {
|
||||||
public SingularAttribute createSingularAttribute(String name);
|
public SingularAttribute createSingularAttribute(String name);
|
||||||
public SingularAttribute createVirtualSingularAttribute(String name);
|
public SingularAttribute createVirtualSingularAttribute(String name);
|
||||||
|
|
||||||
public SingularAttribute locateCompositionAttribute(String name);
|
public SingularAttribute locateCompositeAttribute(String name);
|
||||||
public SingularAttribute createCompositionAttribute(String name, Composition composition);
|
public SingularAttribute createCompositeAttribute(String name, Composite composite);
|
||||||
|
|
||||||
public PluralAttribute locatePluralAttribute(String name);
|
public PluralAttribute locatePluralAttribute(String name);
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,8 @@ import org.hibernate.internal.util.Value;
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class Composition extends AbstractAttributeContainer {
|
public class Composite extends AbstractAttributeContainer {
|
||||||
public Composition(String name, String className, Value<Class<?>> classReference, Hierarchical superType) {
|
public Composite(String name, String className, Value<Class<?>> classReference, Hierarchical superType) {
|
||||||
super( name, className, classReference, superType );
|
super( name, className, classReference, superType );
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ import org.hibernate.metamodel.spi.binding.AttributeBinding;
|
||||||
import org.hibernate.metamodel.spi.binding.BasicAttributeBinding;
|
import org.hibernate.metamodel.spi.binding.BasicAttributeBinding;
|
||||||
import org.hibernate.metamodel.spi.binding.EntityBinding;
|
import org.hibernate.metamodel.spi.binding.EntityBinding;
|
||||||
import org.hibernate.metamodel.spi.domain.Attribute;
|
import org.hibernate.metamodel.spi.domain.Attribute;
|
||||||
import org.hibernate.metamodel.spi.domain.Composition;
|
import org.hibernate.metamodel.spi.domain.Composite;
|
||||||
import org.hibernate.metamodel.spi.domain.SingularAttribute;
|
import org.hibernate.metamodel.spi.domain.SingularAttribute;
|
||||||
import org.hibernate.tuple.IdentifierProperty;
|
import org.hibernate.tuple.IdentifierProperty;
|
||||||
import org.hibernate.tuple.PropertyFactory;
|
import org.hibernate.tuple.PropertyFactory;
|
||||||
|
@ -608,8 +608,8 @@ public class EntityMetamodel implements Serializable {
|
||||||
return ValueInclusion.FULL;
|
return ValueInclusion.FULL;
|
||||||
}
|
}
|
||||||
// TODO: fix the following when components are working (HHH-6173)
|
// TODO: fix the following when components are working (HHH-6173)
|
||||||
//else if ( mappingProperty.getValue() instanceof CompositionAttributeBinding ) {
|
//else if ( mappingProperty.getValue() instanceof CompositeAttributeBinding ) {
|
||||||
// if ( hasPartialInsertComponentGeneration( ( CompositionAttributeBinding ) mappingProperty.getValue() ) ) {
|
// if ( hasPartialInsertComponentGeneration( ( CompositeAttributeBinding ) mappingProperty.getValue() ) ) {
|
||||||
// return ValueInclusion.PARTIAL;
|
// return ValueInclusion.PARTIAL;
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
@ -649,8 +649,8 @@ public class EntityMetamodel implements Serializable {
|
||||||
return ValueInclusion.FULL;
|
return ValueInclusion.FULL;
|
||||||
}
|
}
|
||||||
// TODO: fix the following when components are working (HHH-6173)
|
// TODO: fix the following when components are working (HHH-6173)
|
||||||
//else if ( mappingProperty.getValue() instanceof CompositionAttributeBinding ) {
|
//else if ( mappingProperty.getValue() instanceof CompositeAttributeBinding ) {
|
||||||
// if ( hasPartialUpdateComponentGeneration( ( CompositionAttributeBinding ) mappingProperty.getValue() ) ) {
|
// if ( hasPartialUpdateComponentGeneration( ( CompositeAttributeBinding ) mappingProperty.getValue() ) ) {
|
||||||
// return ValueInclusion.PARTIAL;
|
// return ValueInclusion.PARTIAL;
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
@ -691,9 +691,9 @@ public class EntityMetamodel implements Serializable {
|
||||||
propertyIndexes.put( attribute.getName(), i );
|
propertyIndexes.put( attribute.getName(), i );
|
||||||
if ( attribute.isSingular() &&
|
if ( attribute.isSingular() &&
|
||||||
( ( SingularAttribute ) attribute ).getSingularAttributeType().isComponent() ) {
|
( ( SingularAttribute ) attribute ).getSingularAttributeType().isComponent() ) {
|
||||||
Composition composition =
|
Composite composite =
|
||||||
(Composition) ( (SingularAttribute) attribute ).getSingularAttributeType();
|
(Composite) ( (SingularAttribute) attribute ).getSingularAttributeType();
|
||||||
for ( Attribute subAttribute : composition.attributes() ) {
|
for ( Attribute subAttribute : composite.attributes() ) {
|
||||||
propertyIndexes.put(
|
propertyIndexes.put(
|
||||||
attribute.getName() + '.' + subAttribute.getName(),
|
attribute.getName() + '.' + subAttribute.getName(),
|
||||||
i
|
i
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class Atmosphere {
|
||||||
@ElementCollection
|
@ElementCollection
|
||||||
@Column(name="composition_rate")
|
@Column(name="composition_rate")
|
||||||
@MapKeyJoinColumns( { @MapKeyJoinColumn(name="gas_id" ) } ) //use @MapKeyJoinColumns explicitly for tests
|
@MapKeyJoinColumns( { @MapKeyJoinColumn(name="gas_id" ) } ) //use @MapKeyJoinColumns explicitly for tests
|
||||||
@JoinTable(name = "Composition", joinColumns = @JoinColumn(name = "atmosphere_id"))
|
@JoinTable(name = "Composite", joinColumns = @JoinColumn(name = "atmosphere_id"))
|
||||||
public Map<Gas, Double> composition = new HashMap<Gas, Double>();
|
public Map<Gas, Double> composition = new HashMap<Gas, Double>();
|
||||||
|
|
||||||
//use default JPA 2 column name for map key
|
//use default JPA 2 column name for map key
|
||||||
|
|
|
@ -34,7 +34,7 @@ import javax.persistence.Id;
|
||||||
import org.hibernate.annotations.Parent;
|
import org.hibernate.annotations.Parent;
|
||||||
import org.hibernate.annotations.Target;
|
import org.hibernate.annotations.Target;
|
||||||
import org.hibernate.metamodel.spi.binding.BasicAttributeBinding;
|
import org.hibernate.metamodel.spi.binding.BasicAttributeBinding;
|
||||||
import org.hibernate.metamodel.spi.binding.CompositionAttributeBinding;
|
import org.hibernate.metamodel.spi.binding.CompositeAttributeBinding;
|
||||||
import org.hibernate.metamodel.spi.binding.EntityBinding;
|
import org.hibernate.metamodel.spi.binding.EntityBinding;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -72,8 +72,8 @@ public class EmbeddableBindingTest extends BaseAnnotationBindingTestCase {
|
||||||
|
|
||||||
final String componentName = "phone";
|
final String componentName = "phone";
|
||||||
assertNotNull( binding.locateAttributeBinding( componentName ) );
|
assertNotNull( binding.locateAttributeBinding( componentName ) );
|
||||||
assertTrue( binding.locateAttributeBinding( componentName ) instanceof CompositionAttributeBinding );
|
assertTrue( binding.locateAttributeBinding( componentName ) instanceof CompositeAttributeBinding );
|
||||||
CompositionAttributeBinding compositionBinding = (CompositionAttributeBinding) binding.locateAttributeBinding(
|
CompositeAttributeBinding compositeBinding = (CompositeAttributeBinding) binding.locateAttributeBinding(
|
||||||
componentName
|
componentName
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -81,12 +81,12 @@ public class EmbeddableBindingTest extends BaseAnnotationBindingTestCase {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Wrong path",
|
"Wrong path",
|
||||||
EmbeddableBindingTest.User.class.getName() + ".phone",
|
EmbeddableBindingTest.User.class.getName() + ".phone",
|
||||||
compositionBinding.getPathBase()
|
compositeBinding.getPathBase()
|
||||||
);
|
);
|
||||||
|
|
||||||
assertNotNull( compositionBinding.locateAttributeBinding( "countryCode" ) );
|
assertNotNull( compositeBinding.locateAttributeBinding( "countryCode" ) );
|
||||||
assertNotNull( compositionBinding.locateAttributeBinding( "areaCode" ) );
|
assertNotNull( compositeBinding.locateAttributeBinding( "areaCode" ) );
|
||||||
assertNotNull( compositionBinding.locateAttributeBinding( "number" ) );
|
assertNotNull( compositeBinding.locateAttributeBinding( "number" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -113,13 +113,13 @@ public class EmbeddableBindingTest extends BaseAnnotationBindingTestCase {
|
||||||
|
|
||||||
final String componentName = "embedded";
|
final String componentName = "embedded";
|
||||||
assertNotNull( binding.locateAttributeBinding( componentName ) );
|
assertNotNull( binding.locateAttributeBinding( componentName ) );
|
||||||
assertTrue( binding.locateAttributeBinding( componentName ) instanceof CompositionAttributeBinding );
|
assertTrue( binding.locateAttributeBinding( componentName ) instanceof CompositeAttributeBinding );
|
||||||
CompositionAttributeBinding compositionBinding = (CompositionAttributeBinding) binding.locateAttributeBinding(
|
CompositeAttributeBinding compositeBinding = (CompositeAttributeBinding) binding.locateAttributeBinding(
|
||||||
componentName
|
componentName
|
||||||
);
|
);
|
||||||
|
|
||||||
assertNotNull( compositionBinding.locateAttributeBinding( "name" ) );
|
assertNotNull( compositeBinding.locateAttributeBinding( "name" ) );
|
||||||
BasicAttributeBinding nameAttribute = (BasicAttributeBinding) compositionBinding.locateAttributeBinding( "name" );
|
BasicAttributeBinding nameAttribute = (BasicAttributeBinding) compositeBinding.locateAttributeBinding( "name" );
|
||||||
assertEquals( 1, nameAttribute.getRelationalValueBindings().size() );
|
assertEquals( 1, nameAttribute.getRelationalValueBindings().size() );
|
||||||
org.hibernate.metamodel.spi.relational.Column column
|
org.hibernate.metamodel.spi.relational.Column column
|
||||||
= (org.hibernate.metamodel.spi.relational.Column) nameAttribute.getRelationalValueBindings().get( 0 ).getValue();
|
= (org.hibernate.metamodel.spi.relational.Column) nameAttribute.getRelationalValueBindings().get( 0 ).getValue();
|
||||||
|
@ -168,16 +168,16 @@ public class EmbeddableBindingTest extends BaseAnnotationBindingTestCase {
|
||||||
|
|
||||||
final String addressComponentName = "address";
|
final String addressComponentName = "address";
|
||||||
assertNotNull( binding.locateAttributeBinding( addressComponentName ) );
|
assertNotNull( binding.locateAttributeBinding( addressComponentName ) );
|
||||||
assertTrue( binding.locateAttributeBinding( addressComponentName ) instanceof CompositionAttributeBinding );
|
assertTrue( binding.locateAttributeBinding( addressComponentName ) instanceof CompositeAttributeBinding );
|
||||||
CompositionAttributeBinding attributeCompositionBinding = (CompositionAttributeBinding) binding.locateAttributeBinding(
|
CompositeAttributeBinding attributeCompositeBinding = (CompositeAttributeBinding) binding.locateAttributeBinding(
|
||||||
addressComponentName
|
addressComponentName
|
||||||
);
|
);
|
||||||
|
|
||||||
assertNotNull( attributeCompositionBinding.locateAttributeBinding( "street" ) );
|
assertNotNull( attributeCompositeBinding.locateAttributeBinding( "street" ) );
|
||||||
assertNotNull( attributeCompositionBinding.locateAttributeBinding( "city" ) );
|
assertNotNull( attributeCompositeBinding.locateAttributeBinding( "city" ) );
|
||||||
assertNotNull( attributeCompositionBinding.locateAttributeBinding( "state" ) );
|
assertNotNull( attributeCompositeBinding.locateAttributeBinding( "state" ) );
|
||||||
|
|
||||||
BasicAttributeBinding stateAttribute = (BasicAttributeBinding) attributeCompositionBinding.locateAttributeBinding(
|
BasicAttributeBinding stateAttribute = (BasicAttributeBinding) attributeCompositeBinding.locateAttributeBinding(
|
||||||
"state"
|
"state"
|
||||||
);
|
);
|
||||||
assertEquals( 1, stateAttribute.getRelationalValueBindings().size() );
|
assertEquals( 1, stateAttribute.getRelationalValueBindings().size() );
|
||||||
|
@ -191,13 +191,13 @@ public class EmbeddableBindingTest extends BaseAnnotationBindingTestCase {
|
||||||
|
|
||||||
|
|
||||||
final String zipComponentName = "zipcode";
|
final String zipComponentName = "zipcode";
|
||||||
assertNotNull( attributeCompositionBinding.locateAttributeBinding( zipComponentName ) );
|
assertNotNull( attributeCompositeBinding.locateAttributeBinding( zipComponentName ) );
|
||||||
assertTrue( attributeCompositionBinding.locateAttributeBinding( zipComponentName ) instanceof CompositionAttributeBinding );
|
assertTrue( attributeCompositeBinding.locateAttributeBinding( zipComponentName ) instanceof CompositeAttributeBinding );
|
||||||
CompositionAttributeBinding zipCompositionBinding = (CompositionAttributeBinding) attributeCompositionBinding.locateAttributeBinding(
|
CompositeAttributeBinding zipCompositeBinding = (CompositeAttributeBinding) attributeCompositeBinding.locateAttributeBinding(
|
||||||
zipComponentName
|
zipComponentName
|
||||||
);
|
);
|
||||||
|
|
||||||
BasicAttributeBinding nameAttribute = (BasicAttributeBinding) zipCompositionBinding.locateAttributeBinding( "zip" );
|
BasicAttributeBinding nameAttribute = (BasicAttributeBinding) zipCompositeBinding.locateAttributeBinding( "zip" );
|
||||||
assertEquals( 1, nameAttribute.getRelationalValueBindings().size() );
|
assertEquals( 1, nameAttribute.getRelationalValueBindings().size() );
|
||||||
column = (org.hibernate.metamodel.spi.relational.Column) nameAttribute.getRelationalValueBindings().get( 0 ).getValue();
|
column = (org.hibernate.metamodel.spi.relational.Column) nameAttribute.getRelationalValueBindings().get( 0 ).getValue();
|
||||||
assertEquals(
|
assertEquals(
|
||||||
|
@ -262,19 +262,19 @@ public class EmbeddableBindingTest extends BaseAnnotationBindingTestCase {
|
||||||
|
|
||||||
final String aComponentName = "a";
|
final String aComponentName = "a";
|
||||||
assertNotNull( binding.locateAttributeBinding( aComponentName ) );
|
assertNotNull( binding.locateAttributeBinding( aComponentName ) );
|
||||||
assertTrue( binding.locateAttributeBinding( aComponentName ) instanceof CompositionAttributeBinding );
|
assertTrue( binding.locateAttributeBinding( aComponentName ) instanceof CompositeAttributeBinding );
|
||||||
CompositionAttributeBinding aCompositionBinding = (CompositionAttributeBinding) binding.locateAttributeBinding(
|
CompositeAttributeBinding aCompositeBinding = (CompositeAttributeBinding) binding.locateAttributeBinding(
|
||||||
aComponentName
|
aComponentName
|
||||||
);
|
);
|
||||||
|
|
||||||
final String bComponentName = "b";
|
final String bComponentName = "b";
|
||||||
assertNotNull( aCompositionBinding.locateAttributeBinding( bComponentName ) );
|
assertNotNull( aCompositeBinding.locateAttributeBinding( bComponentName ) );
|
||||||
assertTrue( aCompositionBinding.locateAttributeBinding( bComponentName ) instanceof CompositionAttributeBinding );
|
assertTrue( aCompositeBinding.locateAttributeBinding( bComponentName ) instanceof CompositeAttributeBinding );
|
||||||
CompositionAttributeBinding bCompositionBinding = (CompositionAttributeBinding) aCompositionBinding.locateAttributeBinding(
|
CompositeAttributeBinding bCompositeBinding = (CompositeAttributeBinding) aCompositeBinding.locateAttributeBinding(
|
||||||
bComponentName
|
bComponentName
|
||||||
);
|
);
|
||||||
|
|
||||||
BasicAttributeBinding attribute = (BasicAttributeBinding) bCompositionBinding.locateAttributeBinding( "foo" );
|
BasicAttributeBinding attribute = (BasicAttributeBinding) bCompositeBinding.locateAttributeBinding( "foo" );
|
||||||
assertEquals( 1, attribute.getRelationalValueBindings().size() );
|
assertEquals( 1, attribute.getRelationalValueBindings().size() );
|
||||||
org.hibernate.metamodel.spi.relational.Column column
|
org.hibernate.metamodel.spi.relational.Column column
|
||||||
= (org.hibernate.metamodel.spi.relational.Column) attribute.getRelationalValueBindings().get( 0 ).getValue();
|
= (org.hibernate.metamodel.spi.relational.Column) attribute.getRelationalValueBindings().get( 0 ).getValue();
|
||||||
|
@ -284,7 +284,7 @@ public class EmbeddableBindingTest extends BaseAnnotationBindingTestCase {
|
||||||
column.getColumnName().getName()
|
column.getColumnName().getName()
|
||||||
);
|
);
|
||||||
|
|
||||||
attribute = (BasicAttributeBinding) bCompositionBinding.locateAttributeBinding( "fubar" );
|
attribute = (BasicAttributeBinding) bCompositeBinding.locateAttributeBinding( "fubar" );
|
||||||
assertEquals( 1, attribute.getRelationalValueBindings().size() );
|
assertEquals( 1, attribute.getRelationalValueBindings().size() );
|
||||||
column = (org.hibernate.metamodel.spi.relational.Column) attribute.getRelationalValueBindings().get( 0 ).getValue();
|
column = (org.hibernate.metamodel.spi.relational.Column) attribute.getRelationalValueBindings().get( 0 ).getValue();
|
||||||
assertEquals(
|
assertEquals(
|
||||||
|
@ -319,12 +319,12 @@ public class EmbeddableBindingTest extends BaseAnnotationBindingTestCase {
|
||||||
|
|
||||||
final String componentName = "embedded";
|
final String componentName = "embedded";
|
||||||
assertNotNull( binding.locateAttributeBinding( componentName ) );
|
assertNotNull( binding.locateAttributeBinding( componentName ) );
|
||||||
assertTrue( binding.locateAttributeBinding( componentName ) instanceof CompositionAttributeBinding );
|
assertTrue( binding.locateAttributeBinding( componentName ) instanceof CompositeAttributeBinding );
|
||||||
CompositionAttributeBinding compositionBinding = (CompositionAttributeBinding) binding.locateAttributeBinding(
|
CompositeAttributeBinding compositeBinding = (CompositeAttributeBinding) binding.locateAttributeBinding(
|
||||||
componentName
|
componentName
|
||||||
);
|
);
|
||||||
|
|
||||||
assertEquals( "Wrong parent reference name", "parent", compositionBinding.getParentReference().getName() );
|
assertEquals( "Wrong parent reference name", "parent", compositeBinding.getParentReference().getName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -365,12 +365,12 @@ public class EmbeddableBindingTest extends BaseAnnotationBindingTestCase {
|
||||||
|
|
||||||
final String componentName = "car";
|
final String componentName = "car";
|
||||||
assertNotNull( binding.locateAttributeBinding( componentName ) );
|
assertNotNull( binding.locateAttributeBinding( componentName ) );
|
||||||
assertTrue( binding.locateAttributeBinding( componentName ) instanceof CompositionAttributeBinding );
|
assertTrue( binding.locateAttributeBinding( componentName ) instanceof CompositeAttributeBinding );
|
||||||
CompositionAttributeBinding compositionBinding = (CompositionAttributeBinding) binding.locateAttributeBinding(
|
CompositeAttributeBinding compositeBinding = (CompositeAttributeBinding) binding.locateAttributeBinding(
|
||||||
componentName
|
componentName
|
||||||
);
|
);
|
||||||
|
|
||||||
BasicAttributeBinding attribute = (BasicAttributeBinding) compositionBinding.locateAttributeBinding( "horsePower" );
|
BasicAttributeBinding attribute = (BasicAttributeBinding) compositeBinding.locateAttributeBinding( "horsePower" );
|
||||||
assertTrue( attribute.getAttribute().isTypeResolved() );
|
assertTrue( attribute.getAttribute().isTypeResolved() );
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Wrong resolved type",
|
"Wrong resolved type",
|
||||||
|
|
|
@ -137,12 +137,12 @@ public abstract class AbstractBasicBindingTests extends BaseUnitTestCase {
|
||||||
assertRoot( metadata, entityBinding );
|
assertRoot( metadata, entityBinding );
|
||||||
assertIdAndSimpleProperty( entityBinding );
|
assertIdAndSimpleProperty( entityBinding );
|
||||||
|
|
||||||
CompositionAttributeBinding compositionAttributeBinding = (CompositionAttributeBinding) entityBinding.locateAttributeBinding( "simpleComponent" );
|
CompositeAttributeBinding compositeAttributeBinding = (CompositeAttributeBinding) entityBinding.locateAttributeBinding( "simpleComponent" );
|
||||||
assertNotNull( compositionAttributeBinding );
|
assertNotNull( compositeAttributeBinding );
|
||||||
assertSame( compositionAttributeBinding.getAttribute().getSingularAttributeType(), compositionAttributeBinding.getAttributeContainer() );
|
assertSame( compositeAttributeBinding.getAttribute().getSingularAttributeType(), compositeAttributeBinding.getAttributeContainer() );
|
||||||
assertEquals( SimpleEntityWithSimpleComponent.class.getName() + ".simpleComponent", compositionAttributeBinding.getPathBase() );
|
assertEquals( SimpleEntityWithSimpleComponent.class.getName() + ".simpleComponent", compositeAttributeBinding.getPathBase() );
|
||||||
assertSame( entityBinding, compositionAttributeBinding.seekEntityBinding() );
|
assertSame( entityBinding, compositeAttributeBinding.seekEntityBinding() );
|
||||||
assertNotNull( compositionAttributeBinding.getComponent() );
|
assertNotNull( compositeAttributeBinding.getComponent() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void addSourcesForSimpleVersionedEntityBinding(MetadataSources sources);
|
public abstract void addSourcesForSimpleVersionedEntityBinding(MetadataSources sources);
|
||||||
|
|
Loading…
Reference in New Issue