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 073509a9f8..55c8b0feb2 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 @@ -27,10 +27,12 @@ import java.io.Serializable; import java.sql.Blob; import java.sql.Clob; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; +import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.IndexView; import org.jboss.logging.Logger; @@ -62,6 +64,7 @@ import org.hibernate.metamodel.MetadataSourceProcessingOrder; import org.hibernate.metamodel.MetadataSources; import org.hibernate.metamodel.SessionFactoryBuilder; import org.hibernate.metamodel.internal.source.annotations.AnnotationMetadataSourceProcessorImpl; +import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames; import org.hibernate.metamodel.internal.source.hbm.HbmMetadataSourceProcessorImpl; import org.hibernate.metamodel.spi.AdditionalJaxbRootProducer; import org.hibernate.metamodel.spi.MetadataContributor; @@ -169,7 +172,7 @@ public class MetadataImpl implements MetadataImplementor, Serializable { final IndexView jandexView = options.getJandexView() != null ? metadataSources.wrapJandexView( options.getJandexView() ) : metadataSources.buildJandexView(); - + Collection tables = jandexView.getAnnotations( JPADotNames.TABLE ); final MetadataSourceProcessor[] metadataSourceProcessors; if ( options.getMetadataSourceProcessingOrder() == MetadataSourceProcessingOrder.HBM_FIRST ) { metadataSourceProcessors = new MetadataSourceProcessor[] { diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/xml/mocker/IndexBuilder.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/xml/mocker/IndexBuilder.java index 5085754673..7beeb0fb0b 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/xml/mocker/IndexBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/xml/mocker/IndexBuilder.java @@ -90,17 +90,19 @@ public class IndexBuilder { //this class has been overrided by orm.xml continue; } - if ( ci.annotations() != null && !ci.annotations().isEmpty() ) { + ClassInfo mockedClassInfo = createClassInfo( name.toString() ); + if ( CollectionHelper.isNotEmpty( ci.annotations() ) ) { Map> tmp = new HashMap>( ci.annotations() ); DefaultConfigurationHelper.INSTANCE.applyDefaults( tmp, globalDefaults ); mergeAnnotationMap( tmp, annotations ); - classes.put( name, ci ); - if ( ci.superName() != null ) { - addSubClasses( ci.superName(), ci ); - } - if ( ci.interfaces() != null && ci.interfaces().length > 0 ) { - addImplementors( ci.interfaces(), ci ); - } + classInfoAnnotationsMap.get( name ).putAll( tmp ); +// classes.put( name, ci ); +// if ( ci.superName() != null ) { +// addSubClasses( ci.superName(), ci ); +// } +// if ( CollectionHelper.isNotEmpty( ci.interfaces() ) ) { +// addImplementors( ci.interfaces(), ci ); +// } } } return Index.create( diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/id/sequences/HibernateSequenceTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/id/sequences/HibernateSequenceTest.java index 1385a81693..bc44de2b94 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/id/sequences/HibernateSequenceTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/id/sequences/HibernateSequenceTest.java @@ -11,9 +11,9 @@ import org.hibernate.id.IdentifierGenerator; import org.hibernate.id.enhanced.SequenceStyleGenerator; import org.hibernate.mapping.Table; import org.hibernate.metamodel.MetadataSources; +import org.hibernate.metamodel.spi.binding.EntityBinding; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.test.annotations.id.sequences.entities.HibernateSequenceEntity; -import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; @@ -52,8 +52,10 @@ public class HibernateSequenceTest extends BaseCoreFunctionalTestCase { } @Test - @FailureExpectedWithNewMetamodel public void testHibernateSequenceSchema() { + EntityBinding entityBinding = metadata().getEntityBinding( HibernateSequenceEntity.class.getName() ); + org.hibernate.metamodel.spi.relational.Table table = (org.hibernate.metamodel.spi.relational.Table ) entityBinding.getPrimaryTable(); + Assert.assertEquals( SCHEMA_NAME, table.getSchema().getName().getSchema().getText() ); EntityPersister persister = sessionFactory().getEntityPersister( HibernateSequenceEntity.class.getName() ); IdentifierGenerator generator = persister.getIdentifierGenerator(); Assert.assertTrue( SequenceStyleGenerator.class.isInstance( generator ) );