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 ExplicitHibernateTypeSource typeSource;
|
||||||
private final int base;
|
private final int base;
|
||||||
|
|
||||||
public ListAttributeIndexSource( MappingDocument mappingDocument, final JaxbListIndexElement indexElement ) {
|
public ListAttributeIndexSource( MappingDocument sourceMappingDocument, final JaxbListIndexElement indexElement ) {
|
||||||
super( mappingDocument );
|
super( sourceMappingDocument );
|
||||||
valueSources = Helper.buildValueSources( sourceMappingDocument(), new Helper.ValueSourcesAdapter() {
|
valueSources = Helper.buildValueSources( sourceMappingDocument, new Helper.ValueSourcesAdapter() {
|
||||||
|
|
||||||
List< JaxbColumnElement > columnElements = indexElement.getColumn() == null
|
List< JaxbColumnElement > columnElements = indexElement.getColumn() == null
|
||||||
? Collections.EMPTY_LIST
|
? Collections.EMPTY_LIST
|
||||||
|
@ -96,10 +96,9 @@ public class ListAttributeIndexSource extends AbstractHbmSourceNode implements P
|
||||||
base = Integer.parseInt( indexElement.getBase() );
|
base = Integer.parseInt( indexElement.getBase() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: What do we do with the length property?
|
public ListAttributeIndexSource( MappingDocument sourceMappingDocument, final JaxbIndexElement indexElement ) {
|
||||||
public ListAttributeIndexSource( MappingDocument mappingDocument, final JaxbIndexElement indexElement ) {
|
super( sourceMappingDocument );
|
||||||
super( mappingDocument );
|
valueSources = Helper.buildValueSources( sourceMappingDocument, new Helper.ValueSourcesAdapter() {
|
||||||
valueSources = Helper.buildValueSources( sourceMappingDocument(), new Helper.ValueSourcesAdapter() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getColumnAttribute() {
|
public String getColumnAttribute() {
|
||||||
|
|
|
@ -26,6 +26,7 @@ package org.hibernate.metamodel.internal.source.hbm;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.hibernate.internal.jaxb.mapping.hbm.JaxbIndexElement;
|
||||||
import org.hibernate.internal.jaxb.mapping.hbm.JaxbMapElement.JaxbMapKey;
|
import org.hibernate.internal.jaxb.mapping.hbm.JaxbMapElement.JaxbMapKey;
|
||||||
import org.hibernate.metamodel.spi.source.ExplicitHibernateTypeSource;
|
import org.hibernate.metamodel.spi.source.ExplicitHibernateTypeSource;
|
||||||
import org.hibernate.metamodel.spi.source.PluralAttributeIndexSource;
|
import org.hibernate.metamodel.spi.source.PluralAttributeIndexSource;
|
||||||
|
@ -42,7 +43,6 @@ public class MapAttributeIndexSource extends AbstractHbmSourceNode implements Pl
|
||||||
/**
|
/**
|
||||||
* @param sourceMappingDocument
|
* @param sourceMappingDocument
|
||||||
*/
|
*/
|
||||||
// TODO: What do we do with the length property?
|
|
||||||
public MapAttributeIndexSource( MappingDocument sourceMappingDocument, final JaxbMapKey mapKey ) {
|
public MapAttributeIndexSource( MappingDocument sourceMappingDocument, final JaxbMapKey mapKey ) {
|
||||||
super( sourceMappingDocument );
|
super( sourceMappingDocument );
|
||||||
valueSources = Helper.buildValueSources( sourceMappingDocument(), new Helper.ValueSourcesAdapter() {
|
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}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
package org.hibernate.metamodel.internal.source.hbm;
|
package org.hibernate.metamodel.internal.source.hbm;
|
||||||
|
|
||||||
import org.hibernate.cfg.NotYetImplementedException;
|
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;
|
||||||
import org.hibernate.internal.jaxb.mapping.hbm.JaxbMapElement.JaxbMapKey;
|
import org.hibernate.internal.jaxb.mapping.hbm.JaxbMapElement.JaxbMapKey;
|
||||||
import org.hibernate.metamodel.spi.source.AttributeSourceContainer;
|
import org.hibernate.metamodel.spi.source.AttributeSourceContainer;
|
||||||
|
@ -48,11 +49,15 @@ public class MapAttributeSource extends AbstractPluralAttributeSourceImpl implem
|
||||||
AttributeSourceContainer container ) {
|
AttributeSourceContainer container ) {
|
||||||
super( sourceMappingDocument, mapElement, container );
|
super( sourceMappingDocument, mapElement, container );
|
||||||
JaxbMapKey mapKey = mapElement.getMapKey();
|
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(
|
throw new NotYetImplementedException(
|
||||||
"<map-key-many-to-many>, <composite-map-key>, <index>, <composite-index>, <index-many-to-many>, and <index-many-to-any>" );
|
"<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