diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/ListAttributeIndexSource.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/ListAttributeIndexSource.java index 4d0831cfab..9727cf8b38 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/ListAttributeIndexSource.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/ListAttributeIndexSource.java @@ -43,9 +43,9 @@ public class ListAttributeIndexSource extends AbstractHbmSourceNode implements P private final ExplicitHibernateTypeSource typeSource; private final int base; - public ListAttributeIndexSource( MappingDocument mappingDocument, final JaxbListIndexElement indexElement ) { - super( mappingDocument ); - valueSources = Helper.buildValueSources( sourceMappingDocument(), new Helper.ValueSourcesAdapter() { + public ListAttributeIndexSource( MappingDocument sourceMappingDocument, final JaxbListIndexElement indexElement ) { + super( sourceMappingDocument ); + valueSources = Helper.buildValueSources( sourceMappingDocument, new Helper.ValueSourcesAdapter() { List< JaxbColumnElement > columnElements = indexElement.getColumn() == null ? Collections.EMPTY_LIST @@ -96,10 +96,9 @@ public class ListAttributeIndexSource extends AbstractHbmSourceNode implements P base = Integer.parseInt( indexElement.getBase() ); } - // TODO: What do we do with the length property? - public ListAttributeIndexSource( MappingDocument mappingDocument, final JaxbIndexElement indexElement ) { - super( mappingDocument ); - valueSources = Helper.buildValueSources( sourceMappingDocument(), new Helper.ValueSourcesAdapter() { + public ListAttributeIndexSource( MappingDocument sourceMappingDocument, final JaxbIndexElement indexElement ) { + super( sourceMappingDocument ); + valueSources = Helper.buildValueSources( sourceMappingDocument, new Helper.ValueSourcesAdapter() { @Override public String getColumnAttribute() { diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/MapAttributeIndexSource.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/MapAttributeIndexSource.java index 8f74f5cac7..a8309becf3 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/MapAttributeIndexSource.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/MapAttributeIndexSource.java @@ -26,6 +26,7 @@ package org.hibernate.metamodel.internal.source.hbm; import java.util.List; import java.util.Map; +import org.hibernate.internal.jaxb.mapping.hbm.JaxbIndexElement; import org.hibernate.internal.jaxb.mapping.hbm.JaxbMapElement.JaxbMapKey; import org.hibernate.metamodel.spi.source.ExplicitHibernateTypeSource; import org.hibernate.metamodel.spi.source.PluralAttributeIndexSource; @@ -42,7 +43,6 @@ public class MapAttributeIndexSource extends AbstractHbmSourceNode implements Pl /** * @param sourceMappingDocument */ - // TODO: What do we do with the length property? public MapAttributeIndexSource( MappingDocument sourceMappingDocument, final JaxbMapKey mapKey ) { super( sourceMappingDocument ); valueSources = Helper.buildValueSources( sourceMappingDocument(), new Helper.ValueSourcesAdapter() { @@ -99,6 +99,54 @@ public class MapAttributeIndexSource extends AbstractHbmSourceNode implements Pl }; } + public MapAttributeIndexSource( MappingDocument sourceMappingDocument, final JaxbIndexElement indexElement ) { + super( sourceMappingDocument ); + valueSources = Helper.buildValueSources( sourceMappingDocument, new Helper.ValueSourcesAdapter() { + + @Override + public String getColumnAttribute() { + return indexElement.getColumnAttribute(); + } + + @Override + public List getColumnOrFormulaElements() { + return indexElement.getColumn(); + } + + @Override + public String getContainingTableName() { + return null; + } + + @Override + public String getFormulaAttribute() { + return null; + } + + @Override + public boolean isIncludedInInsertByDefault() { + return areValuesIncludedInInsertByDefault(); + } + + @Override + public boolean isIncludedInUpdateByDefault() { + return areValuesIncludedInUpdateByDefault(); + } + } ); + typeSource = new ExplicitHibernateTypeSource() { + + @Override + public String getName() { + return indexElement.getType(); + } + + @Override + public Map< String, String > getParameters() { + return java.util.Collections.< String, String >emptyMap(); + } + }; + } + /** * {@inheritDoc} * diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/MapAttributeSource.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/MapAttributeSource.java index 31c823601a..439f17cc27 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/MapAttributeSource.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/MapAttributeSource.java @@ -24,6 +24,7 @@ package org.hibernate.metamodel.internal.source.hbm; import org.hibernate.cfg.NotYetImplementedException; +import org.hibernate.internal.jaxb.mapping.hbm.JaxbIndexElement; import org.hibernate.internal.jaxb.mapping.hbm.JaxbMapElement; import org.hibernate.internal.jaxb.mapping.hbm.JaxbMapElement.JaxbMapKey; import org.hibernate.metamodel.spi.source.AttributeSourceContainer; @@ -48,11 +49,15 @@ public class MapAttributeSource extends AbstractPluralAttributeSourceImpl implem AttributeSourceContainer container ) { super( sourceMappingDocument, mapElement, container ); JaxbMapKey mapKey = mapElement.getMapKey(); - if ( mapKey == null ) { + if ( mapKey != null ) { + this.indexSource = new MapAttributeIndexSource( sourceMappingDocument, mapKey ); + } else { + JaxbIndexElement indexElement = mapElement.getIndex(); + if ( indexElement != null ) { + this.indexSource = new MapAttributeIndexSource( sourceMappingDocument, indexElement ); + } throw new NotYetImplementedException( ", , , , , and " ); - } else { - this.indexSource = new MapAttributeIndexSource( sourceMappingDocument(), mapKey ); } }