HHH-8201 global info defined in the orm.xml is not mocked into entity annotation

This commit is contained in:
Strong Liu 2013-04-24 00:57:45 +08:00
parent a0ccbb425b
commit 262c109e64
3 changed files with 18 additions and 11 deletions

View File

@ -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<AnnotationInstance> tables = jandexView.getAnnotations( JPADotNames.TABLE );
final MetadataSourceProcessor[] metadataSourceProcessors;
if ( options.getMetadataSourceProcessingOrder() == MetadataSourceProcessingOrder.HBM_FIRST ) {
metadataSourceProcessors = new MetadataSourceProcessor[] {

View File

@ -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<DotName, List<AnnotationInstance>> tmp = new HashMap<DotName, List<AnnotationInstance>>( 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(

View File

@ -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 ) );