HHH-6504: Added support for index attribute for maps.
This commit is contained in:
parent
a33943694c
commit
ce2f359d05
|
@ -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() {
|
||||
|
|
|
@ -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}
|
||||
*
|
||||
|
|
|
@ -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(
|
||||
"<map-key-many-to-many>, <composite-map-key>, <index>, <composite-index>, <index-many-to-many>, and <index-many-to-any>" );
|
||||
} else {
|
||||
this.indexSource = new MapAttributeIndexSource( sourceMappingDocument(), mapKey );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue