From 94480b6905c652c56bf5aaa461fba036164c56f5 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Thu, 9 Feb 2012 15:32:36 -0600 Subject: [PATCH] HHH-7042 - Clean up MetadataSources --- .../org/hibernate/cfg/AnnotationBinder.java | 2 +- .../org/hibernate/metamodel/Metadata.java | 6 +- .../metamodel/internal/MetadataImpl.java | 123 ++++++++--------- .../metamodel/internal/source/Binder.java | 10 +- ...AnnotationMetadataSourceProcessorImpl.java | 16 +-- ...l.java => FilterDefinitionSourceImpl.java} | 6 +- .../annotations/TypeDescriptorSourceImpl.java | 14 +- .../global/FilterDefProcessor.java | 100 -------------- .../annotations/global/TypeDefProcessor.java | 126 ------------------ ...l.java => FilterDefinitionSourceImpl.java} | 6 +- .../hbm/HbmMetadataSourceProcessorImpl.java | 12 +- .../source/hbm/HibernateMappingProcessor.java | 6 +- .../source/hbm/TypeDescriptorSourceImpl.java | 6 +- .../spi/MetadataSourceProcessor.java | 6 +- .../{TypeDef.java => TypeDefinition.java} | 32 +++-- ...ource.java => FilterDefinitionSource.java} | 2 +- .../metamodel/spi/source/FilterSource.java | 4 +- .../spi/source/MetadataImplementor.java | 4 +- .../spi/source/TypeDescriptorSource.java | 4 +- .../entity/BasicHibernateAnnotationsTest.java | 2 +- .../entity/IdentifierGeneratorTest.java | 3 + .../global/FetchProfileBinderTest.java | 8 +- 22 files changed, 143 insertions(+), 355 deletions(-) rename hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/{FilterDefSourceImpl.java => FilterDefinitionSourceImpl.java} (92%) delete mode 100644 hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/global/FilterDefProcessor.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/global/TypeDefProcessor.java rename hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/{FilterDefSourceImpl.java => FilterDefinitionSourceImpl.java} (92%) rename hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/{TypeDef.java => TypeDefinition.java} (64%) rename hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/{FilterDefSource.java => FilterDefinitionSource.java} (97%) diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java index e4dc5098c0..1256d78fb7 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java @@ -1284,7 +1284,7 @@ public final class AnnotationBinder { if ( BinderHelper.isEmptyAnnotationValue( defAnn.name() ) && defAnn.defaultForType().equals( void.class ) ) { throw new AnnotationException( - "Either name or defaultForType (or both) attribute should be set in TypeDef having typeClass " + + "Either name or defaultForType (or both) attribute should be set in TypeDefinition having typeClass " + defAnn.typeClass().getName() ); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/Metadata.java b/hibernate-core/src/main/java/org/hibernate/metamodel/Metadata.java index 507c2f45b7..db2eab794c 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/Metadata.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/Metadata.java @@ -40,7 +40,7 @@ import org.hibernate.metamodel.spi.binding.EntityBinding; import org.hibernate.metamodel.spi.binding.FetchProfile; import org.hibernate.metamodel.spi.binding.IdGenerator; import org.hibernate.metamodel.spi.binding.PluralAttributeBinding; -import org.hibernate.metamodel.spi.binding.TypeDef; +import org.hibernate.metamodel.spi.binding.TypeDefinition; /** * @author Steve Ebersole @@ -80,9 +80,9 @@ public interface Metadata { public Iterable getCollectionBindings(); - public TypeDef getTypeDefinition(String name); + public TypeDefinition getTypeDefinition(String name); - public Iterable getTypeDefinitions(); + public Iterable getTypeDefinitions(); public Iterable getFilterDefinitions(); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataImpl.java index e0ba03c5e0..442cc112e7 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataImpl.java @@ -60,12 +60,12 @@ import org.hibernate.metamodel.spi.binding.EntityBinding; import org.hibernate.metamodel.spi.binding.FetchProfile; import org.hibernate.metamodel.spi.binding.IdGenerator; import org.hibernate.metamodel.spi.binding.PluralAttributeBinding; -import org.hibernate.metamodel.spi.binding.TypeDef; +import org.hibernate.metamodel.spi.binding.TypeDefinition; import org.hibernate.metamodel.spi.domain.BasicType; import org.hibernate.metamodel.spi.domain.Type; import org.hibernate.metamodel.spi.relational.Database; import org.hibernate.metamodel.spi.source.EntityHierarchy; -import org.hibernate.metamodel.spi.source.FilterDefSource; +import org.hibernate.metamodel.spi.source.FilterDefinitionSource; import org.hibernate.metamodel.spi.source.MappingDefaults; import org.hibernate.metamodel.spi.source.MetaAttributeContext; import org.hibernate.metamodel.spi.source.MetadataImplementor; @@ -105,20 +105,17 @@ public class MetadataImpl implements MetadataImplementor, Serializable { private final MappingDefaults mappingDefaults; - /** - * Maps the fully qualified class name of an entity to its entity binding - */ - private Map entityBindingMap = new HashMap(); + private Map typeDefinitionMap = new HashMap(); + private Map filterDefinitionMap = new HashMap(); + private Map entityBindingMap = new HashMap(); private Map collectionBindingMap = new HashMap(); private Map fetchProfiles = new HashMap(); private Map imports = new HashMap(); - private Map typeDefs = new HashMap(); private Map idGenerators = new HashMap(); private Map namedQueryDefs = new HashMap(); private Map namedNativeQueryDefs = new HashMap(); private Map resultSetMappings = new HashMap(); - private Map filterDefs = new HashMap(); private boolean globallyQuotedIdentifiers = false; @@ -162,12 +159,11 @@ public class MetadataImpl implements MetadataImplementor, Serializable { } ); - - prepare( metadataSourceProcessors, metadataSources ); - processTypeDescriptors( metadataSourceProcessors, metadataSources ); - processFilterDefs( metadataSourceProcessors, metadataSources ); + processTypeDefinitions( metadataSourceProcessors, metadataSources ); + processFilterDefinitions( metadataSourceProcessors, metadataSources ); + processIdentifierGenerators( metadataSourceProcessors, metadataSources ); processMappings( metadataSourceProcessors, metadataSources ); @@ -181,6 +177,9 @@ public class MetadataImpl implements MetadataImplementor, Serializable { new IdentifierGeneratorResolver( this ).resolve(); } + + // general preparation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + private void prepare(MetadataSourceProcessor[] metadataSourceProcessors, MetadataSources metadataSources) { for ( MetadataSourceProcessor metadataSourceProcessor : metadataSourceProcessors ) { metadataSourceProcessor.prepare( metadataSources ); @@ -188,35 +187,61 @@ public class MetadataImpl implements MetadataImplementor, Serializable { } - // type descriptors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // type definitions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - private void processTypeDescriptors( + private void processTypeDefinitions( MetadataSourceProcessor[] metadataSourceProcessors, MetadataSources metadataSources) { for ( MetadataSourceProcessor processor : metadataSourceProcessors ) { - for ( TypeDescriptorSource typeDescriptorSource : processor.extractTypeDescriptorSources( metadataSources ) ) { - final TypeDef typeDef = new TypeDef( - typeDescriptorSource.getName(), - typeDescriptorSource.getTypeImplementationClassName(), - typeDescriptorSource.getParameters() + for ( TypeDescriptorSource typeDescriptorSource : processor.extractTypeDefinitionSources( metadataSources ) ) { + addTypeDefinition( + new TypeDefinition( + typeDescriptorSource.getName(), + classLoaderService().classForName( typeDescriptorSource.getTypeImplementationClassName() ), + typeDescriptorSource.getRegistrationKeys(), + typeDescriptorSource.getParameters() + ) ); - typeDefs.put( typeDef.getName(), typeDef ); } } } + @Override + public void addTypeDefinition(TypeDefinition typeDefinition) { + if ( typeDefinition == null ) { + throw new IllegalArgumentException( "Type definition is null" ); + } + else if ( typeDefinition.getName() == null ) { + throw new IllegalArgumentException( "Type definition name is null: " + typeDefinition.getTypeImplementorClass().getName() ); + } + final TypeDefinition previous = typeDefinitionMap.put( typeDefinition.getName(), typeDefinition ); + if ( previous != null ) { + LOG.debugf( "Duplicate typedef name [%s] now -> %s", typeDefinition.getName(), typeDefinition.getTypeImplementorClass().getName() ); + } + } - // filter-defs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + @Override + public Iterable getTypeDefinitions() { + return typeDefinitionMap.values(); + } - private void processFilterDefs( + @Override + public TypeDefinition getTypeDefinition(String name) { + return typeDefinitionMap.get( name ); + } + + + // filter definitions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + private void processFilterDefinitions( MetadataSourceProcessor[] metadataSourceProcessors, MetadataSources metadataSources) { for ( MetadataSourceProcessor processor : metadataSourceProcessors ) { - for ( FilterDefSource filterDefSource : processor.extractFilterDefSources( metadataSources ) ) { + for ( FilterDefinitionSource filterDefinitionSource : processor.extractFilterDefinitionSources( metadataSources ) ) { addFilterDefinition( new FilterDefinition( - filterDefSource.getName(), - filterDefSource.getCondition(), + filterDefinitionSource.getName(), + filterDefinitionSource.getCondition(), null // the params, todo : need to figure out how to handle the type portion ) ); @@ -224,6 +249,18 @@ public class MetadataImpl implements MetadataImplementor, Serializable { } } + @Override + public void addFilterDefinition(FilterDefinition filterDefinition) { + if ( filterDefinition == null || filterDefinition.getFilterName() == null ) { + throw new IllegalArgumentException( "Filter definition object or name is null: " + filterDefinition ); + } + filterDefinitionMap.put( filterDefinition.getFilterName(), filterDefinition ); + } + + public Iterable getFilterDefinitions() { + return filterDefinitionMap.values(); + } + // identifier generators ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -264,18 +301,6 @@ public class MetadataImpl implements MetadataImplementor, Serializable { fetchProfiles.put( profile.getName(), profile ); } - @Override - public void addFilterDefinition(FilterDefinition def) { - if ( def == null || def.getFilterName() == null ) { - throw new IllegalArgumentException( "Filter definition object or name is null: " + def ); - } - filterDefs.put( def.getFilterName(), def ); - } - - public Iterable getFilterDefinitions() { - return filterDefs.values(); - } - @Override public void addIdGenerator(IdGenerator generator) { if ( generator == null || generator.getName() == null ) { @@ -352,30 +377,6 @@ public class MetadataImpl implements MetadataImplementor, Serializable { return resultSetMappings.values(); } - @Override - public void addTypeDefinition(TypeDef typeDef) { - if ( typeDef == null ) { - throw new IllegalArgumentException( "Type definition is null" ); - } - else if ( typeDef.getName() == null ) { - throw new IllegalArgumentException( "Type definition name is null: " + typeDef.getTypeClass() ); - } - final TypeDef previous = typeDefs.put( typeDef.getName(), typeDef ); - if ( previous != null ) { - LOG.debugf( "Duplicate typedef name [%s] now -> %s", typeDef.getName(), typeDef.getTypeClass() ); - } - } - - @Override - public Iterable getTypeDefinitions() { - return typeDefs.values(); - } - - @Override - public TypeDef getTypeDefinition(String name) { - return typeDefs.get( name ); - } - private ClassLoaderService classLoaderService() { return classLoaderService.getValue(); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/Binder.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/Binder.java index 43e2a310ae..9fa499384c 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/Binder.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/Binder.java @@ -57,7 +57,7 @@ import org.hibernate.metamodel.spi.binding.IdGenerator; import org.hibernate.metamodel.spi.binding.InheritanceType; import org.hibernate.metamodel.spi.binding.SimpleValueBinding; import org.hibernate.metamodel.spi.binding.SingularAttributeBinding; -import org.hibernate.metamodel.spi.binding.TypeDef; +import org.hibernate.metamodel.spi.binding.TypeDefinition; import org.hibernate.metamodel.spi.domain.Component; import org.hibernate.metamodel.spi.domain.Entity; import org.hibernate.metamodel.spi.domain.PluralAttribute; @@ -820,11 +820,11 @@ public class Binder { final String explicitTypeName = typeSource.getName(); if ( explicitTypeName != null ) { - final TypeDef typeDef = currentBindingContext.getMetadataImplementor() + final TypeDefinition typeDefinition = currentBindingContext.getMetadataImplementor() .getTypeDefinition( explicitTypeName ); - if ( typeDef != null ) { - hibernateTypeDescriptor.setExplicitTypeName( typeDef.getTypeClass() ); - hibernateTypeDescriptor.getTypeParameters().putAll( typeDef.getParameters() ); + if ( typeDefinition != null ) { + hibernateTypeDescriptor.setExplicitTypeName( typeDefinition.getTypeImplementorClass().getName() ); + hibernateTypeDescriptor.getTypeParameters().putAll( typeDefinition.getParameters() ); } else { hibernateTypeDescriptor.setExplicitTypeName( explicitTypeName ); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/AnnotationMetadataSourceProcessorImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/AnnotationMetadataSourceProcessorImpl.java index b6850c804b..2747b85f3f 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/AnnotationMetadataSourceProcessorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/AnnotationMetadataSourceProcessorImpl.java @@ -40,14 +40,13 @@ import org.hibernate.internal.jaxb.mapping.orm.JaxbEntityMappings; import org.hibernate.metamodel.MetadataSources; import org.hibernate.metamodel.internal.MetadataImpl; import org.hibernate.metamodel.internal.source.annotations.global.FetchProfileProcessor; -import org.hibernate.metamodel.internal.source.annotations.global.FilterDefProcessor; import org.hibernate.metamodel.internal.source.annotations.global.QueryProcessor; import org.hibernate.metamodel.internal.source.annotations.global.TableProcessor; import org.hibernate.metamodel.internal.source.annotations.xml.PseudoJpaDotNames; import org.hibernate.metamodel.internal.source.annotations.xml.mocker.EntityMappingsMocker; import org.hibernate.metamodel.spi.MetadataSourceProcessor; import org.hibernate.metamodel.spi.source.EntityHierarchy; -import org.hibernate.metamodel.spi.source.FilterDefSource; +import org.hibernate.metamodel.spi.source.FilterDefinitionSource; import org.hibernate.metamodel.spi.source.MetadataImplementor; import org.hibernate.metamodel.spi.source.TypeDescriptorSource; import org.hibernate.service.classloading.spi.ClassLoaderService; @@ -105,7 +104,7 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc } @Override - public Iterable extractTypeDescriptorSources(MetadataSources sources) { + public Iterable extractTypeDefinitionSources(MetadataSources sources) { assertBindingContextExists(); List typeDescriptorSources = new ArrayList(); @@ -135,13 +134,13 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc } @Override - public Iterable extractFilterDefSources(MetadataSources sources) { + public Iterable extractFilterDefinitionSources(MetadataSources sources) { assertBindingContextExists(); - List filterDefSources = new ArrayList(); + List filterDefinitionSources = new ArrayList(); List annotations = bindingContext.getIndex().getAnnotations( HibernateDotNames.FILTER_DEF ); for ( AnnotationInstance filterDef : annotations ) { - filterDefSources.add( new FilterDefSourceImpl( filterDef ) ); + filterDefinitionSources.add( new FilterDefinitionSourceImpl( filterDef ) ); } annotations = bindingContext.getIndex().getAnnotations( HibernateDotNames.FILTER_DEFS ); @@ -152,10 +151,10 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc AnnotationInstance[].class ); for ( AnnotationInstance filterDef : filterDefAnnotations ) { - filterDefSources.add( new FilterDefSourceImpl( filterDef ) ); + filterDefinitionSources.add( new FilterDefinitionSourceImpl( filterDef ) ); } } - return filterDefSources; + return filterDefinitionSources; } @Override @@ -170,7 +169,6 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc TableProcessor.bind( bindingContext ); FetchProfileProcessor.bind( bindingContext ); QueryProcessor.bind( bindingContext ); - FilterDefProcessor.bind( bindingContext ); } private Index parseAndUpdateIndex(List> mappings, Index annotationIndex) { diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/FilterDefSourceImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/FilterDefinitionSourceImpl.java similarity index 92% rename from hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/FilterDefSourceImpl.java rename to hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/FilterDefinitionSourceImpl.java index 5c66bc1afc..bed9807b93 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/FilterDefSourceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/FilterDefinitionSourceImpl.java @@ -28,18 +28,18 @@ import java.util.List; import org.jboss.jandex.AnnotationInstance; -import org.hibernate.metamodel.spi.source.FilterDefSource; +import org.hibernate.metamodel.spi.source.FilterDefinitionSource; import org.hibernate.metamodel.spi.source.FilterParameterSource; /** * @author Steve Ebersole */ -public class FilterDefSourceImpl implements FilterDefSource { +public class FilterDefinitionSourceImpl implements FilterDefinitionSource { private final String name; private final String condition; private List parameterSources; - public FilterDefSourceImpl(AnnotationInstance filterDefAnnotation) { + public FilterDefinitionSourceImpl(AnnotationInstance filterDefAnnotation) { this.name = JandexHelper.getValue( filterDefAnnotation, "name", String.class ); this.condition = JandexHelper.getValue( filterDefAnnotation, "defaultCondition", String.class ); this.parameterSources = buildParameterSources( filterDefAnnotation ); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/TypeDescriptorSourceImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/TypeDescriptorSourceImpl.java index bb165d1cb3..eac438fcac 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/TypeDescriptorSourceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/TypeDescriptorSourceImpl.java @@ -23,7 +23,6 @@ */ package org.hibernate.metamodel.internal.source.annotations; -import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -39,7 +38,7 @@ import org.hibernate.metamodel.spi.source.TypeDescriptorSource; public class TypeDescriptorSourceImpl implements TypeDescriptorSource { private final String name; private final String implementationClassName; - private final String registrationKey; + private final String[] registrationKeys; private Map parameterValueMap; @@ -53,17 +52,18 @@ public class TypeDescriptorSourceImpl implements TypeDescriptorSource { defaultForType = null; } } - registrationKey = defaultForType; + String registrationKey = defaultForType; if ( StringHelper.isEmpty( name ) && registrationKey == null ) { throw new AnnotationException( String.format( - "Either name or defaultForType (or both) must be set on TypeDef [%s]", + "Either name or defaultForType (or both) must be set on TypeDefinition [%s]", implementationClassName ) ); } + this.registrationKeys = registrationKey == null ? new String[0] : new String[] { registrationKey }; this.parameterValueMap = extractParameterValues( typeDefAnnotation ); } @@ -94,10 +94,8 @@ public class TypeDescriptorSourceImpl implements TypeDescriptorSource { } @Override - public Iterable getRegistrationKeys() { - return registrationKey == null - ? Collections.emptyList() - : Collections.singletonList( registrationKey ); + public String[] getRegistrationKeys() { + return registrationKeys; } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/global/FilterDefProcessor.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/global/FilterDefProcessor.java deleted file mode 100644 index 6956903ccf..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/global/FilterDefProcessor.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2011, 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.global; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.jboss.jandex.AnnotationInstance; -import org.jboss.logging.Logger; - -import org.hibernate.annotations.FilterDef; -import org.hibernate.annotations.FilterDefs; -import org.hibernate.engine.spi.FilterDefinition; -import org.hibernate.internal.CoreMessageLogger; -import org.hibernate.metamodel.spi.source.MetadataImplementor; -import org.hibernate.metamodel.internal.source.annotations.AnnotationBindingContext; -import org.hibernate.metamodel.internal.source.annotations.HibernateDotNames; -import org.hibernate.metamodel.internal.source.annotations.JandexHelper; -import org.hibernate.type.Type; - -/** - * Binds {@link FilterDefs} and {@link FilterDef} annotations. - * - * @author Hardy Ferentschik - */ -public class FilterDefProcessor { - - private static final CoreMessageLogger LOG = Logger.getMessageLogger( - CoreMessageLogger.class, - FilterDefProcessor.class.getName() - ); - - /** - * Binds all {@link FilterDefs} and {@link FilterDef} annotations to the supplied metadata. - * - * @param bindingContext the context for annotation binding - */ - public static void bind(AnnotationBindingContext bindingContext) { - List annotations = bindingContext.getIndex().getAnnotations( HibernateDotNames.FILTER_DEF ); - for ( AnnotationInstance filterDef : annotations ) { - bind( bindingContext.getMetadataImplementor(), filterDef ); - } - - annotations = bindingContext.getIndex().getAnnotations( HibernateDotNames.FILTER_DEFS ); - for ( AnnotationInstance filterDefs : annotations ) { - AnnotationInstance[] filterDefAnnotations = JandexHelper.getValue( - filterDefs, - "value", - AnnotationInstance[].class - ); - for ( AnnotationInstance filterDef : filterDefAnnotations ) { - bind( bindingContext.getMetadataImplementor(), filterDef ); - } - } - } - - private static void bind(MetadataImplementor metadata, AnnotationInstance filterDef) { - String name = JandexHelper.getValue( filterDef, "name", String.class ); - Map prms = new HashMap(); - for ( AnnotationInstance prm : JandexHelper.getValue( filterDef, "parameters", AnnotationInstance[].class ) ) { - prms.put( - JandexHelper.getValue( prm, "name", String.class ), - metadata.getTypeResolver().heuristicType( JandexHelper.getValue( prm, "type", String.class ) ) - ); - } - metadata.addFilterDefinition( - new FilterDefinition( - name, - JandexHelper.getValue( filterDef, "defaultCondition", String.class ), - prms - ) - ); - LOG.debugf( "Binding filter definition: %s", name ); - } - - private FilterDefProcessor() { - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/global/TypeDefProcessor.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/global/TypeDefProcessor.java deleted file mode 100644 index 4aa101fe88..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/global/TypeDefProcessor.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2011, 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.global; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.jboss.jandex.AnnotationInstance; -import org.jboss.logging.Logger; - -import org.hibernate.AnnotationException; -import org.hibernate.annotations.TypeDefs; -import org.hibernate.internal.CoreMessageLogger; -import org.hibernate.internal.util.StringHelper; -import org.hibernate.metamodel.spi.binding.TypeDef; -import org.hibernate.metamodel.spi.source.MetadataImplementor; -import org.hibernate.metamodel.internal.source.annotations.AnnotationBindingContext; -import org.hibernate.metamodel.internal.source.annotations.HibernateDotNames; -import org.hibernate.metamodel.internal.source.annotations.JandexHelper; - -/** - * Binds {@link org.hibernate.annotations.TypeDef} and {@link TypeDefs}. - * - * @author Hardy Ferentschik - */ -public class TypeDefProcessor { - - private static final CoreMessageLogger LOG = Logger.getMessageLogger( - CoreMessageLogger.class, - TypeDefProcessor.class.getName() - ); - - /** - * Binds all {@link org.hibernate.annotations.TypeDef} and {@link TypeDefs} annotations to the supplied metadata. - * - * @param bindingContext the context for annotation binding - */ - public static void bind(AnnotationBindingContext bindingContext) { - List annotations = bindingContext.getIndex().getAnnotations( HibernateDotNames.TYPE_DEF ); - for ( AnnotationInstance typeDef : annotations ) { - bind( bindingContext.getMetadataImplementor(), typeDef ); - } - - annotations = bindingContext.getIndex().getAnnotations( HibernateDotNames.TYPE_DEFS ); - for ( AnnotationInstance typeDefs : annotations ) { - AnnotationInstance[] typeDefAnnotations = JandexHelper.getValue( - typeDefs, - "value", - AnnotationInstance[].class - ); - for ( AnnotationInstance typeDef : typeDefAnnotations ) { - bind( bindingContext.getMetadataImplementor(), typeDef ); - } - } - } - - private static void bind(MetadataImplementor metadata, AnnotationInstance typeDefAnnotation) { - String name = JandexHelper.getValue( typeDefAnnotation, "name", String.class ); - String defaultForType = JandexHelper.getValue( typeDefAnnotation, "defaultForType", String.class ); - String typeClass = JandexHelper.getValue( typeDefAnnotation, "typeClass", String.class ); - - boolean noName = StringHelper.isEmpty( name ); - boolean noDefaultForType = defaultForType == null || defaultForType.equals( void.class.getName() ); - - if ( noName && noDefaultForType ) { - throw new AnnotationException( - "Either name or defaultForType (or both) attribute should be set in TypeDef having typeClass " - + typeClass - ); - } - - Map parameterMaps = new HashMap(); - AnnotationInstance[] parameterAnnotations = JandexHelper.getValue( - typeDefAnnotation, - "parameters", - AnnotationInstance[].class - ); - for ( AnnotationInstance parameterAnnotation : parameterAnnotations ) { - parameterMaps.put( - JandexHelper.getValue( parameterAnnotation, "name", String.class ), - JandexHelper.getValue( parameterAnnotation, "value", String.class ) - ); - } - - if ( !noName ) { - bind( name, typeClass, parameterMaps, metadata ); - } - if ( !noDefaultForType ) { - bind( defaultForType, typeClass, parameterMaps, metadata ); - } - } - - private static void bind( - String name, - String typeClass, - Map prms, - MetadataImplementor metadata) { - LOG.debugf( "Binding type definition: %s", name ); - metadata.addTypeDefinition( new TypeDef( name, typeClass, prms ) ); - } - - private TypeDefProcessor() { - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/FilterDefSourceImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/FilterDefinitionSourceImpl.java similarity index 92% rename from hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/FilterDefSourceImpl.java rename to hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/FilterDefinitionSourceImpl.java index c5f70aa4cd..71c73b4519 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/FilterDefSourceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/FilterDefinitionSourceImpl.java @@ -27,18 +27,18 @@ import java.util.ArrayList; import java.util.List; import org.hibernate.internal.jaxb.mapping.hbm.JaxbHibernateMapping; -import org.hibernate.metamodel.spi.source.FilterDefSource; +import org.hibernate.metamodel.spi.source.FilterDefinitionSource; import org.hibernate.metamodel.spi.source.FilterParameterSource; /** * @author Steve Ebersole */ -public class FilterDefSourceImpl implements FilterDefSource { +public class FilterDefinitionSourceImpl implements FilterDefinitionSource { private final String name; private final String condition; private List parameterSources; - public FilterDefSourceImpl(JaxbHibernateMapping.JaxbFilterDef filterDefElement) { + public FilterDefinitionSourceImpl(JaxbHibernateMapping.JaxbFilterDef filterDefElement) { this.name = filterDefElement.getName(); String conditionAttribute = filterDefElement.getCondition(); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/HbmMetadataSourceProcessorImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/HbmMetadataSourceProcessorImpl.java index b5c53876cc..5dad1ff56d 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/HbmMetadataSourceProcessorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/HbmMetadataSourceProcessorImpl.java @@ -30,7 +30,7 @@ import org.hibernate.internal.jaxb.JaxbRoot; import org.hibernate.internal.jaxb.mapping.hbm.JaxbHibernateMapping; import org.hibernate.metamodel.MetadataSources; import org.hibernate.metamodel.spi.MetadataSourceProcessor; -import org.hibernate.metamodel.spi.source.FilterDefSource; +import org.hibernate.metamodel.spi.source.FilterDefinitionSource; import org.hibernate.metamodel.spi.source.MetadataImplementor; import org.hibernate.metamodel.spi.source.TypeDescriptorSource; @@ -71,7 +71,7 @@ public class HbmMetadataSourceProcessorImpl implements MetadataSourceProcessor { // todo : still need to deal with auxiliary database objects @Override - public Iterable extractTypeDescriptorSources(MetadataSources sources) { + public Iterable extractTypeDefinitionSources(MetadataSources sources) { final List typeDescriptorSources = new ArrayList(); for ( HibernateMappingProcessor processor : processors ) { processor.collectTypeDescriptorSources( typeDescriptorSources ); @@ -80,12 +80,12 @@ public class HbmMetadataSourceProcessorImpl implements MetadataSourceProcessor { } @Override - public Iterable extractFilterDefSources(MetadataSources sources) { - final List filterDefSources = new ArrayList(); + public Iterable extractFilterDefinitionSources(MetadataSources sources) { + final List filterDefinitionSources = new ArrayList(); for ( HibernateMappingProcessor processor : processors ) { - processor.collectFilterDefSources( filterDefSources ); + processor.collectFilterDefSources( filterDefinitionSources ); } - return filterDefSources; + return filterDefinitionSources; } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/HibernateMappingProcessor.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/HibernateMappingProcessor.java index 7fad29133a..21b62be2fc 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/HibernateMappingProcessor.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/HibernateMappingProcessor.java @@ -37,7 +37,7 @@ import org.hibernate.internal.util.Value; import org.hibernate.metamodel.spi.binding.FetchProfile; import org.hibernate.metamodel.spi.relational.AuxiliaryDatabaseObject; import org.hibernate.metamodel.spi.relational.BasicAuxiliaryDatabaseObjectImpl; -import org.hibernate.metamodel.spi.source.FilterDefSource; +import org.hibernate.metamodel.spi.source.FilterDefinitionSource; import org.hibernate.metamodel.spi.source.MappingException; import org.hibernate.metamodel.spi.source.MetadataImplementor; import org.hibernate.metamodel.spi.source.TypeDescriptorSource; @@ -136,13 +136,13 @@ public class HibernateMappingProcessor { } } - public void collectFilterDefSources(List filterDefSources) { + public void collectFilterDefSources(List filterDefinitionSources) { if ( mappingRoot().getFilterDef() == null ) { return; } for ( JaxbHibernateMapping.JaxbFilterDef filterDefElement : mappingRoot().getFilterDef() ) { - filterDefSources.add( new FilterDefSourceImpl( filterDefElement ) ); + filterDefinitionSources.add( new FilterDefinitionSourceImpl( filterDefElement ) ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/TypeDescriptorSourceImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/TypeDescriptorSourceImpl.java index 18cc3aa32a..a982b9db08 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/TypeDescriptorSourceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/TypeDescriptorSourceImpl.java @@ -33,6 +33,8 @@ import org.hibernate.metamodel.spi.source.TypeDescriptorSource; * @author Steve Ebersole */ public class TypeDescriptorSourceImpl implements TypeDescriptorSource { + private static final String[] NO_REGISTRATION_KEYS = new String[0]; + private final String name; private final String implementationClassName; private final Map params; @@ -54,8 +56,8 @@ public class TypeDescriptorSourceImpl implements TypeDescriptorSource { } @Override - public Iterable getRegistrationKeys() { - return Collections.emptyList(); + public String[] getRegistrationKeys() { + return NO_REGISTRATION_KEYS; } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/MetadataSourceProcessor.java b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/MetadataSourceProcessor.java index 96d7ea0134..07bdc65543 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/MetadataSourceProcessor.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/MetadataSourceProcessor.java @@ -25,7 +25,7 @@ package org.hibernate.metamodel.spi; import org.hibernate.metamodel.MetadataSources; import org.hibernate.metamodel.spi.source.EntityHierarchy; -import org.hibernate.metamodel.spi.source.FilterDefSource; +import org.hibernate.metamodel.spi.source.FilterDefinitionSource; import org.hibernate.metamodel.spi.source.TypeDescriptorSource; /** @@ -48,7 +48,7 @@ public interface MetadataSourceProcessor { * * @return The type descriptor sources. */ - public Iterable extractTypeDescriptorSources(MetadataSources sources); + public Iterable extractTypeDefinitionSources(MetadataSources sources); /** * Retrieve the sources pertaining to filter defs. @@ -57,7 +57,7 @@ public interface MetadataSourceProcessor { * * @return The filter def sources. */ - public Iterable extractFilterDefSources(MetadataSources sources); + public Iterable extractFilterDefinitionSources(MetadataSources sources); /** * Retrieve the entity hierarchies. diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/TypeDef.java b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/TypeDefinition.java similarity index 64% rename from hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/TypeDef.java rename to hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/TypeDefinition.java index 27725d7b62..500ea738fc 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/TypeDef.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/TypeDefinition.java @@ -28,30 +28,40 @@ import java.util.Collections; import java.util.Map; /** - * Represents the metamodel view of a typedef (type definition). + * Describes custom type definitions supplied by the user as part of the metadata. * * @author John Verhaeg */ -public class TypeDef implements Serializable { +public class TypeDefinition implements Serializable { private final String name; - private final String typeClass; + private final Class typeImplementorClass; + private final String[] registrationKeys; private final Map parameters; - public TypeDef(String name, String typeClass, Map parameters) { + public TypeDefinition( + String name, + Class typeImplementorClass, + String[] registrationKeys, + Map parameters) { this.name = name; - this.typeClass = typeClass; - this.parameters = parameters; + this.typeImplementorClass = typeImplementorClass; + this.registrationKeys= registrationKeys; + this.parameters = Collections.unmodifiableMap( parameters ); } public String getName() { return name; } - public String getTypeClass() { - return typeClass; - } + public Class getTypeImplementorClass() { + return typeImplementorClass; + } - public Map getParameters() { - return Collections.unmodifiableMap(parameters); + public String[] getRegistrationKeys() { + return registrationKeys; + } + + public Map getParameters() { + return parameters; } } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/FilterDefSource.java b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/FilterDefinitionSource.java similarity index 97% rename from hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/FilterDefSource.java rename to hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/FilterDefinitionSource.java index a9e3bbca91..04d57067de 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/FilterDefSource.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/FilterDefinitionSource.java @@ -29,7 +29,7 @@ package org.hibernate.metamodel.spi.source; * * @author Steve Ebersole */ -public interface FilterDefSource { +public interface FilterDefinitionSource { /** * Retrieve the name of the filter. Would match the related {@link FilterSource#getName} * diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/FilterSource.java b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/FilterSource.java index a40cb8b317..c8010d8542 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/FilterSource.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/FilterSource.java @@ -24,7 +24,7 @@ package org.hibernate.metamodel.spi.source; /** - * Defines the source of filter information. May have an associated {@link FilterDefSource}. + * Defines the source of filter information. May have an associated {@link FilterDefinitionSource}. * Relates to both {@code } and {@link org.hibernate.annotations.Filter @Filter} * * @author Steve Ebersole @@ -43,7 +43,7 @@ public interface FilterSource { * * @return The condition defined on the filter. * - * @see {@link org.hibernate.metamodel.spi.source.FilterDefSource#getCondition()} + * @see {@link FilterDefinitionSource#getCondition()} */ public String getCondition(); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/MetadataImplementor.java b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/MetadataImplementor.java index afac5526eb..a8ab7b158c 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/MetadataImplementor.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/MetadataImplementor.java @@ -33,7 +33,7 @@ import org.hibernate.metamodel.spi.binding.EntityBinding; import org.hibernate.metamodel.spi.binding.FetchProfile; import org.hibernate.metamodel.spi.binding.IdGenerator; import org.hibernate.metamodel.spi.binding.PluralAttributeBinding; -import org.hibernate.metamodel.spi.binding.TypeDef; +import org.hibernate.metamodel.spi.binding.TypeDefinition; import org.hibernate.metamodel.spi.relational.Database; import org.hibernate.service.ServiceRegistry; import org.hibernate.type.TypeResolver; @@ -56,7 +56,7 @@ public interface MetadataImplementor extends Metadata, BindingContext, Mapping { public void addFetchProfile(FetchProfile profile); - public void addTypeDefinition(TypeDef typeDef); + public void addTypeDefinition(TypeDefinition typeDefinition); public void addFilterDefinition(FilterDefinition filterDefinition); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/TypeDescriptorSource.java b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/TypeDescriptorSource.java index f86e942a44..ba7ff6329b 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/TypeDescriptorSource.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/TypeDescriptorSource.java @@ -27,7 +27,7 @@ import java.util.Map; /** * Describes the source of a custom type description. For example, {@code } or - * {@link org.hibernate.annotations.TypeDef @TypeDef} + * {@link org.hibernate.annotations.TypeDef @TypeDefinition} * * @author Steve Ebersole */ @@ -58,7 +58,7 @@ public interface TypeDescriptorSource { * * @return The registration keys for the type built from this type def. */ - public Iterable getRegistrationKeys(); + public String[] getRegistrationKeys(); /** * Types accept configuration. The values here represent the user supplied values that will be given diff --git a/hibernate-core/src/matrix/java/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java b/hibernate-core/src/matrix/java/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java index ea702eafb8..f0d2c266f8 100644 --- a/hibernate-core/src/matrix/java/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java +++ b/hibernate-core/src/matrix/java/org/hibernate/test/annotations/entity/BasicHibernateAnnotationsTest.java @@ -652,7 +652,7 @@ public class BasicHibernateAnnotationsTest extends BaseCoreFunctionalTestCase { } catch( AnnotationException ex ) { assertEquals( - "Either name or defaultForType (or both) attribute should be set in TypeDef having typeClass org.hibernate.test.annotations.entity.PhoneNumberType", + "Either name or defaultForType (or both) attribute should be set in TypeDefinition having typeClass org.hibernate.test.annotations.entity.PhoneNumberType", ex.getMessage()); } } diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/entity/IdentifierGeneratorTest.java b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/entity/IdentifierGeneratorTest.java index a56cd506ef..7a8936300f 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/entity/IdentifierGeneratorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/entity/IdentifierGeneratorTest.java @@ -44,6 +44,8 @@ import org.hibernate.metamodel.spi.binding.EntityIdentifier; import org.hibernate.metamodel.spi.source.MappingException; import org.hibernate.service.ServiceRegistryBuilder; +import org.hibernate.testing.FailureExpected; + import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertNotNull; @@ -170,6 +172,7 @@ public class IdentifierGeneratorTest extends BaseAnnotationBindingTestCase { } @Test + @FailureExpected( jiraKey = "HHH-7040" ) @Resources(annotatedClasses = NamedGeneratorEntity2.class) public void testNamedGenerator() { EntityBinding binding = getEntityBinding( NamedGeneratorEntity2.class ); diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/global/FetchProfileBinderTest.java b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/global/FetchProfileBinderTest.java index 8dba12b079..e723373779 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/global/FetchProfileBinderTest.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/global/FetchProfileBinderTest.java @@ -26,9 +26,6 @@ package org.hibernate.metamodel.internal.source.annotations.global; import java.util.Iterator; import org.jboss.jandex.Index; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; import org.hibernate.MappingException; import org.hibernate.annotations.FetchMode; @@ -41,6 +38,11 @@ import org.hibernate.metamodel.internal.source.annotations.JandexHelper; import org.hibernate.service.ServiceRegistryBuilder; import org.hibernate.service.classloading.spi.ClassLoaderService; import org.hibernate.service.internal.StandardServiceRegistryImpl; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + import org.hibernate.testing.junit4.BaseUnitTestCase; import static junit.framework.Assert.fail;