HHH-7909 : Refactor to prepare for supporting non-basic map keys

This commit is contained in:
Gail Badner 2013-01-07 15:06:57 -08:00
parent fc1c6b6d41
commit 1159905084
21 changed files with 328 additions and 131 deletions

View File

@ -33,7 +33,7 @@ import org.hibernate.service.Service;
* @author Steve Ebersole
*/
public interface ConfigurationService extends Service {
public Map getSettings();
public Map<?,?> getSettings();
public <T> T getSetting(String name);
public <T> T getSetting(String name, Converter<T> converter);

View File

@ -115,6 +115,7 @@ import org.hibernate.metamodel.spi.source.AggregatedCompositeIdentifierSource;
import org.hibernate.metamodel.spi.source.AttributeSource;
import org.hibernate.metamodel.spi.source.AttributeSourceContainer;
import org.hibernate.metamodel.spi.source.BasicPluralAttributeElementSource;
import org.hibernate.metamodel.spi.source.BasicPluralAttributeIndexSource;
import org.hibernate.metamodel.spi.source.ColumnSource;
import org.hibernate.metamodel.spi.source.ComponentAttributeSource;
import org.hibernate.metamodel.spi.source.CompositePluralAttributeElementSource;
@ -130,6 +131,7 @@ import org.hibernate.metamodel.spi.source.ForeignKeyContributingSource.JoinColum
import org.hibernate.metamodel.spi.source.IdentifierSource;
import org.hibernate.metamodel.spi.source.InLineViewSource;
import org.hibernate.metamodel.spi.source.IndexedPluralAttributeSource;
import org.hibernate.metamodel.spi.source.PluralAttributeIndexSource;
import org.hibernate.metamodel.spi.source.LocalBindingContext;
import org.hibernate.metamodel.spi.source.ManyToManyPluralAttributeElementSource;
import org.hibernate.metamodel.spi.source.MappingDefaults;
@ -140,7 +142,6 @@ import org.hibernate.metamodel.spi.source.NonAggregatedCompositeIdentifierSource
import org.hibernate.metamodel.spi.source.OneToManyPluralAttributeElementSource;
import org.hibernate.metamodel.spi.source.Orderable;
import org.hibernate.metamodel.spi.source.PluralAttributeElementSource;
import org.hibernate.metamodel.spi.source.PluralAttributeIndexSource;
import org.hibernate.metamodel.spi.source.PluralAttributeKeySource;
import org.hibernate.metamodel.spi.source.PluralAttributeSource;
import org.hibernate.metamodel.spi.source.PrimaryKeyJoinColumnSource;
@ -148,6 +149,7 @@ import org.hibernate.metamodel.spi.source.RelationalValueSource;
import org.hibernate.metamodel.spi.source.RelationalValueSourceContainer;
import org.hibernate.metamodel.spi.source.RootEntitySource;
import org.hibernate.metamodel.spi.source.SecondaryTableSource;
import org.hibernate.metamodel.spi.source.SequentialPluralAttributeIndexSource;
import org.hibernate.metamodel.spi.source.SimpleIdentifierSource;
import org.hibernate.metamodel.spi.source.SingularAttributeSource;
import org.hibernate.metamodel.spi.source.Sortable;
@ -1339,7 +1341,7 @@ public class Binder {
case LIST:
attributeBinding = bindListAttribute(
attributeBindingContainer,
attributeSource,
(IndexedPluralAttributeSource) attributeSource,
attribute
);
break;
@ -1353,7 +1355,7 @@ public class Binder {
case ARRAY:
attributeBinding = bindArrayAttribute(
attributeBindingContainer,
attributeSource,
(IndexedPluralAttributeSource) attributeSource,
attribute
);
break;
@ -1427,7 +1429,13 @@ public class Binder {
)
);
}
bindIndexedPluralAttributeIfPossible( attributeSource, attributeBinding, reflectedCollectionJavaTypes );
if ( attributeBinding.hasIndex() ) {
bindPluralAttributeIndex(
(IndexedPluralAttributeSource) attributeSource,
(IndexedPluralAttributeBinding) attributeBinding,
reflectedCollectionJavaTypes
);
}
bindCollectionTablePrimaryKey( attributeBinding, attributeSource );
metadata.addCollection( attributeBinding );
return attributeBinding;
@ -1452,15 +1460,11 @@ public class Binder {
private AbstractPluralAttributeBinding bindListAttribute(
final AttributeBindingContainer attributeBindingContainer,
final PluralAttributeSource attributeSource,
final IndexedPluralAttributeSource attributeSource,
PluralAttribute attribute) {
if ( attribute == null ) {
attribute = attributeBindingContainer.getAttributeContainer().createList( attributeSource.getName() );
}
final int base = IndexedPluralAttributeSource.class.isInstance( attributeSource ) ? IndexedPluralAttributeSource.class
.cast( attributeSource )
.getIndexSource()
.base() : 0;
return attributeBindingContainer.makeListAttributeBinding(
attribute,
pluralAttributeElementNature( attributeSource ),
@ -1468,21 +1472,17 @@ public class Binder {
propertyAccessorName( attributeSource ),
attributeSource.isIncludedInOptimisticLocking(),
createMetaAttributeContext( attributeBindingContainer, attributeSource ),
base
getSequentialPluralAttributeIndexBase( attributeSource )
);
}
private AbstractPluralAttributeBinding bindArrayAttribute(
final AttributeBindingContainer attributeBindingContainer,
final PluralAttributeSource attributeSource,
final IndexedPluralAttributeSource attributeSource,
PluralAttribute attribute) {
if ( attribute == null ) {
attribute = attributeBindingContainer.getAttributeContainer().createArray( attributeSource.getName() );
}
final int base = IndexedPluralAttributeSource.class.isInstance( attributeSource ) ? IndexedPluralAttributeSource.class
.cast( attributeSource )
.getIndexSource()
.base() : 0;
return attributeBindingContainer.makeArrayAttributeBinding(
attribute,
pluralAttributeElementNature( attributeSource ),
@ -1490,10 +1490,24 @@ public class Binder {
propertyAccessorName( attributeSource ),
attributeSource.isIncludedInOptimisticLocking(),
createMetaAttributeContext( attributeBindingContainer, attributeSource ),
base
getSequentialPluralAttributeIndexBase( attributeSource )
);
}
private int getSequentialPluralAttributeIndexBase(IndexedPluralAttributeSource pluralAttributeSource) {
final PluralAttributeIndexSource indexedPluralAttributeSource = pluralAttributeSource.getIndexSource();
if ( ! SequentialPluralAttributeIndexSource.class.isInstance( indexedPluralAttributeSource ) ) {
throw new IllegalArgumentException(
String.format(
"Expected an argument of type: %s; instead, got %s",
SequentialPluralAttributeIndexSource.class.getName(),
indexedPluralAttributeSource.getClass().getName()
)
);
}
return ( (SequentialPluralAttributeIndexSource) indexedPluralAttributeSource ).base();
}
private AbstractPluralAttributeBinding bindMapAttribute(
final AttributeBindingContainer attributeBindingContainer,
final PluralAttributeSource attributeSource,
@ -1647,19 +1661,18 @@ public class Binder {
}
}
private void bindCollectionIndex(
private void bindBasicCollectionIndex(
final IndexedPluralAttributeBinding attributeBinding,
final PluralAttributeIndexSource attributeSource,
final BasicPluralAttributeIndexSource attributeSource,
final String defaultIndexJavaTypeName) {
IndexedPluralAttributeBinding indexedAttributeBinding = attributeBinding;
final BasicPluralAttributeIndexBinding indexBinding =
(BasicPluralAttributeIndexBinding) indexedAttributeBinding.getPluralAttributeIndexBinding();
(BasicPluralAttributeIndexBinding) attributeBinding.getPluralAttributeIndexBinding();
indexBinding.setIndexRelationalValue(
bindValues(
indexedAttributeBinding.getContainer(),
attributeBinding.getContainer(),
attributeSource,
indexedAttributeBinding.getAttribute(),
indexedAttributeBinding.getPluralAttributeKeyBinding().getCollectionTable(),
attributeBinding.getAttribute(),
attributeBinding.getPluralAttributeKeyBinding().getCollectionTable(),
attributeBinding.getPluralAttributeElementBinding()
.getNature() != PluralAttributeElementBinding.Nature.ONE_TO_MANY
)
@ -1859,23 +1872,27 @@ public class Binder {
bindCollectionTableForeignKey( attributeBinding, attributeSource.getKeySource(), collectionTable );
}
private void bindIndexedPluralAttributeIfPossible(
final PluralAttributeSource attributeSource,
final AbstractPluralAttributeBinding attributeBinding,
private void bindPluralAttributeIndex(
final IndexedPluralAttributeSource attributeSource,
final IndexedPluralAttributeBinding attributeBinding,
final ReflectedCollectionJavaTypes reflectedCollectionJavaTypes) {
if ( attributeBinding.getAttribute()
.getNature()
.isIndexable() && attributeSource instanceof IndexedPluralAttributeSource ) {
attributeBinding.setIndex( true );
bindCollectionIndex(
(IndexedPluralAttributeBinding) attributeBinding,
( (IndexedPluralAttributeSource) attributeSource ).getIndexSource(),
HibernateTypeHelper.defaultCollectionIndexJavaTypeName( reflectedCollectionJavaTypes )
);
}
else {
attributeBinding.setIndex( false );
switch ( attributeSource.getIndexSource().getNature() ) {
case BASIC: {
bindBasicCollectionIndex(
attributeBinding,
(BasicPluralAttributeIndexSource) attributeSource.getIndexSource(),
HibernateTypeHelper.defaultCollectionIndexJavaTypeName( reflectedCollectionJavaTypes )
);
break;
}
default: {
throw new NotYetImplementedException(
String.format(
"%s collection indexes are not supported yet.",
attributeSource.getIndexSource().getNature()
)
);
}
}
}

View File

@ -1,3 +1,26 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2012, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations;
import java.util.ArrayList;
@ -12,19 +35,18 @@ import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotName
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.spi.binding.PluralAttributeIndexBinding;
import org.hibernate.metamodel.spi.source.BasicPluralAttributeIndexSource;
import org.hibernate.metamodel.spi.source.ExplicitHibernateTypeSource;
import org.hibernate.metamodel.spi.source.PluralAttributeIndexSource;
import org.hibernate.metamodel.spi.source.RelationalValueSource;
/**
* @author Strong Liu <stliu@hibernate.org>
*/
public class PluralAttributeIndexSourceImpl implements PluralAttributeIndexSource {
public class BasicPluralAttributeIndexSourceImpl implements BasicPluralAttributeIndexSource {
private final PluralAssociationAttribute attribute;
private final IndexedPluralAttributeSourceImpl indexedPluralAttributeSource;
private final int base;
private final List<RelationalValueSource> relationalValueSources = new ArrayList<RelationalValueSource>( 1 );
public PluralAttributeIndexSourceImpl(IndexedPluralAttributeSourceImpl indexedPluralAttributeSource, PluralAssociationAttribute attribute) {
public BasicPluralAttributeIndexSourceImpl(IndexedPluralAttributeSourceImpl indexedPluralAttributeSource, PluralAssociationAttribute attribute) {
this.attribute = attribute;
this.indexedPluralAttributeSource = indexedPluralAttributeSource;
AnnotationInstance columnAnnotation = JandexHelper.getSingleAnnotation(
@ -37,8 +59,6 @@ public class PluralAttributeIndexSourceImpl implements PluralAttributeIndexSourc
JPADotNames.ORDER_COLUMN
);
}
this.base = columnAnnotation.value( "base" ) != null ? columnAnnotation.value( "base" )
.asInt() : 0;
Column indexColumn = new Column( columnAnnotation );
relationalValueSources.add( new ColumnValuesSourceImpl( indexColumn ) );
@ -46,22 +66,7 @@ public class PluralAttributeIndexSourceImpl implements PluralAttributeIndexSourc
@Override
public PluralAttributeIndexBinding.Nature getNature() {
switch ( indexedPluralAttributeSource.getElementSource().getNature() ) {
case BASIC:
return PluralAttributeIndexBinding.Nature.BASIC;
case AGGREGATE:
return PluralAttributeIndexBinding.Nature.AGGREGATE;
case MANY_TO_ANY:
return PluralAttributeIndexBinding.Nature.MANY_TO_ANY;
case MANY_TO_MANY:
return PluralAttributeIndexBinding.Nature.MANY_TO_MANY;
}
return null;
}
@Override
public int base() {
return base;
return PluralAttributeIndexBinding.Nature.BASIC;
}
@Override

View File

@ -1,3 +1,26 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2012, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations;
import java.util.EnumSet;
@ -5,7 +28,6 @@ import java.util.EnumSet;
import org.hibernate.metamodel.internal.source.annotations.attribute.MappedAttribute;
import org.hibernate.metamodel.internal.source.annotations.attribute.PluralAssociationAttribute;
import org.hibernate.metamodel.internal.source.annotations.entity.ConfiguredClass;
import org.hibernate.metamodel.internal.source.annotations.entity.EntityClass;
import org.hibernate.metamodel.spi.source.IndexedPluralAttributeSource;
import org.hibernate.metamodel.spi.source.MappingException;
import org.hibernate.metamodel.spi.source.PluralAttributeIndexSource;
@ -31,7 +53,13 @@ public class IndexedPluralAttributeSourceImpl extends PluralAttributeSourceImpl
attribute.getContext().getOrigin()
);
}
this.indexSource = new PluralAttributeIndexSourceImpl( this, attribute );
if ( attribute.isSequentiallyIndexed() ) {
indexSource = new SequentialPluralAttributeIndexSourceImpl( this, attribute );
}
else {
// for now assume the index is basic type
indexSource = new BasicPluralAttributeIndexSourceImpl( this, attribute );
}
}
@Override

View File

@ -35,7 +35,6 @@ import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.ValueHolder;
import org.hibernate.metamodel.internal.source.annotations.attribute.PluralAssociationAttribute;
import org.hibernate.metamodel.internal.source.annotations.entity.ConfiguredClass;
import org.hibernate.metamodel.internal.source.annotations.entity.EntityClass;
import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.spi.binding.Caching;

View File

@ -0,0 +1,61 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations;
import org.jboss.jandex.AnnotationInstance;
import org.hibernate.metamodel.internal.source.annotations.attribute.PluralAssociationAttribute;
import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.spi.source.SequentialPluralAttributeIndexSource;
/**
* @author Gail Badner
*/
public class SequentialPluralAttributeIndexSourceImpl
extends BasicPluralAttributeIndexSourceImpl
implements SequentialPluralAttributeIndexSource {
private final int base;
public SequentialPluralAttributeIndexSourceImpl(IndexedPluralAttributeSourceImpl indexedPluralAttributeSource, PluralAssociationAttribute attribute) {
super( indexedPluralAttributeSource, attribute );
AnnotationInstance columnAnnotation = JandexHelper.getSingleAnnotation(
attribute.annotations(),
HibernateDotNames.INDEX_COLUMN
);
if(columnAnnotation == null){
columnAnnotation = JandexHelper.getSingleAnnotation(
attribute.annotations(),
JPADotNames.ORDER_COLUMN
);
}
this.base = columnAnnotation.value( "base" ) != null ? columnAnnotation.value( "base" )
.asInt() : 0;
}
@Override
public int base() {
return base;
}
}

View File

@ -25,11 +25,13 @@ package org.hibernate.metamodel.internal.source.annotations;
import java.util.List;
import org.hibernate.AssertionFailure;
import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.metamodel.internal.source.annotations.attribute.AssociationAttribute;
import org.hibernate.metamodel.internal.source.annotations.attribute.PluralAssociationAttribute;
import org.hibernate.metamodel.internal.source.annotations.entity.ConfiguredClass;
import org.hibernate.metamodel.spi.source.AttributeSource;
import org.hibernate.metamodel.spi.source.PluralAttributeSource;
/**
* @author Strong Liu <stliu@hibernate.org>
@ -53,11 +55,12 @@ public class SourceHelper {
case ONE_TO_MANY:
case ELEMENT_COLLECTION_BASIC:
case ELEMENT_COLLECTION_EMBEDDABLE: {
PluralAssociationAttribute pluralAssociationAttribute = (PluralAssociationAttribute) associationAttribute;
AttributeSource source = pluralAssociationAttribute.isIndexed() ?
new IndexedPluralAttributeSourceImpl( pluralAssociationAttribute, configuredClass )
: new PluralAttributeSourceImpl( pluralAssociationAttribute, configuredClass );
attributeList.add( source );
attributeList.add(
createPluralAttributeSource(
configuredClass,
(PluralAssociationAttribute) associationAttribute
)
);
break;
}
default: {
@ -66,4 +69,37 @@ public class SourceHelper {
}
}
}
private static PluralAttributeSource createPluralAttributeSource(
ConfiguredClass configuredClass,
PluralAssociationAttribute pluralAssociationAttribute) {
switch ( pluralAssociationAttribute.getPluralAttributeNature() ) {
case BAG: // fall through intentionally
case SET: {
return new PluralAttributeSourceImpl( pluralAssociationAttribute, configuredClass );
}
case ARRAY: // fall through intentionally
case MAP: // fall through intentionally
case LIST: {
return new IndexedPluralAttributeSourceImpl( pluralAssociationAttribute, configuredClass );
}
case ID_BAG: {
throw new NotYetImplementedException(
String.format(
"%s attributes are not supported yet",
pluralAssociationAttribute.getPluralAttributeNature()
)
);
}
default: {
throw new AssertionFailure(
String.format(
"Unknown plural attribute nature: %s",
pluralAssociationAttribute.getPluralAttributeNature()
)
);
}
}
}
}

View File

@ -37,7 +37,6 @@ import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.hibernate.AnnotationException;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.LazyCollectionOption;
@ -75,7 +74,7 @@ public class PluralAssociationAttribute extends AssociationAttribute {
private final ClassInfo entityClassInfo;
private final boolean isExtraLazy;
private final OnDeleteAction onDeleteAction;
private final boolean isIndexed;
private final boolean isSequentiallyIndexed;
// Used for the non-owning side of a ManyToMany relationship
private final String inverseForeignKeyName;
private final String explicitForeignKeyName;
@ -176,8 +175,8 @@ public class PluralAssociationAttribute extends AssociationAttribute {
return sorted;
}
public boolean isIndexed() {
return isIndexed;
public boolean isSequentiallyIndexed() {
return isSequentiallyIndexed;
}
private PluralAssociationAttribute(
@ -260,7 +259,7 @@ public class PluralAssociationAttribute extends AssociationAttribute {
getContext().getOrigin()
);
}
this.isIndexed = orderColumnAnnotation != null || indexColumnAnnotation != null;
this.isSequentiallyIndexed = orderColumnAnnotation != null || indexColumnAnnotation != null;
this.pluralAttributeNature = resolvePluralAttributeNature();
validateMapping();
@ -305,7 +304,7 @@ public class PluralAssociationAttribute extends AssociationAttribute {
return PluralAttributeSource.Nature.MAP;
}
else if ( List.class.isAssignableFrom( getAttributeType() ) ) {
if ( isIndexed() ) {
if ( isSequentiallyIndexed() ) {
return PluralAttributeSource.Nature.LIST;
}
else if ( isCollectionIdPresent ) {

View File

@ -142,35 +142,35 @@ public abstract class AbstractComponentAttributeSourceImpl extends AbstractHbmSo
}
// todo duplicated with org.hibernate.metamodel.internal.source.hbm.AbstractEntitySourceImpl
protected AttributeSource buildAttributeSource(JaxbMapElement attributeElement){
return new MapAttributeSource(
return new MapSource(
sourceMappingDocument(),
attributeElement,
parentContainer
);
}
protected AttributeSource buildAttributeSource(JaxbSetElement attributeElement) {
return new SetAttributeSourceImpl(
return new SetSourceImpl(
sourceMappingDocument(),
attributeElement,
parentContainer
);
}
protected AttributeSource buildAttributeSource(JaxbListElement attributeElement) {
return new ListAttributeSource(
return new ListSourceImpl(
sourceMappingDocument(),
attributeElement,
parentContainer
);
}
protected AttributeSource buildAttributeSource(JaxbBagElement attributeElement) {
return new BagAttributeSourceImpl(
return new BagSourceImpl(
sourceMappingDocument(),
attributeElement,
parentContainer
);
}
protected AttributeSource buildAttributeSource(JaxbArrayElement attributeElement) {
return new ArrayAttributeSource(
return new ArraySourceImpl(
sourceMappingDocument(),
attributeElement,
parentContainer

View File

@ -274,7 +274,7 @@ public abstract class AbstractEntitySourceImpl
List<JaxbMapElement> propertyElements){
for ( JaxbMapElement element : propertyElements ) {
results.add(
new MapAttributeSource(
new MapSource(
sourceMappingDocument(),
element, this
)
@ -285,7 +285,7 @@ public abstract class AbstractEntitySourceImpl
List<JaxbArrayElement> propertyElements){
for ( JaxbArrayElement element : propertyElements ) {
results.add(
new ArrayAttributeSource(
new ArraySourceImpl(
sourceMappingDocument(),
element, this
)
@ -296,7 +296,7 @@ public abstract class AbstractEntitySourceImpl
List<JaxbListElement> propertyElements){
for ( JaxbListElement element : propertyElements ) {
results.add(
new ListAttributeSource(
new ListSourceImpl(
sourceMappingDocument(),
element, this
)
@ -307,7 +307,7 @@ public abstract class AbstractEntitySourceImpl
List<JaxbSetElement> propertyElements){
for ( JaxbSetElement element : propertyElements ) {
results.add(
new SetAttributeSourceImpl(
new SetSourceImpl(
sourceMappingDocument(),
element,
this
@ -326,7 +326,7 @@ public abstract class AbstractEntitySourceImpl
List<JaxbBagElement> propertyElements) {
for ( JaxbBagElement element : propertyElements ) {
results.add(
new BagAttributeSourceImpl(
new BagSourceImpl(
sourceMappingDocument(),
element,
this

View File

@ -28,24 +28,25 @@ import org.hibernate.jaxb.spi.hbm.JaxbListIndexElement;
import org.hibernate.metamodel.spi.source.AttributeSourceContainer;
import org.hibernate.metamodel.spi.source.IndexedPluralAttributeSource;
import org.hibernate.metamodel.spi.source.PluralAttributeIndexSource;
import org.hibernate.metamodel.spi.source.SequentialPluralAttributeIndexSource;
/**
* @author Brett Meyer
*/
public class ArrayAttributeSource extends AbstractPluralAttributeSourceImpl implements IndexedPluralAttributeSource {
public class ArraySourceImpl extends AbstractPluralAttributeSourceImpl implements IndexedPluralAttributeSource {
private final ListAttributeIndexSource indexSource;
private final SequentialPluralAttributeIndexSource indexSource;
public ArrayAttributeSource(
public ArraySourceImpl(
MappingDocument sourceMappingDocument,
JaxbArrayElement arrayElement,
AttributeSourceContainer container ) {
AttributeSourceContainer container) {
super( sourceMappingDocument, arrayElement, container );
JaxbListIndexElement listIndexElement = arrayElement.getListIndex();
if ( listIndexElement == null ) {
this.indexSource = new ListAttributeIndexSource( sourceMappingDocument(), arrayElement.getIndex() );
this.indexSource = new SequentialPluralAttributeIndexSourceImpl( sourceMappingDocument(), arrayElement.getIndex() );
} else {
this.indexSource = new ListAttributeIndexSource( sourceMappingDocument(), listIndexElement );
this.indexSource = new SequentialPluralAttributeIndexSourceImpl( sourceMappingDocument(), listIndexElement );
}
}

View File

@ -31,8 +31,8 @@ import org.hibernate.metamodel.spi.source.Orderable;
/**
* @author Steve Ebersole
*/
public class BagAttributeSourceImpl extends AbstractPluralAttributeSourceImpl implements Orderable {
public BagAttributeSourceImpl(
public class BagSourceImpl extends AbstractPluralAttributeSourceImpl implements Orderable {
public BagSourceImpl(
MappingDocument sourceMappingDocument,
JaxbBagElement bagElement,
AttributeSourceContainer container) {

View File

@ -28,29 +28,30 @@ import org.hibernate.jaxb.spi.hbm.JaxbListIndexElement;
import org.hibernate.metamodel.spi.source.AttributeSourceContainer;
import org.hibernate.metamodel.spi.source.IndexedPluralAttributeSource;
import org.hibernate.metamodel.spi.source.PluralAttributeIndexSource;
import org.hibernate.metamodel.spi.source.SequentialPluralAttributeIndexSource;
/**
*
*/
public class ListAttributeSource extends AbstractPluralAttributeSourceImpl implements IndexedPluralAttributeSource {
public class ListSourceImpl extends AbstractPluralAttributeSourceImpl implements IndexedPluralAttributeSource {
private final ListAttributeIndexSource indexSource;
private final SequentialPluralAttributeIndexSource indexSource;
/**
* @param sourceMappingDocument
* @param listElement
* @param container
*/
public ListAttributeSource(
public ListSourceImpl(
MappingDocument sourceMappingDocument,
JaxbListElement listElement,
AttributeSourceContainer container ) {
AttributeSourceContainer container) {
super( sourceMappingDocument, listElement, container );
JaxbListIndexElement listIndexElement = listElement.getListIndex();
if ( listIndexElement == null ) {
this.indexSource = new ListAttributeIndexSource( sourceMappingDocument(), listElement.getIndex() );
this.indexSource = new SequentialPluralAttributeIndexSourceImpl( sourceMappingDocument(), listElement.getIndex() );
} else {
this.indexSource = new ListAttributeIndexSource( sourceMappingDocument(), listIndexElement );
this.indexSource = new SequentialPluralAttributeIndexSourceImpl( sourceMappingDocument(), listIndexElement );
}
}

View File

@ -30,19 +30,19 @@ import org.hibernate.jaxb.spi.hbm.JaxbColumnElement;
import org.hibernate.jaxb.spi.hbm.JaxbIndexElement;
import org.hibernate.jaxb.spi.hbm.JaxbMapKeyElement;
import org.hibernate.metamodel.spi.binding.PluralAttributeIndexBinding;
import org.hibernate.metamodel.spi.source.BasicPluralAttributeIndexSource;
import org.hibernate.metamodel.spi.source.ExplicitHibernateTypeSource;
import org.hibernate.metamodel.spi.source.PluralAttributeIndexSource;
import org.hibernate.metamodel.spi.source.RelationalValueSource;
/**
*
*/
public class MapAttributeIndexSource extends AbstractHbmSourceNode implements PluralAttributeIndexSource {
public class MapKeySourceImpl extends AbstractHbmSourceNode implements BasicPluralAttributeIndexSource {
private final PluralAttributeIndexBinding.Nature nature;
private final List<RelationalValueSource> valueSources;
private final ExplicitHibernateTypeSource typeSource;
public MapAttributeIndexSource(MappingDocument sourceMappingDocument, final JaxbMapKeyElement mapKey) {
public MapKeySourceImpl(MappingDocument sourceMappingDocument, final JaxbMapKeyElement mapKey) {
super( sourceMappingDocument );
valueSources = Helper.buildValueSources(
sourceMappingDocument(),
@ -101,7 +101,7 @@ public class MapAttributeIndexSource extends AbstractHbmSourceNode implements Pl
this.nature = PluralAttributeIndexBinding.Nature.BASIC;
}
public MapAttributeIndexSource(MappingDocument sourceMappingDocument, final JaxbIndexElement indexElement) {
public MapKeySourceImpl(MappingDocument sourceMappingDocument, final JaxbIndexElement indexElement) {
super( sourceMappingDocument );
valueSources = Helper.buildValueSources(
sourceMappingDocument,
@ -136,7 +136,7 @@ public class MapAttributeIndexSource extends AbstractHbmSourceNode implements Pl
@Override
public Map<String, String> getParameters() {
return java.util.Collections.<String, String>emptyMap();
return java.util.Collections.emptyMap();
}
};
@ -172,9 +172,4 @@ public class MapAttributeIndexSource extends AbstractHbmSourceNode implements Pl
public List<RelationalValueSource> relationalValueSources() {
return valueSources;
}
@Override
public int base() {
return 0;
}
}

View File

@ -33,28 +33,28 @@ import org.hibernate.metamodel.spi.source.IndexedPluralAttributeSource;
/**
*
*/
public class MapAttributeSource extends AbstractPluralAttributeSourceImpl implements IndexedPluralAttributeSource {
public class MapSource extends AbstractPluralAttributeSourceImpl implements IndexedPluralAttributeSource {
private final MapAttributeIndexSource indexSource;
private final MapKeySourceImpl indexSource;
/**
* @param sourceMappingDocument
* @param pluralAttributeElement
* @param container
*/
public MapAttributeSource(
public MapSource(
MappingDocument sourceMappingDocument,
JaxbMapElement mapElement,
AttributeSourceContainer container ) {
AttributeSourceContainer container) {
super( sourceMappingDocument, mapElement, container );
JaxbMapKeyElement mapKey = mapElement.getMapKey();
if ( mapKey != null ) {
this.indexSource = new MapAttributeIndexSource( sourceMappingDocument, mapKey );
this.indexSource = new MapKeySourceImpl( sourceMappingDocument, mapKey );
}
else {
JaxbIndexElement indexElement = mapElement.getIndex();
if ( indexElement != null ) {
this.indexSource = new MapAttributeIndexSource( sourceMappingDocument, indexElement );
this.indexSource = new MapKeySourceImpl( 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>" );
@ -62,7 +62,7 @@ public class MapAttributeSource extends AbstractPluralAttributeSourceImpl implem
}
@Override
public MapAttributeIndexSource getIndexSource() {
public MapKeySourceImpl getIndexSource() {
return indexSource;
}

View File

@ -33,18 +33,18 @@ import org.hibernate.jaxb.spi.hbm.JaxbIndexElement;
import org.hibernate.jaxb.spi.hbm.JaxbListIndexElement;
import org.hibernate.metamodel.spi.binding.PluralAttributeIndexBinding;
import org.hibernate.metamodel.spi.source.ExplicitHibernateTypeSource;
import org.hibernate.metamodel.spi.source.PluralAttributeIndexSource;
import org.hibernate.metamodel.spi.source.SequentialPluralAttributeIndexSource;
import org.hibernate.metamodel.spi.source.RelationalValueSource;
/**
*
*/
public class ListAttributeIndexSource extends AbstractHbmSourceNode implements PluralAttributeIndexSource {
public class SequentialPluralAttributeIndexSourceImpl extends AbstractHbmSourceNode implements SequentialPluralAttributeIndexSource {
private final List< RelationalValueSource > valueSources;
private final ExplicitHibernateTypeSource typeSource;
private final int base;
public ListAttributeIndexSource( MappingDocument sourceMappingDocument, final JaxbListIndexElement indexElement ) {
public SequentialPluralAttributeIndexSourceImpl(MappingDocument sourceMappingDocument, final JaxbListIndexElement indexElement) {
super( sourceMappingDocument );
valueSources = Helper.buildValueSources( sourceMappingDocument, new Helper.ValueSourcesAdapter() {
@ -85,7 +85,7 @@ public class ListAttributeIndexSource extends AbstractHbmSourceNode implements P
base = Integer.parseInt( indexElement.getBase() );
}
public ListAttributeIndexSource( MappingDocument sourceMappingDocument, final JaxbIndexElement indexElement ) {
public SequentialPluralAttributeIndexSourceImpl(MappingDocument sourceMappingDocument, final JaxbIndexElement indexElement) {
super( sourceMappingDocument );
valueSources = Helper.buildValueSources( sourceMappingDocument, new Helper.ValueSourcesAdapter() {

View File

@ -32,8 +32,8 @@ import org.hibernate.metamodel.spi.source.Sortable;
/**
* @author Steve Ebersole
*/
public class SetAttributeSourceImpl extends AbstractPluralAttributeSourceImpl implements Orderable, Sortable {
public SetAttributeSourceImpl(
public class SetSourceImpl extends AbstractPluralAttributeSourceImpl implements Orderable, Sortable {
public SetSourceImpl(
MappingDocument sourceMappingDocument,
JaxbSetElement setElement,
AttributeSourceContainer container) {

View File

@ -59,7 +59,6 @@ public abstract class AbstractPluralAttributeBinding extends AbstractAttributeBi
private String where;
private String orderBy;
private boolean sorted;
private boolean index;
private Comparator< ? > comparator;
private String customLoaderName;
@ -252,11 +251,7 @@ public abstract class AbstractPluralAttributeBinding extends AbstractAttributeBi
}
@Override
public boolean hasIndex() {
return index;
}
public void setIndex(boolean index) {
this.index = index;
return IndexedPluralAttributeBinding.class.isInstance( this );
}
@Override

View File

@ -0,0 +1,31 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.spi.source;
/**
* @author Gail Badner
*/
public interface BasicPluralAttributeIndexSource extends PluralAttributeIndexSource {
ExplicitHibernateTypeSource explicitHibernateTypeSource();
}

View File

@ -30,6 +30,4 @@ import org.hibernate.metamodel.spi.binding.PluralAttributeIndexBinding;
*/
public interface PluralAttributeIndexSource extends RelationalValueSourceContainer {
PluralAttributeIndexBinding.Nature getNature();
ExplicitHibernateTypeSource explicitHibernateTypeSource();
int base();
}

View File

@ -0,0 +1,31 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.spi.source;
/**
* @author Gail Badner
*/
public interface SequentialPluralAttributeIndexSource extends BasicPluralAttributeIndexSource {
int base();
}