Skip to content

Commit

Permalink
HHH-7702 : Add support for collections of (aggregated) composite elem…
Browse files Browse the repository at this point in the history
…ents
  • Loading branch information
gbadner committed Nov 8, 2012
1 parent 84f65d4 commit fc66ca5
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 26 deletions.
Expand Up @@ -520,7 +520,10 @@ private void bindCompositeCollectionElement(
final CompositeAttributeBindingContainer compositeAttributeBindingContainer =
elementBinding.createCompositeAttributeBindingContainer(
aggregate,
pluralAttributeBinding.getMetaAttributeContext(), // TODO: should get this from elementSource
createMetaAttributeContext(
pluralAttributeBinding.getContainer(),
elementSource.getMetaAttributeSources()
),
parentAttribute
);

Expand Down
Expand Up @@ -100,22 +100,22 @@ private PluralAttributeElementSource interpretElementType() {
else if ( pluralAttributeElement.getCompositeElement() != null ) {
return new CompositePluralAttributeElementSourceImpl(
sourceMappingDocument(),
pluralAttributeElement,
pluralAttributeElement.getCompositeElement()
pluralAttributeElement.getCompositeElement(),
pluralAttributeElement.getCascade()
);
}
else if ( pluralAttributeElement.getOneToMany() != null ) {
return new OneToManyPluralAttributeElementSourceImpl(
sourceMappingDocument(),
pluralAttributeElement,
pluralAttributeElement.getOneToMany()
pluralAttributeElement.getOneToMany(),
pluralAttributeElement.getCascade()
);
}
else if ( pluralAttributeElement.getManyToMany() != null ) {
return new ManyToManyPluralAttributeElementSourceImpl(
sourceMappingDocument(),
pluralAttributeElement,
pluralAttributeElement.getManyToMany()
pluralAttributeElement.getManyToMany(),
pluralAttributeElement.getCascade()
);
}
else if ( pluralAttributeElement.getManyToAny() != null ) {
Expand Down
Expand Up @@ -37,11 +37,11 @@
import org.hibernate.jaxb.spi.hbm.JaxbNestedCompositeElementElement;
import org.hibernate.jaxb.spi.hbm.JaxbPropertyElement;
import org.hibernate.jaxb.spi.hbm.JaxbTuplizerElement;
import org.hibernate.jaxb.spi.hbm.PluralAttributeElement;
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
import org.hibernate.metamodel.spi.source.AttributeSource;
import org.hibernate.metamodel.spi.source.CompositePluralAttributeElementSource;
import org.hibernate.metamodel.spi.source.LocalBindingContext;
import org.hibernate.metamodel.spi.source.MetaAttributeSource;
import org.hibernate.metamodel.spi.source.SingularAttributeSource;

/**
Expand All @@ -52,17 +52,17 @@ public class CompositePluralAttributeElementSourceImpl
extends AbstractHbmSourceNode
implements CompositePluralAttributeElementSource {

private final PluralAttributeElement pluralAttributeElement;
private final JaxbCompositeElementElement compositeElement;
private final Iterable<CascadeStyle> cascadeStyles;
private final List<AttributeSource> attributeSources;

public CompositePluralAttributeElementSourceImpl(
MappingDocument mappingDocument,
PluralAttributeElement pluralAttributeElement,
JaxbCompositeElementElement compositeElement) {
JaxbCompositeElementElement compositeElement,
String cascadeString) {
super( mappingDocument );
this.pluralAttributeElement = pluralAttributeElement;
this.compositeElement = compositeElement;
this.cascadeStyles = Helper.interpretCascadeStyles( cascadeString, bindingContext() );
this.attributeSources = buildAttributeSources( mappingDocument, compositeElement );
}

Expand Down Expand Up @@ -139,7 +139,7 @@ public LocalBindingContext getLocalBindingContext() {

@Override
public Iterable<CascadeStyle> getCascadeStyles() {
return Helper.interpretCascadeStyles( pluralAttributeElement.getCascade(), bindingContext() );
return cascadeStyles;
}

private static AttributeSource buildAttributeSource(
Expand Down Expand Up @@ -178,4 +178,8 @@ private static AttributeSource buildAttributeSource(
throw new NotYetImplementedException();
}

@Override
public Iterable<? extends MetaAttributeSource> getMetaAttributeSources() {
return compositeElement.getMeta();
}
}
Expand Up @@ -31,7 +31,6 @@
import org.hibernate.internal.util.StringHelper;
import org.hibernate.jaxb.spi.hbm.JaxbColumnElement;
import org.hibernate.jaxb.spi.hbm.JaxbManyToManyElement;
import org.hibernate.jaxb.spi.hbm.PluralAttributeElement;
import org.hibernate.metamodel.spi.source.ManyToManyPluralAttributeElementSource;
import org.hibernate.metamodel.spi.source.RelationalValueSource;

Expand All @@ -41,18 +40,18 @@
public class ManyToManyPluralAttributeElementSourceImpl
extends AbstractHbmSourceNode
implements ManyToManyPluralAttributeElementSource {
private final PluralAttributeElement pluralAttributeElement;
private final JaxbManyToManyElement manyToManyElement;
private final Iterable<CascadeStyle> cascadeStyles;

private final List<RelationalValueSource> valueSources;

public ManyToManyPluralAttributeElementSourceImpl(
MappingDocument mappingDocument,
final PluralAttributeElement pluralAttributeElement,
final JaxbManyToManyElement manyToManyElement) {
final JaxbManyToManyElement manyToManyElement,
String cascadeString) {
super( mappingDocument );
this.pluralAttributeElement = pluralAttributeElement;
this.manyToManyElement = manyToManyElement;
this.cascadeStyles = Helper.interpretCascadeStyles( cascadeString, bindingContext() );

this.valueSources = Helper.buildValueSources(
sourceMappingDocument(),
Expand Down Expand Up @@ -145,7 +144,7 @@ public String getWhere() {

@Override
public Iterable<CascadeStyle> getCascadeStyles() {
return Helper.interpretCascadeStyles( pluralAttributeElement.getCascade(), bindingContext() );
return cascadeStyles;
}

@Override
Expand Down
Expand Up @@ -26,7 +26,6 @@
import org.hibernate.engine.spi.CascadeStyle;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.jaxb.spi.hbm.JaxbOneToManyElement;
import org.hibernate.jaxb.spi.hbm.PluralAttributeElement;
import org.hibernate.metamodel.spi.source.OneToManyPluralAttributeElementSource;

/**
Expand All @@ -35,16 +34,16 @@
public class OneToManyPluralAttributeElementSourceImpl
extends AbstractHbmSourceNode
implements OneToManyPluralAttributeElementSource {
private final PluralAttributeElement pluralAttributeElement;
private final JaxbOneToManyElement oneToManyElement;
private final Iterable<CascadeStyle> cascadeStyles;

public OneToManyPluralAttributeElementSourceImpl(
MappingDocument mappingDocument,
PluralAttributeElement pluralAttributeElement,
JaxbOneToManyElement oneToManyElement) {
JaxbOneToManyElement oneToManyElement,
String cascadeString) {
super( mappingDocument );
this.pluralAttributeElement = pluralAttributeElement;
this.oneToManyElement = oneToManyElement;
this.cascadeStyles = Helper.interpretCascadeStyles( cascadeString, bindingContext() );
}

@Override
Expand All @@ -67,6 +66,6 @@ public boolean isNotFoundAnException() {

@Override
public Iterable<CascadeStyle> getCascadeStyles() {
return Helper.interpretCascadeStyles( pluralAttributeElement.getCascade(), bindingContext() );
return cascadeStyles;
}
}
Expand Up @@ -43,6 +43,7 @@ public class CompositePluralAttributeElementBinding
extends AbstractPluralAttributeElementBinding
implements Cascadeable {

// TODO: Come up with a more descriptive name for compositeAttributeBindingContainer.
private AbstractCompositeAttributeBindingContainer compositeAttributeBindingContainer;
private CascadeStyle cascadeStyle;

Expand Down
Expand Up @@ -29,7 +29,7 @@
* @author Steve Ebersole
*/
public interface CompositePluralAttributeElementSource
extends PluralAttributeElementSource, AttributeSourceContainer, CascadeStyleSource {
extends PluralAttributeElementSource, AttributeSourceContainer, CascadeStyleSource, MetaSource {
public String getClassName();

public ValueHolder<Class<?>> getClassReference();
Expand Down

0 comments on commit fc66ca5

Please sign in to comment.