HHH-7514 - Upgrade to Jandex 1.1

This commit is contained in:
Steve Ebersole 2012-08-22 17:35:35 -05:00
parent 8c1923ee05
commit 581f037dee
27 changed files with 250 additions and 199 deletions

View File

@ -62,7 +62,7 @@ libraries = [
// Annotations // Annotations
commons_annotations: commons_annotations:
'org.hibernate.common:hibernate-commons-annotations:4.0.1.Final@jar', 'org.hibernate.common:hibernate-commons-annotations:4.0.1.Final@jar',
jandex: 'org.jboss:jandex:1.0.3.Final', jandex: 'org.jboss:jandex:1.1.0.Alpha1',
classmate: 'com.fasterxml:classmate:0.5.4', classmate: 'com.fasterxml:classmate:0.5.4',
// Dom4J // Dom4J

View File

@ -26,6 +26,7 @@ package org.hibernate.metamodel;
import java.util.Map; import java.util.Map;
import javax.persistence.SharedCacheMode; import javax.persistence.SharedCacheMode;
import org.jboss.jandex.IndexView;
import org.xml.sax.EntityResolver; import org.xml.sax.EntityResolver;
import org.hibernate.MultiTenancyStrategy; import org.hibernate.MultiTenancyStrategy;
@ -60,6 +61,7 @@ public interface Metadata {
public String getDefaultSchemaName(); public String getDefaultSchemaName();
public String getDefaultCatalogName(); public String getDefaultCatalogName();
public MultiTenancyStrategy getMultiTenancyStrategy(); public MultiTenancyStrategy getMultiTenancyStrategy();
public IndexView getJandexView();
} }
/** /**

View File

@ -25,6 +25,7 @@ package org.hibernate.metamodel;
import javax.persistence.SharedCacheMode; import javax.persistence.SharedCacheMode;
import org.jboss.jandex.IndexView;
import org.xml.sax.EntityResolver; import org.xml.sax.EntityResolver;
import org.hibernate.cache.spi.access.AccessType; import org.hibernate.cache.spi.access.AccessType;
@ -45,6 +46,8 @@ public interface MetadataBuilder {
public MetadataBuilder with(AccessType accessType); public MetadataBuilder with(AccessType accessType);
public MetadataBuilder with(IndexView jandexView);
public MetadataBuilder withNewIdentifierGeneratorsEnabled(boolean enabled); public MetadataBuilder withNewIdentifierGeneratorsEnabled(boolean enabled);
public Metadata buildMetadata(); public Metadata buildMetadata();

View File

@ -31,20 +31,28 @@ import java.io.InputStream;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashSet;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.jboss.jandex.IndexView;
import org.jboss.jandex.Indexer;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.hibernate.HibernateException;
import org.hibernate.boot.spi.CacheRegionDefinition; import org.hibernate.boot.spi.CacheRegionDefinition;
import org.hibernate.jaxb.internal.JaxbMappingProcessor; import org.hibernate.jaxb.internal.JaxbMappingProcessor;
import org.hibernate.jaxb.spi.JaxbRoot; import org.hibernate.jaxb.spi.JaxbRoot;
import org.hibernate.jaxb.spi.Origin; import org.hibernate.jaxb.spi.Origin;
import org.hibernate.jaxb.spi.SourceType; import org.hibernate.jaxb.spi.SourceType;
import org.hibernate.jaxb.spi.orm.JaxbEntityMappings;
import org.hibernate.metamodel.internal.MetadataBuilderImpl; import org.hibernate.metamodel.internal.MetadataBuilderImpl;
import org.hibernate.metamodel.internal.source.annotations.xml.mocker.EntityMappingsMocker;
import org.hibernate.metamodel.spi.source.MappingException; import org.hibernate.metamodel.spi.source.MappingException;
import org.hibernate.metamodel.spi.source.MappingNotFoundException; import org.hibernate.metamodel.spi.source.MappingNotFoundException;
import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistry;
@ -59,18 +67,17 @@ import org.hibernate.service.classloading.spi.ClassLoaderService;
public class MetadataSources { public class MetadataSources {
private static final Logger LOG = Logger.getLogger( MetadataSources.class ); private static final Logger LOG = Logger.getLogger( MetadataSources.class );
private final List<CacheRegionDefinition> externalCacheRegionDefinitions = new ArrayList<CacheRegionDefinition>();
private final JaxbMappingProcessor jaxbProcessor;
private final ServiceRegistry serviceRegistry;
private final MetadataBuilderImpl metadataBuilder;
private List<JaxbRoot> jaxbRootList = new ArrayList<JaxbRoot>(); private List<JaxbRoot> jaxbRootList = new ArrayList<JaxbRoot>();
private LinkedHashSet<Class<?>> annotatedClasses = new LinkedHashSet<Class<?>>(); private LinkedHashSet<Class<?>> annotatedClasses = new LinkedHashSet<Class<?>>();
private LinkedHashSet<String> annotatedClassNames = new LinkedHashSet<String>(); private LinkedHashSet<String> annotatedClassNames = new LinkedHashSet<String>();
private LinkedHashSet<String> annotatedPackages = new LinkedHashSet<String>(); private LinkedHashSet<String> annotatedPackages = new LinkedHashSet<String>();
private final List<CacheRegionDefinition> externalCacheRegionDefinitions = new ArrayList<CacheRegionDefinition>(); private boolean hasOrmXmlJaxbRoots;
private final JaxbMappingProcessor jaxbProcessor;
private final ServiceRegistry serviceRegistry;
private final MetadataBuilderImpl metadataBuilder;
/** /**
* Create a metadata sources using the specified service registry. * Create a metadata sources using the specified service registry.
@ -108,6 +115,11 @@ public class MetadataSources {
return serviceRegistry; return serviceRegistry;
} }
public boolean hasOrmXmlJaxbRoots() {
return hasOrmXmlJaxbRoots;
}
/** /**
* Get a builder for metadata where non-default options can be specified. * Get a builder for metadata where non-default options can be specified.
* *
@ -197,7 +209,7 @@ public class MetadataSources {
private JaxbRoot add(InputStream inputStream, Origin origin, boolean close) { private JaxbRoot add(InputStream inputStream, Origin origin, boolean close) {
try { try {
JaxbRoot jaxbRoot = jaxbProcessor.unmarshal( inputStream, origin ); JaxbRoot jaxbRoot = jaxbProcessor.unmarshal( inputStream, origin );
jaxbRootList.add( jaxbRoot ); addJaxbRoot( jaxbRoot );
return jaxbRoot; return jaxbRoot;
} }
finally { finally {
@ -336,10 +348,15 @@ public class MetadataSources {
public MetadataSources addDocument(Document document) { public MetadataSources addDocument(Document document) {
final Origin origin = new Origin( SourceType.DOM, "<unknown>" ); final Origin origin = new Origin( SourceType.DOM, "<unknown>" );
JaxbRoot jaxbRoot = jaxbProcessor.unmarshal( document, origin ); JaxbRoot jaxbRoot = jaxbProcessor.unmarshal( document, origin );
jaxbRootList.add( jaxbRoot ); addJaxbRoot( jaxbRoot );
return this; return this;
} }
private void addJaxbRoot(JaxbRoot jaxbRoot) {
hasOrmXmlJaxbRoots = hasOrmXmlJaxbRoots || JaxbEntityMappings.class.isInstance( jaxbRoot.getRoot() );
jaxbRootList.add( jaxbRoot );
}
/** /**
* Read all mappings from a jar file. * Read all mappings from a jar file.
* <p/> * <p/>
@ -412,4 +429,71 @@ public class MetadataSources {
externalCacheRegionDefinitions.addAll( cacheRegionDefinitions ); externalCacheRegionDefinitions.addAll( cacheRegionDefinitions );
return this; return this;
} }
@SuppressWarnings("unchecked")
public IndexView wrapJandexView(IndexView jandexView) {
if ( ! hasOrmXmlJaxbRoots ) {
// no need to wrap
return jandexView;
}
final List<JaxbEntityMappings> collectedOrmXmlMappings = new ArrayList<JaxbEntityMappings>();
for ( JaxbRoot jaxbRoot : getJaxbRootList() ) {
if ( JaxbEntityMappings.class.isInstance( jaxbRoot.getRoot() ) ) {
collectedOrmXmlMappings.add( ( (JaxbRoot<JaxbEntityMappings>) jaxbRoot ).getRoot() );
}
}
if ( collectedOrmXmlMappings.isEmpty() ) {
// log a warning or something
}
return new EntityMappingsMocker( collectedOrmXmlMappings, jandexView, serviceRegistry ).mockNewIndex();
}
public IndexView buildJandexView() {
// create a jandex index from the annotated classes
Indexer indexer = new Indexer();
Set<String> processedNames = new HashSet<String>();
for ( Class<?> clazz : getAnnotatedClasses() ) {
indexClass( clazz, indexer, processedNames );
}
for ( String className : getAnnotatedClassNames() ) {
indexResource( className.replace( '.', '/' ) + ".class", indexer, processedNames );
}
// add package-info from the configured packages
for ( String packageName : getAnnotatedPackages() ) {
indexResource( packageName.replace( '.', '/' ) + "/package-info.class", indexer, processedNames );
}
return wrapJandexView( indexer.complete() );
}
private void indexClass(Class clazz, Indexer indexer, Set<String> processedNames) {
if ( clazz == null ) {
return;
}
indexResource( clazz.getName().replace( '.', '/' ) + ".class", indexer, processedNames );
// index all super classes of the specified class. Using org.hibernate.cfg.Configuration it was not
// necessary to add all annotated classes. Entities would be enough. Mapped superclasses would be
// discovered while processing the annotations. To keep this behavior we index all classes in the
// hierarchy (see also HHH-7484)
indexClass( clazz.getSuperclass(), indexer, processedNames );
}
private void indexResource(String resourceName, Indexer indexer, Set<String> processedNames) {
InputStream stream = serviceRegistry.getService( ClassLoaderService.class ).locateResourceStream( resourceName );
try {
indexer.index( stream );
}
catch ( IOException e ) {
throw new HibernateException( "Unable to open input stream for resource " + resourceName, e );
}
}
} }

View File

@ -25,6 +25,7 @@ package org.hibernate.metamodel.internal;
import javax.persistence.SharedCacheMode; import javax.persistence.SharedCacheMode;
import org.jboss.jandex.IndexView;
import org.xml.sax.EntityResolver; import org.xml.sax.EntityResolver;
import org.hibernate.MultiTenancyStrategy; import org.hibernate.MultiTenancyStrategy;
@ -90,6 +91,12 @@ public class MetadataBuilderImpl implements MetadataBuilder {
return this; return this;
} }
@Override
public MetadataBuilder with(IndexView jandexView) {
this.options.jandexView = jandexView;
return this;
}
@Override @Override
public MetadataBuilder withNewIdentifierGeneratorsEnabled(boolean enabled) { public MetadataBuilder withNewIdentifierGeneratorsEnabled(boolean enabled) {
this.options.useNewIdentifierGenerators = enabled; this.options.useNewIdentifierGenerators = enabled;
@ -114,6 +121,7 @@ public class MetadataBuilderImpl implements MetadataBuilder {
private String defaultSchemaName; private String defaultSchemaName;
private String defaultCatalogName; private String defaultCatalogName;
private MultiTenancyStrategy multiTenancyStrategy; private MultiTenancyStrategy multiTenancyStrategy;
public IndexView jandexView;
public OptionsImpl(ServiceRegistry serviceRegistry) { public OptionsImpl(ServiceRegistry serviceRegistry) {
ConfigurationService configService = serviceRegistry.getService( ConfigurationService.class ); ConfigurationService configService = serviceRegistry.getService( ConfigurationService.class );
@ -215,5 +223,10 @@ public class MetadataBuilderImpl implements MetadataBuilder {
public MultiTenancyStrategy getMultiTenancyStrategy() { public MultiTenancyStrategy getMultiTenancyStrategy() {
return multiTenancyStrategy; return multiTenancyStrategy;
} }
@Override
public IndexView getJandexView() {
return jandexView;
}
} }
} }

View File

@ -29,6 +29,10 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.jboss.jandex.IndexView;
import org.jboss.logging.Logger;
import org.hibernate.AssertionFailure; import org.hibernate.AssertionFailure;
import org.hibernate.DuplicateMappingException; import org.hibernate.DuplicateMappingException;
import org.hibernate.MappingException; import org.hibernate.MappingException;
@ -45,8 +49,8 @@ import org.hibernate.engine.spi.SyntheticAttributeHelper;
import org.hibernate.id.factory.IdentifierGeneratorFactory; import org.hibernate.id.factory.IdentifierGeneratorFactory;
import org.hibernate.id.factory.spi.MutableIdentifierGeneratorFactory; import org.hibernate.id.factory.spi.MutableIdentifierGeneratorFactory;
import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.jaxb.spi.JaxbRoot;
import org.hibernate.internal.util.ValueHolder; import org.hibernate.internal.util.ValueHolder;
import org.hibernate.jaxb.spi.JaxbRoot;
import org.hibernate.metamodel.MetadataSourceProcessingOrder; import org.hibernate.metamodel.MetadataSourceProcessingOrder;
import org.hibernate.metamodel.MetadataSources; import org.hibernate.metamodel.MetadataSources;
import org.hibernate.metamodel.SessionFactoryBuilder; import org.hibernate.metamodel.SessionFactoryBuilder;
@ -82,7 +86,6 @@ import org.hibernate.metamodel.spi.source.TypeDescriptorSource;
import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.classloading.spi.ClassLoaderService; import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.type.TypeResolver; import org.hibernate.type.TypeResolver;
import org.jboss.logging.Logger;
/** /**
* Container for configuration data collected during binding the metamodel. * Container for configuration data collected during binding the metamodel.
@ -101,7 +104,7 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
private final ServiceRegistry serviceRegistry; private final ServiceRegistry serviceRegistry;
private final Options options; private final Options options;
private final ValueHolder<ClassLoaderService> classLoaderService; private final ClassLoaderService classLoaderService;
// private final ValueHolder<PersisterClassResolver> persisterClassResolverService; // private final ValueHolder<PersisterClassResolver> persisterClassResolverService;
private TypeResolver typeResolver = new TypeResolver(); private TypeResolver typeResolver = new TypeResolver();
@ -147,28 +150,26 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
} }
}; };
// todo : cache the built index if no inputs have changed (look at gradle-style hashing for up-to-date checking)
final IndexView jandexView = options.getJandexView() != null
? metadataSources.wrapJandexView( options.getJandexView() )
: metadataSources.buildJandexView();
final MetadataSourceProcessor[] metadataSourceProcessors; final MetadataSourceProcessor[] metadataSourceProcessors;
if ( options.getMetadataSourceProcessingOrder() == MetadataSourceProcessingOrder.HBM_FIRST ) { if ( options.getMetadataSourceProcessingOrder() == MetadataSourceProcessingOrder.HBM_FIRST ) {
metadataSourceProcessors = new MetadataSourceProcessor[] { metadataSourceProcessors = new MetadataSourceProcessor[] {
new HbmMetadataSourceProcessorImpl( this, metadataSources ), new HbmMetadataSourceProcessorImpl( this, metadataSources ),
new AnnotationMetadataSourceProcessorImpl( this, metadataSources ) new AnnotationMetadataSourceProcessorImpl( this, metadataSources, jandexView )
}; };
} }
else { else {
metadataSourceProcessors = new MetadataSourceProcessor[] { metadataSourceProcessors = new MetadataSourceProcessor[] {
new AnnotationMetadataSourceProcessorImpl( this, metadataSources ), new AnnotationMetadataSourceProcessorImpl( this, metadataSources, jandexView ),
new HbmMetadataSourceProcessorImpl( this, metadataSources ) new HbmMetadataSourceProcessorImpl( this, metadataSources )
}; };
} }
this.classLoaderService = new ValueHolder<ClassLoaderService>( this.classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
new ValueHolder.DeferredInitializer<ClassLoaderService>() {
@Override
public ClassLoaderService initialize() {
return serviceRegistry.getService( ClassLoaderService.class );
}
}
);
// this.persisterClassResolverService = new ValueHolder<PersisterClassResolver>( // this.persisterClassResolverService = new ValueHolder<PersisterClassResolver>(
// new ValueHolder.DeferredInitializer<PersisterClassResolver>() { // new ValueHolder.DeferredInitializer<PersisterClassResolver>() {
// @Override // @Override
@ -180,8 +181,7 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
processTypeDefinitions( metadataSourceProcessors ); processTypeDefinitions( metadataSourceProcessors );
for ( TypeContributor contributor : for ( TypeContributor contributor : classLoaderService.loadJavaServices( TypeContributor.class ) ) {
serviceRegistry.getService( ClassLoaderService.class ).loadJavaServices( TypeContributor.class ) ) {
contributor.contribute( this ); contributor.contribute( this );
} }
@ -190,17 +190,14 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
processMappings( metadataSourceProcessors ); processMappings( metadataSourceProcessors );
bindMappingDependentMetadata( metadataSourceProcessors ); bindMappingDependentMetadata( metadataSourceProcessors );
for ( MetadataContributor contributor : for ( MetadataContributor contributor : classLoaderService.loadJavaServices( MetadataContributor.class ) ) {
serviceRegistry.getService( ClassLoaderService.class ).loadJavaServices( MetadataContributor.class ) ) { contributor.contribute( this, jandexView );
// todo : handle Jandex index here...
contributor.contribute( this, null );
} }
final List<JaxbRoot> jaxbRoots = new ArrayList<JaxbRoot>(); final List<JaxbRoot> jaxbRoots = new ArrayList<JaxbRoot>();
for ( AdditionalJaxbRootProducer producer : for ( AdditionalJaxbRootProducer producer : classLoaderService.loadJavaServices( AdditionalJaxbRootProducer.class ) ) {
serviceRegistry.getService( ClassLoaderService.class ).loadJavaServices( AdditionalJaxbRootProducer.class ) ) {
// todo : handle Jandex index here... // todo : handle Jandex index here...
jaxbRoots.addAll( producer.produceRoots( this, null ) ); jaxbRoots.addAll( producer.produceRoots( this, jandexView ) );
} }
final HbmMetadataSourceProcessorImpl processor = new HbmMetadataSourceProcessorImpl( this, jaxbRoots ); final HbmMetadataSourceProcessorImpl processor = new HbmMetadataSourceProcessorImpl( this, jaxbRoots );
final Binder binder = new Binder( this, identifierGeneratorFactory ); final Binder binder = new Binder( this, identifierGeneratorFactory );
@ -208,6 +205,7 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
} }
// type definitions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // type definitions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
private void processTypeDefinitions(MetadataSourceProcessor[] metadataSourceProcessors) { private void processTypeDefinitions(MetadataSourceProcessor[] metadataSourceProcessors) {
@ -216,7 +214,7 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
addTypeDefinition( addTypeDefinition(
new TypeDefinition( new TypeDefinition(
typeDescriptorSource.getName(), typeDescriptorSource.getName(),
classLoaderService().classForName( typeDescriptorSource.getTypeImplementationClassName() ), classLoaderService.classForName( typeDescriptorSource.getTypeImplementationClassName() ),
typeDescriptorSource.getRegistrationKeys(), typeDescriptorSource.getRegistrationKeys(),
typeDescriptorSource.getParameters() typeDescriptorSource.getParameters()
) )
@ -318,7 +316,7 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
@Override @Override
public void registerIdentifierGenerator(String name, String generatorClassName) { public void registerIdentifierGenerator(String name, String generatorClassName) {
identifierGeneratorFactory.register( name, classLoaderService().classForName( generatorClassName ) ); identifierGeneratorFactory.register( name, classLoaderService.classForName( generatorClassName ) );
} }
private void processMappings(MetadataSourceProcessor[] metadataSourceProcessors) { private void processMappings(MetadataSourceProcessor[] metadataSourceProcessors) {
@ -409,8 +407,11 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
@Override @Override
public void addNamedNativeQuery(NamedSQLQueryDefinition def) { public void addNamedNativeQuery(NamedSQLQueryDefinition def) {
if ( def == null || def.getName() == null ) { if ( def == null ) {
throw new IllegalArgumentException( "Named native query definition object or name is null: " + def.getQueryString() ); throw new IllegalArgumentException( "Named native query definition object is null" );
}
if ( def.getName() == null ) {
throw new IllegalArgumentException( "Named native query definition name is null: " + def.getQueryString() );
} }
namedNativeQueryDefs.put( def.getName(), def ); namedNativeQueryDefs.put( def.getName(), def );
} }
@ -470,10 +471,6 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
return resultSetMappings; return resultSetMappings;
} }
private ClassLoaderService classLoaderService() {
return classLoaderService.getValue();
}
// private PersisterClassResolver persisterClassResolverService() { // private PersisterClassResolver persisterClassResolverService() {
// return persisterClassResolverService.getValue(); // return persisterClassResolverService.getValue();
// } // }
@ -491,7 +488,7 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
@Override @Override
@SuppressWarnings( {"unchecked"}) @SuppressWarnings( {"unchecked"})
public <T> Class<T> locateClassByName(String name) { public <T> Class<T> locateClassByName(String name) {
return classLoaderService().classForName( name ); return classLoaderService.classForName( name );
} }
@Override @Override
@ -506,7 +503,7 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
new ValueHolder.DeferredInitializer<Class<?>>() { new ValueHolder.DeferredInitializer<Class<?>>() {
@Override @Override
public Class<?> initialize() { public Class<?> initialize() {
return classLoaderService.getValue().classForName( className ); return classLoaderService.classForName( className );
} }
} }
); );

View File

@ -26,7 +26,7 @@ package org.hibernate.metamodel.internal.source.annotations;
import com.fasterxml.classmate.ResolvedType; import com.fasterxml.classmate.ResolvedType;
import com.fasterxml.classmate.ResolvedTypeWithMembers; import com.fasterxml.classmate.ResolvedTypeWithMembers;
import org.jboss.jandex.ClassInfo; import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.Index; import org.jboss.jandex.IndexView;
import org.hibernate.metamodel.spi.binding.IdGenerator; import org.hibernate.metamodel.spi.binding.IdGenerator;
import org.hibernate.metamodel.spi.source.BindingContext; import org.hibernate.metamodel.spi.source.BindingContext;
@ -39,7 +39,7 @@ import org.hibernate.metamodel.spi.source.IdentifierGeneratorSource;
* @author Hardy Ferentschik * @author Hardy Ferentschik
*/ */
public interface AnnotationBindingContext extends BindingContext { public interface AnnotationBindingContext extends BindingContext {
Index getIndex(); IndexView getIndex();
ClassInfo getClassInfo(String name); ClassInfo getClassInfo(String name);

View File

@ -33,6 +33,7 @@ import com.fasterxml.classmate.TypeResolver;
import org.jboss.jandex.ClassInfo; import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName; import org.jboss.jandex.DotName;
import org.jboss.jandex.Index; import org.jboss.jandex.Index;
import org.jboss.jandex.IndexView;
import org.hibernate.cfg.NamingStrategy; import org.hibernate.cfg.NamingStrategy;
import org.hibernate.internal.util.ValueHolder; import org.hibernate.internal.util.ValueHolder;
@ -50,13 +51,13 @@ import org.hibernate.service.classloading.spi.ClassLoaderService;
public class AnnotationBindingContextImpl implements AnnotationBindingContext { public class AnnotationBindingContextImpl implements AnnotationBindingContext {
private final MetadataImplementor metadata; private final MetadataImplementor metadata;
private final ValueHolder<ClassLoaderService> classLoaderService; private final ValueHolder<ClassLoaderService> classLoaderService;
private final Index index; private final IndexView index;
private final TypeResolver typeResolver = new TypeResolver(); private final TypeResolver typeResolver = new TypeResolver();
private final Map<Class<?>, ResolvedType> resolvedTypeCache = new HashMap<Class<?>, ResolvedType>(); private final Map<Class<?>, ResolvedType> resolvedTypeCache = new HashMap<Class<?>, ResolvedType>();
private final IdentifierGeneratorExtractionDelegate identifierGeneratorSourceCreationDelegate; private final IdentifierGeneratorExtractionDelegate identifierGeneratorSourceCreationDelegate;
public AnnotationBindingContextImpl(MetadataImplementor metadata, Index index) { public AnnotationBindingContextImpl(MetadataImplementor metadata, IndexView index) {
this.metadata = metadata; this.metadata = metadata;
this.classLoaderService = new ValueHolder<ClassLoaderService>( this.classLoaderService = new ValueHolder<ClassLoaderService>(
new ValueHolder.DeferredInitializer<ClassLoaderService>() { new ValueHolder.DeferredInitializer<ClassLoaderService>() {
@ -75,7 +76,7 @@ public class AnnotationBindingContextImpl implements AnnotationBindingContext {
} }
@Override @Override
public Index getIndex() { public IndexView getIndex() {
return index; return index;
} }

View File

@ -23,24 +23,15 @@
*/ */
package org.hibernate.metamodel.internal.source.annotations; package org.hibernate.metamodel.internal.source.annotations;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.Index; import org.jboss.jandex.IndexView;
import org.jboss.jandex.Indexer;
import org.hibernate.AssertionFailure; import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
import org.hibernate.jaxb.spi.JaxbRoot;
import org.hibernate.jaxb.spi.Origin;
import org.hibernate.jaxb.spi.SourceType;
import org.hibernate.jaxb.spi.orm.JaxbEntityMappings;
import org.hibernate.metamodel.MetadataSources; import org.hibernate.metamodel.MetadataSources;
import org.hibernate.metamodel.internal.MetadataImpl; import org.hibernate.metamodel.internal.MetadataImpl;
import org.hibernate.metamodel.internal.source.annotations.global.FetchProfileProcessor; import org.hibernate.metamodel.internal.source.annotations.global.FetchProfileProcessor;
@ -52,16 +43,12 @@ 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.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper; import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.internal.source.annotations.xml.PseudoJpaDotNames; import org.hibernate.metamodel.internal.source.annotations.xml.PseudoJpaDotNames;
import org.hibernate.metamodel.internal.source.annotations.xml.mocker.EntityMappingsMocker;
import org.hibernate.metamodel.spi.MetadataImplementor; import org.hibernate.metamodel.spi.MetadataImplementor;
import org.hibernate.metamodel.spi.MetadataSourceProcessor; import org.hibernate.metamodel.spi.MetadataSourceProcessor;
import org.hibernate.metamodel.spi.source.EntityHierarchy; import org.hibernate.metamodel.spi.source.EntityHierarchy;
import org.hibernate.metamodel.spi.source.FilterDefinitionSource; import org.hibernate.metamodel.spi.source.FilterDefinitionSource;
import org.hibernate.metamodel.spi.source.IdentifierGeneratorSource; import org.hibernate.metamodel.spi.source.IdentifierGeneratorSource;
import org.hibernate.metamodel.spi.source.MappingException;
import org.hibernate.metamodel.spi.source.TypeDescriptorSource; import org.hibernate.metamodel.spi.source.TypeDescriptorSource;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.classloading.spi.ClassLoadingException;
/** /**
* Main class responsible to creating and binding the Hibernate meta-model from annotations. * Main class responsible to creating and binding the Hibernate meta-model from annotations.
@ -73,57 +60,24 @@ import org.hibernate.service.classloading.spi.ClassLoadingException;
*/ */
public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProcessor { public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProcessor {
private final MetadataImplementor metadata; private final MetadataImplementor metadata;
private final IndexView jandexView;
private AnnotationBindingContext bindingContext; private AnnotationBindingContext bindingContext;
public AnnotationMetadataSourceProcessorImpl(MetadataImpl metadata, MetadataSources metadataSources) { public AnnotationMetadataSourceProcessorImpl(
MetadataImpl metadata,
MetadataSources metadataSources,
IndexView jandexView) {
this.metadata = metadata; this.metadata = metadata;
this.jandexView = jandexView;
// todo : use the Jandex from JBoss/JPA if available... if ( !jandexView.getAnnotations( PseudoJpaDotNames.DEFAULT_DELIMITED_IDENTIFIERS ).isEmpty() ) {
// todo : cache the built index if no inputs have changed (look at gradle-style hashing for up-to-date checking)
// create a jandex index from the annotated classes
Set<String> processedNames = new HashSet<String>();
Indexer indexer = new Indexer();
for ( Class<?> clazz : metadataSources.getAnnotatedClasses() ) {
indexClass( indexer, clazz, processedNames );
}
for ( String className : metadataSources.getAnnotatedClassNames() ) {
Class<?> clazz;
try {
clazz = metadata.getServiceRegistry().getService( ClassLoaderService.class ).classForName( className );
}
catch ( ClassLoadingException e ) {
throw new MappingException( "Unable to load a configured class", new Origin( SourceType.FILE, null ) );
}
indexClass( indexer, clazz, processedNames );
}
// add package-info from the configured packages
for ( String packageName : metadataSources.getAnnotatedPackages() ) {
indexClass( indexer, packageName.replace( '.', '/' ) + "/package-info.class", processedNames );
}
Index index = indexer.complete();
List<JaxbRoot<JaxbEntityMappings>> mappings = new ArrayList<JaxbRoot<JaxbEntityMappings>>();
for ( JaxbRoot<?> root : metadataSources.getJaxbRootList() ) {
if ( root.getRoot() instanceof JaxbEntityMappings ) {
mappings.add( ( JaxbRoot<JaxbEntityMappings> ) root );
}
}
if ( !mappings.isEmpty() ) {
index = parseAndUpdateIndex( mappings, index );
}
if ( !index.getAnnotations( PseudoJpaDotNames.DEFAULT_DELIMITED_IDENTIFIERS ).isEmpty() ) {
// todo : this needs to move to AnnotationBindingContext // todo : this needs to move to AnnotationBindingContext
// what happens right now is that specifying this in an orm.xml causes it to effect all orm.xmls // what happens right now is that specifying this in an orm.xml causes it to effect all orm.xmls
metadata.setGloballyQuotedIdentifiers( true ); metadata.setGloballyQuotedIdentifiers( true );
} }
bindingContext = new AnnotationBindingContextImpl( metadata, index ); bindingContext = new AnnotationBindingContextImpl( metadata, jandexView );
} }
@Override @Override
@ -131,7 +85,7 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
assertBindingContextExists(); assertBindingContextExists();
List<TypeDescriptorSource> typeDescriptorSources = new ArrayList<TypeDescriptorSource>(); List<TypeDescriptorSource> typeDescriptorSources = new ArrayList<TypeDescriptorSource>();
List<AnnotationInstance> annotations = bindingContext.getIndex().getAnnotations( HibernateDotNames.TYPE_DEF ); Collection<AnnotationInstance> annotations = bindingContext.getIndex().getAnnotations( HibernateDotNames.TYPE_DEF );
for ( AnnotationInstance typeDef : annotations ) { for ( AnnotationInstance typeDef : annotations ) {
typeDescriptorSources.add( new TypeDescriptorSourceImpl( typeDef ) ); typeDescriptorSources.add( new TypeDescriptorSourceImpl( typeDef ) );
} }
@ -161,7 +115,7 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
assertBindingContextExists(); assertBindingContextExists();
List<FilterDefinitionSource> filterDefinitionSources = new ArrayList<FilterDefinitionSource>(); List<FilterDefinitionSource> filterDefinitionSources = new ArrayList<FilterDefinitionSource>();
List<AnnotationInstance> annotations = bindingContext.getIndex().getAnnotations( HibernateDotNames.FILTER_DEF ); Collection<AnnotationInstance> annotations = bindingContext.getIndex().getAnnotations( HibernateDotNames.FILTER_DEF );
for ( AnnotationInstance filterDef : annotations ) { for ( AnnotationInstance filterDef : annotations ) {
filterDefinitionSources.add( new FilterDefinitionSourceImpl( filterDef ) ); filterDefinitionSources.add( new FilterDefinitionSourceImpl( filterDef ) );
} }
@ -205,44 +159,6 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
} }
private Index parseAndUpdateIndex(List<JaxbRoot<JaxbEntityMappings>> mappings, Index annotationIndex) {
List<JaxbEntityMappings> list = new ArrayList<JaxbEntityMappings>( mappings.size() );
for ( JaxbRoot<JaxbEntityMappings> jaxbRoot : mappings ) {
list.add( jaxbRoot.getRoot() );
}
return new EntityMappingsMocker( list, annotationIndex, metadata.getServiceRegistry() ).mockNewIndex();
}
private void indexClass(Indexer indexer, Class<?> clazz, Set<String> processedNames) {
indexClass( indexer, clazz.getName().replace( '.', '/' ) + ".class", processedNames );
// index all super classes of the specified class. Using org.hibernate.cfg.Configuration it was not
// necessary to add all annotated classes. Entities would be enough. Mapped superclasses would be
// discovered while processing the annotations. To keep this behavior we index all classes in the
// hierarchy (see also HHH-7484)
clazz = clazz.getSuperclass();
while ( clazz != null && !Object.class.equals( clazz ) ) {
indexClass( indexer, clazz.getName().replace( '.', '/' ) + ".class", processedNames );
clazz = clazz.getSuperclass();
}
}
private void indexClass(Indexer indexer, String className, Set<String> processedNames) {
if ( processedNames.contains( className ) ) {
return;
}
InputStream stream = metadata.getServiceRegistry().getService( ClassLoaderService.class ).locateResourceStream(
className
);
try {
indexer.index( stream );
}
catch ( IOException e ) {
throw new HibernateException( "Unable to open input stream for class " + className, e );
}
}
private class GlobalIdentifierGeneratorSourceContainer implements IdentifierGeneratorSourceContainer { private class GlobalIdentifierGeneratorSourceContainer implements IdentifierGeneratorSourceContainer {
private final AnnotationBindingContext bindingContext; private final AnnotationBindingContext bindingContext;
@ -251,17 +167,17 @@ public class AnnotationMetadataSourceProcessorImpl implements MetadataSourceProc
} }
@Override @Override
public List<AnnotationInstance> getSequenceGeneratorSources() { public Collection<AnnotationInstance> getSequenceGeneratorSources() {
return bindingContext.getIndex().getAnnotations( JPADotNames.SEQUENCE_GENERATOR ); return bindingContext.getIndex().getAnnotations( JPADotNames.SEQUENCE_GENERATOR );
} }
@Override @Override
public List<AnnotationInstance> getTableGeneratorSources() { public Collection<AnnotationInstance> getTableGeneratorSources() {
return bindingContext.getIndex().getAnnotations( JPADotNames.TABLE_GENERATOR ); return bindingContext.getIndex().getAnnotations( JPADotNames.TABLE_GENERATOR );
} }
@Override @Override
public List<AnnotationInstance> getGenericGeneratorSources() { public Collection<AnnotationInstance> getGenericGeneratorSources() {
List<AnnotationInstance> annotations = new ArrayList<AnnotationInstance>(); List<AnnotationInstance> annotations = new ArrayList<AnnotationInstance>();
annotations.addAll( bindingContext.getIndex().getAnnotations( HibernateDotNames.GENERIC_GENERATOR ) ); annotations.addAll( bindingContext.getIndex().getAnnotations( HibernateDotNames.GENERIC_GENERATOR ) );

View File

@ -25,6 +25,7 @@ package org.hibernate.metamodel.internal.source.annotations;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -90,7 +91,7 @@ public class IdentifierGeneratorExtractionDelegate {
private void processSequenceGenerators( private void processSequenceGenerators(
List<IdentifierGeneratorSource> identifierGeneratorSources, List<IdentifierGeneratorSource> identifierGeneratorSources,
List<AnnotationInstance> generatorAnnotations) { Collection<AnnotationInstance> generatorAnnotations) {
for ( AnnotationInstance generatorAnnotation : generatorAnnotations ) { for ( AnnotationInstance generatorAnnotation : generatorAnnotations ) {
final String generatorName = JandexHelper.getValue( generatorAnnotation, "name", String.class ); final String generatorName = JandexHelper.getValue( generatorAnnotation, "name", String.class );
@ -141,7 +142,7 @@ public class IdentifierGeneratorExtractionDelegate {
private void processTableGenerators( private void processTableGenerators(
List<IdentifierGeneratorSource> identifierGeneratorSources, List<IdentifierGeneratorSource> identifierGeneratorSources,
List<AnnotationInstance> annotations) { Collection<AnnotationInstance> annotations) {
for ( AnnotationInstance generatorAnnotation : annotations ) { for ( AnnotationInstance generatorAnnotation : annotations ) {
final String generatorName = JandexHelper.getValue( generatorAnnotation, "name", String.class ); final String generatorName = JandexHelper.getValue( generatorAnnotation, "name", String.class );
@ -235,7 +236,7 @@ public class IdentifierGeneratorExtractionDelegate {
private void processGenericGenerators( private void processGenericGenerators(
List<IdentifierGeneratorSource> identifierGeneratorSources, List<IdentifierGeneratorSource> identifierGeneratorSources,
List<AnnotationInstance> genericGeneratorSources) { Collection<AnnotationInstance> genericGeneratorSources) {
for ( AnnotationInstance generatorAnnotation : genericGeneratorSources ) { for ( AnnotationInstance generatorAnnotation : genericGeneratorSources ) {
Map<String, String> parameterMap = new HashMap<String, String>(); Map<String, String> parameterMap = new HashMap<String, String>();
AnnotationInstance[] parameterAnnotations = JandexHelper.getValue( AnnotationInstance[] parameterAnnotations = JandexHelper.getValue(

View File

@ -23,6 +23,7 @@
*/ */
package org.hibernate.metamodel.internal.source.annotations; package org.hibernate.metamodel.internal.source.annotations;
import java.util.Collection;
import java.util.List; import java.util.List;
import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationInstance;
@ -34,9 +35,9 @@ import org.jboss.jandex.AnnotationInstance;
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public interface IdentifierGeneratorSourceContainer { public interface IdentifierGeneratorSourceContainer {
public List<AnnotationInstance> getSequenceGeneratorSources(); public Collection<AnnotationInstance> getSequenceGeneratorSources();
public List<AnnotationInstance> getTableGeneratorSources(); public Collection<AnnotationInstance> getTableGeneratorSources();
public List<AnnotationInstance> getGenericGeneratorSources(); public Collection<AnnotationInstance> getGenericGeneratorSources();
} }

View File

@ -34,6 +34,7 @@ import com.fasterxml.classmate.ResolvedTypeWithMembers;
import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.ClassInfo; import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.Index; import org.jboss.jandex.Index;
import org.jboss.jandex.IndexView;
import org.hibernate.cfg.NamingStrategy; import org.hibernate.cfg.NamingStrategy;
import org.hibernate.jaxb.spi.Origin; import org.hibernate.jaxb.spi.Origin;
@ -183,7 +184,7 @@ public class EntityBindingContext implements LocalBindingContext, AnnotationBind
} }
@Override @Override
public Index getIndex() { public IndexView getIndex() {
return contextDelegate.getIndex(); return contextDelegate.getIndex();
} }

View File

@ -26,6 +26,7 @@ package org.hibernate.metamodel.internal.source.annotations.entity;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -494,7 +495,7 @@ public class EntityClass extends ConfiguredClass {
// Bind default JPA entity listener callbacks (unless excluded), using superclasses first (unless excluded) // Bind default JPA entity listener callbacks (unless excluded), using superclasses first (unless excluded)
if ( JandexHelper.getSingleAnnotation( getClassInfo(), JPADotNames.EXCLUDE_DEFAULT_LISTENERS ) == null ) { if ( JandexHelper.getSingleAnnotation( getClassInfo(), JPADotNames.EXCLUDE_DEFAULT_LISTENERS ) == null ) {
List<AnnotationInstance> defaultEntityListenerAnnotations = getLocalBindingContext().getIndex() Collection<AnnotationInstance> defaultEntityListenerAnnotations = getLocalBindingContext().getIndex()
.getAnnotations( PseudoJpaDotNames.DEFAULT_ENTITY_LISTENERS ); .getAnnotations( PseudoJpaDotNames.DEFAULT_ENTITY_LISTENERS );
for ( AnnotationInstance annotation : defaultEntityListenerAnnotations ) { for ( AnnotationInstance annotation : defaultEntityListenerAnnotations ) {
for ( Type callbackClass : annotation.value().asClassArray() ) { for ( Type callbackClass : annotation.value().asClassArray() ) {

View File

@ -23,8 +23,8 @@
*/ */
package org.hibernate.metamodel.internal.source.annotations.global; package org.hibernate.metamodel.internal.source.annotations.global;
import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Set; import java.util.Set;
import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationInstance;
@ -32,12 +32,12 @@ import org.jboss.jandex.AnnotationInstance;
import org.hibernate.MappingException; import org.hibernate.MappingException;
import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.FetchProfiles; import org.hibernate.annotations.FetchProfiles;
import org.hibernate.metamodel.internal.source.annotations.AnnotationBindingContext;
import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames; import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper; import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.spi.MetadataImplementor;
import org.hibernate.metamodel.spi.binding.FetchProfile; import org.hibernate.metamodel.spi.binding.FetchProfile;
import org.hibernate.metamodel.spi.binding.FetchProfile.Fetch; import org.hibernate.metamodel.spi.binding.FetchProfile.Fetch;
import org.hibernate.metamodel.spi.MetadataImplementor;
import org.hibernate.metamodel.internal.source.annotations.AnnotationBindingContext;
/** /**
* Binds fetch profiles found in annotations. * Binds fetch profiles found in annotations.
@ -57,7 +57,7 @@ public class FetchProfileProcessor {
// TODO verify that association exists. See former VerifyFetchProfileReferenceSecondPass // TODO verify that association exists. See former VerifyFetchProfileReferenceSecondPass
public static void bind(AnnotationBindingContext bindingContext) { public static void bind(AnnotationBindingContext bindingContext) {
List<AnnotationInstance> annotations = bindingContext.getIndex() Collection<AnnotationInstance> annotations = bindingContext.getIndex()
.getAnnotations( HibernateDotNames.FETCH_PROFILE ); .getAnnotations( HibernateDotNames.FETCH_PROFILE );
for ( AnnotationInstance fetchProfile : annotations ) { for ( AnnotationInstance fetchProfile : annotations ) {
bind( bindingContext.getMetadataImplementor(), fetchProfile ); bind( bindingContext.getMetadataImplementor(), fetchProfile );

View File

@ -23,13 +23,14 @@
*/ */
package org.hibernate.metamodel.internal.source.annotations.global; package org.hibernate.metamodel.internal.source.annotations.global;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;
import javax.persistence.SequenceGenerator; import javax.persistence.SequenceGenerator;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationInstance;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
@ -43,13 +44,13 @@ import org.hibernate.id.enhanced.SequenceStyleGenerator;
import org.hibernate.id.enhanced.TableGenerator; import org.hibernate.id.enhanced.TableGenerator;
import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.StringHelper;
import org.hibernate.metamodel.internal.source.annotations.AnnotationBindingContext;
import org.hibernate.metamodel.internal.source.annotations.util.EnumConversionHelper; import org.hibernate.metamodel.internal.source.annotations.util.EnumConversionHelper;
import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames; 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.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper; import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.spi.MetadataImplementor; import org.hibernate.metamodel.spi.MetadataImplementor;
import org.hibernate.metamodel.spi.binding.IdGenerator; import org.hibernate.metamodel.spi.binding.IdGenerator;
import org.hibernate.metamodel.internal.source.annotations.AnnotationBindingContext;
/** /**
* Binds {@link SequenceGenerator}, {@link javax.persistence.TableGenerator}, {@link GenericGenerator}, and * Binds {@link SequenceGenerator}, {@link javax.persistence.TableGenerator}, {@link GenericGenerator}, and
@ -74,7 +75,7 @@ public class IdGeneratorProcessor {
* @param bindingContext the context for annotation binding * @param bindingContext the context for annotation binding
*/ */
public static void bind(AnnotationBindingContext bindingContext) { public static void bind(AnnotationBindingContext bindingContext) {
List<AnnotationInstance> annotations = bindingContext.getIndex() Collection<AnnotationInstance> annotations = bindingContext.getIndex()
.getAnnotations( JPADotNames.SEQUENCE_GENERATOR ); .getAnnotations( JPADotNames.SEQUENCE_GENERATOR );
for ( AnnotationInstance generator : annotations ) { for ( AnnotationInstance generator : annotations ) {
bindSequenceGenerator( bindingContext.getMetadataImplementor(), generator ); bindSequenceGenerator( bindingContext.getMetadataImplementor(), generator );

View File

@ -23,15 +23,16 @@
*/ */
package org.hibernate.metamodel.internal.source.annotations.global; package org.hibernate.metamodel.internal.source.annotations.global;
import java.util.HashMap;
import java.util.List;
import javax.persistence.NamedNativeQueries; import javax.persistence.NamedNativeQueries;
import javax.persistence.NamedNativeQuery; import javax.persistence.NamedNativeQuery;
import javax.persistence.NamedQueries; import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery; import javax.persistence.NamedQuery;
import java.util.Collection;
import java.util.HashMap;
import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationValue; import org.jboss.jandex.AnnotationValue;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.hibernate.AnnotationException; import org.hibernate.AnnotationException;
@ -47,11 +48,11 @@ import org.hibernate.engine.spi.NamedSQLQueryDefinition;
import org.hibernate.engine.spi.NamedSQLQueryDefinitionBuilder; import org.hibernate.engine.spi.NamedSQLQueryDefinitionBuilder;
import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.StringHelper;
import org.hibernate.metamodel.internal.source.annotations.AnnotationBindingContext;
import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames; 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.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper; import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.spi.MetadataImplementor; import org.hibernate.metamodel.spi.MetadataImplementor;
import org.hibernate.metamodel.internal.source.annotations.AnnotationBindingContext;
/** /**
* Binds {@link NamedQuery}, {@link NamedQueries}, {@link NamedNativeQuery}, {@link NamedNativeQueries}, * Binds {@link NamedQuery}, {@link NamedQueries}, {@link NamedNativeQuery}, {@link NamedNativeQueries},
@ -79,7 +80,7 @@ public class QueryProcessor {
* @param bindingContext the context for annotation binding * @param bindingContext the context for annotation binding
*/ */
public static void bind(AnnotationBindingContext bindingContext) { public static void bind(AnnotationBindingContext bindingContext) {
List<AnnotationInstance> annotations = bindingContext.getIndex().getAnnotations( JPADotNames.NAMED_QUERY ); Collection<AnnotationInstance> annotations = bindingContext.getIndex().getAnnotations( JPADotNames.NAMED_QUERY );
for ( AnnotationInstance query : annotations ) { for ( AnnotationInstance query : annotations ) {
bindNamedQuery( bindingContext.getMetadataImplementor(), query ); bindNamedQuery( bindingContext.getMetadataImplementor(), query );
} }

View File

@ -25,14 +25,15 @@ package org.hibernate.metamodel.internal.source.annotations.global;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationInstance;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.hibernate.LockMode; import org.hibernate.LockMode;
@ -40,7 +41,6 @@ import org.hibernate.MappingException;
import org.hibernate.engine.ResultSetMappingDefinition; import org.hibernate.engine.ResultSetMappingDefinition;
import org.hibernate.engine.query.spi.sql.NativeSQLQueryRootReturn; import org.hibernate.engine.query.spi.sql.NativeSQLQueryRootReturn;
import org.hibernate.engine.query.spi.sql.NativeSQLQueryScalarReturn; import org.hibernate.engine.query.spi.sql.NativeSQLQueryScalarReturn;
import org.hibernate.id.EntityIdentifierNature;
import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper; import org.hibernate.internal.util.collections.CollectionHelper;
@ -75,7 +75,7 @@ public class SqlResultSetProcessor {
} }
public static void bind(final AnnotationBindingContext bindingContext) { public static void bind(final AnnotationBindingContext bindingContext) {
List<AnnotationInstance> annotations = bindingContext.getIndex() Collection<AnnotationInstance> annotations = bindingContext.getIndex()
.getAnnotations( JPADotNames.SQL_RESULT_SET_MAPPING ); .getAnnotations( JPADotNames.SQL_RESULT_SET_MAPPING );
for ( final AnnotationInstance sqlResultSetMappingAnnotationInstance : annotations ) { for ( final AnnotationInstance sqlResultSetMappingAnnotationInstance : annotations ) {
bindSqlResultSetMapping( bindingContext, sqlResultSetMappingAnnotationInstance ); bindSqlResultSetMapping( bindingContext, sqlResultSetMappingAnnotationInstance );

View File

@ -23,9 +23,10 @@
*/ */
package org.hibernate.metamodel.internal.source.annotations.global; package org.hibernate.metamodel.internal.source.annotations.global;
import java.util.List; import java.util.Collection;
import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationInstance;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.hibernate.AnnotationException; import org.hibernate.AnnotationException;
@ -34,13 +35,13 @@ import org.hibernate.internal.util.StringHelper;
import org.hibernate.metamodel.internal.source.annotations.AnnotationBindingContext; import org.hibernate.metamodel.internal.source.annotations.AnnotationBindingContext;
import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames; import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper; import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.spi.MetadataImplementor;
import org.hibernate.metamodel.spi.relational.Column; import org.hibernate.metamodel.spi.relational.Column;
import org.hibernate.metamodel.spi.relational.Index; import org.hibernate.metamodel.spi.relational.Index;
import org.hibernate.metamodel.spi.relational.ObjectName; import org.hibernate.metamodel.spi.relational.ObjectName;
import org.hibernate.metamodel.spi.relational.Schema; import org.hibernate.metamodel.spi.relational.Schema;
import org.hibernate.metamodel.spi.relational.Table; import org.hibernate.metamodel.spi.relational.Table;
import org.hibernate.metamodel.spi.relational.Value; import org.hibernate.metamodel.spi.relational.Value;
import org.hibernate.metamodel.spi.MetadataImplementor;
/** /**
* Binds table related information. This binder is called after the entities are bound. * Binds table related information. This binder is called after the entities are bound.
@ -64,7 +65,7 @@ public class TableProcessor {
* @param bindingContext the context for annotation binding * @param bindingContext the context for annotation binding
*/ */
public static void bind(AnnotationBindingContext bindingContext) { public static void bind(AnnotationBindingContext bindingContext) {
List<AnnotationInstance> annotations = bindingContext.getIndex().getAnnotations( HibernateDotNames.TABLE ); Collection<AnnotationInstance> annotations = bindingContext.getIndex().getAnnotations( HibernateDotNames.TABLE );
for ( AnnotationInstance tableAnnotation : annotations ) { for ( AnnotationInstance tableAnnotation : annotations ) {
bind( bindingContext.getMetadataImplementor(), tableAnnotation ); bind( bindingContext.getMetadataImplementor(), tableAnnotation );
} }

View File

@ -23,19 +23,20 @@
*/ */
package org.hibernate.metamodel.internal.source.annotations.util; package org.hibernate.metamodel.internal.source.annotations.util;
import javax.persistence.AccessType;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import javax.persistence.AccessType;
import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.ClassInfo; import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName; import org.jboss.jandex.DotName;
import org.jboss.jandex.FieldInfo; import org.jboss.jandex.FieldInfo;
import org.jboss.jandex.Index; import org.jboss.jandex.IndexView;
import org.jboss.jandex.MethodInfo; import org.jboss.jandex.MethodInfo;
import org.hibernate.AnnotationException; import org.hibernate.AnnotationException;
@ -73,7 +74,7 @@ public class EntityHierarchyBuilder {
List<DotName> processedEntities = new ArrayList<DotName>(); List<DotName> processedEntities = new ArrayList<DotName>();
Map<DotName, List<ClassInfo>> classToDirectSubClassMap = new HashMap<DotName, List<ClassInfo>>(); Map<DotName, List<ClassInfo>> classToDirectSubClassMap = new HashMap<DotName, List<ClassInfo>>();
Index index = bindingContext.getIndex(); IndexView index = bindingContext.getIndex();
for ( ClassInfo classInfo : index.getKnownClasses() ) { for ( ClassInfo classInfo : index.getKnownClasses() ) {
if ( !isEntityClass( classInfo ) ) { if ( !isEntityClass( classInfo ) ) {
continue; continue;
@ -174,7 +175,7 @@ public class EntityHierarchyBuilder {
* *
* @return Finds the root entity starting at the entity given by {@code info} * @return Finds the root entity starting at the entity given by {@code info}
*/ */
private static ClassInfo findRootEntityClassInfo(Index index, ClassInfo info) { private static ClassInfo findRootEntityClassInfo(IndexView index, ClassInfo info) {
ClassInfo rootEntity = info; ClassInfo rootEntity = info;
DotName superName = info.superName(); DotName superName = info.superName();
@ -190,7 +191,7 @@ public class EntityHierarchyBuilder {
return rootEntity; return rootEntity;
} }
private static List<ClassInfo> findMappedSuperclasses(Index index, ClassInfo info) { private static List<ClassInfo> findMappedSuperclasses(IndexView index, ClassInfo info) {
List<ClassInfo> mappedSuperclasses = new ArrayList<ClassInfo>( ); List<ClassInfo> mappedSuperclasses = new ArrayList<ClassInfo>( );
DotName superName = info.superName(); DotName superName = info.superName();
ClassInfo tmpInfo; ClassInfo tmpInfo;
@ -226,7 +227,7 @@ public class EntityHierarchyBuilder {
Map<DotName, List<ClassInfo>> classToDirectSubclassMap) { Map<DotName, List<ClassInfo>> classToDirectSubclassMap) {
processedEntities.add( classInfo.name() ); processedEntities.add( classInfo.name() );
rootClassWithAllSubclasses.add( classInfo ); rootClassWithAllSubclasses.add( classInfo );
List<ClassInfo> subClasses = bindingContext.getIndex().getKnownDirectSubclasses( classInfo.name() ); Collection<ClassInfo> subClasses = bindingContext.getIndex().getKnownDirectSubclasses( classInfo.name() );
// if there are no more subclasses we reached the leaf class. In order to properly resolve generics we // if there are no more subclasses we reached the leaf class. In order to properly resolve generics we
// need to resolve the type information using this leaf class // need to resolve the type information using this leaf class

View File

@ -28,6 +28,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.jboss.jandex.Index; import org.jboss.jandex.Index;
import org.jboss.jandex.IndexView;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.CoreMessageLogger;
@ -58,7 +60,7 @@ public class EntityMappingsMocker {
private final IndexBuilder indexBuilder; private final IndexBuilder indexBuilder;
private final GlobalAnnotations globalAnnotations; private final GlobalAnnotations globalAnnotations;
public EntityMappingsMocker(List<JaxbEntityMappings> entityMappingsList, Index index, ServiceRegistry serviceRegistry) { public EntityMappingsMocker(List<JaxbEntityMappings> entityMappingsList, IndexView index, ServiceRegistry serviceRegistry) {
this.entityMappingsList = entityMappingsList; this.entityMappingsList = entityMappingsList;
this.indexBuilder = new IndexBuilder( index, serviceRegistry ); this.indexBuilder = new IndexBuilder( index, serviceRegistry );
this.globalAnnotations = new GlobalAnnotations(); this.globalAnnotations = new GlobalAnnotations();

View File

@ -24,6 +24,7 @@
package org.hibernate.metamodel.internal.source.annotations.xml.mocker; package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -89,7 +90,7 @@ class GlobalAnnotations implements JPADotNames {
} }
void addIndexedAnnotationInstance(List<AnnotationInstance> annotationInstanceList) { void addIndexedAnnotationInstance(Collection<AnnotationInstance> annotationInstanceList) {
if ( CollectionHelper.isNotEmpty( annotationInstanceList ) ) { if ( CollectionHelper.isNotEmpty( annotationInstanceList ) ) {
indexedAnnotationInstanceList.addAll( annotationInstanceList ); indexedAnnotationInstanceList.addAll( annotationInstanceList );
} }

View File

@ -24,6 +24,7 @@
package org.hibernate.metamodel.internal.source.annotations.xml.mocker; package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -33,6 +34,8 @@ import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.ClassInfo; import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName; import org.jboss.jandex.DotName;
import org.jboss.jandex.Index; import org.jboss.jandex.Index;
import org.jboss.jandex.IndexView;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.hibernate.AssertionFailure; import org.hibernate.AssertionFailure;
@ -55,12 +58,12 @@ public class IndexBuilder {
private final Map<DotName, List<ClassInfo>> subclasses; private final Map<DotName, List<ClassInfo>> subclasses;
private final Map<DotName, List<ClassInfo>> implementors; private final Map<DotName, List<ClassInfo>> implementors;
private final Map<DotName, ClassInfo> classes; private final Map<DotName, ClassInfo> classes;
private Index index; private IndexView index;
private final Map<DotName, Map<DotName, List<AnnotationInstance>>> classInfoAnnotationsMap; private final Map<DotName, Map<DotName, List<AnnotationInstance>>> classInfoAnnotationsMap;
private final Map<DotName, Map<DotName, List<AnnotationInstance>>> indexedClassInfoAnnotationsMap; private final Map<DotName, Map<DotName, List<AnnotationInstance>>> indexedClassInfoAnnotationsMap;
private final ServiceRegistry serviceRegistry; private final ServiceRegistry serviceRegistry;
IndexBuilder(Index index, ServiceRegistry serviceRegistry) { IndexBuilder(IndexView index, ServiceRegistry serviceRegistry) {
this.index = index; this.index = index;
this.serviceRegistry = serviceRegistry; this.serviceRegistry = serviceRegistry;
this.annotations = new HashMap<DotName, List<AnnotationInstance>>(); this.annotations = new HashMap<DotName, List<AnnotationInstance>>();
@ -167,9 +170,9 @@ public class IndexBuilder {
void collectGlobalConfigurationFromIndex(GlobalAnnotations globalAnnotations) { void collectGlobalConfigurationFromIndex(GlobalAnnotations globalAnnotations) {
for ( DotName annName : DefaultConfigurationHelper.GLOBAL_ANNOTATIONS ) { for ( DotName annName : DefaultConfigurationHelper.GLOBAL_ANNOTATIONS ) {
List<AnnotationInstance> annotationInstanceList = index.getAnnotations( annName ); Collection<AnnotationInstance> annotationInstances = index.getAnnotations( annName );
if ( CollectionHelper.isNotEmpty( annotationInstanceList ) ) { if ( CollectionHelper.isNotEmpty( annotationInstances ) ) {
globalAnnotations.addIndexedAnnotationInstance( annotationInstanceList ); globalAnnotations.addIndexedAnnotationInstance( annotationInstances );
} }
} }
globalAnnotations.filterIndexedAnnotations(); globalAnnotations.filterIndexedAnnotations();

View File

@ -25,7 +25,7 @@ package org.hibernate.metamodel.spi;
import java.util.List; import java.util.List;
import org.jboss.jandex.IndexResult; import org.jboss.jandex.IndexView;
import org.hibernate.jaxb.spi.JaxbRoot; import org.hibernate.jaxb.spi.JaxbRoot;
@ -44,5 +44,5 @@ public interface AdditionalJaxbRootProducer {
* *
* @return List of additional mappings * @return List of additional mappings
*/ */
public List<JaxbRoot> produceRoots(MetadataImplementor metadata, IndexResult jandexIndex); public List<JaxbRoot> produceRoots(MetadataImplementor metadata, IndexView jandexIndex);
} }

View File

@ -23,7 +23,7 @@
*/ */
package org.hibernate.metamodel.spi; package org.hibernate.metamodel.spi;
import org.jboss.jandex.IndexResult; import org.jboss.jandex.IndexView;
/** /**
* Contract for contributing MetadataSources. This hook occurs just after all processing of * Contract for contributing MetadataSources. This hook occurs just after all processing of
@ -38,5 +38,5 @@ public interface MetadataContributor {
* @param metadata The metadata * @param metadata The metadata
* @param jandexIndex The Jandex index * @param jandexIndex The Jandex index
*/ */
public void contribute(MetadataImplementor metadata, IndexResult jandexIndex); public void contribute(MetadataImplementor metadata, IndexView jandexIndex);
} }

View File

@ -72,7 +72,11 @@ public class AssertSourcesTest extends BaseUnitTestCase {
MetadataSources ann = new MetadataSources( serviceRegistry ); MetadataSources ann = new MetadataSources( serviceRegistry );
ann.addAnnotatedClass( User.class ); ann.addAnnotatedClass( User.class );
MetadataSourceProcessor annProcessor = new AnnotationMetadataSourceProcessorImpl( buildMetadata( ann ), ann ); MetadataSourceProcessor annProcessor = new AnnotationMetadataSourceProcessorImpl(
buildMetadata( ann ),
ann,
ann.buildJandexView()
);
testUserEntitySources( annProcessor ); testUserEntitySources( annProcessor );
} }
@ -179,7 +183,11 @@ public class AssertSourcesTest extends BaseUnitTestCase {
ann.addAnnotatedClass( Order.class ); ann.addAnnotatedClass( Order.class );
ann.addAnnotatedClass( Order.class ); ann.addAnnotatedClass( Order.class );
ann.addAnnotatedClass( Order.OrderPk.class ); ann.addAnnotatedClass( Order.OrderPk.class );
MetadataSourceProcessor annProcessor = new AnnotationMetadataSourceProcessorImpl( buildMetadata( ann ), ann ); MetadataSourceProcessor annProcessor = new AnnotationMetadataSourceProcessorImpl(
buildMetadata( ann ),
ann,
ann.buildJandexView()
);
testOrderEntitySources( annProcessor ); testOrderEntitySources( annProcessor );
} }
@ -204,7 +212,11 @@ public class AssertSourcesTest extends BaseUnitTestCase {
ann.addAnnotatedClass( Order.class ); ann.addAnnotatedClass( Order.class );
ann.addAnnotatedClass( Order.class ); ann.addAnnotatedClass( Order.class );
ann.addAnnotatedClass( Order.OrderPk.class ); ann.addAnnotatedClass( Order.OrderPk.class );
MetadataSourceProcessor annProcessor = new AnnotationMetadataSourceProcessorImpl( buildMetadata( ann ), ann ); MetadataSourceProcessor annProcessor = new AnnotationMetadataSourceProcessorImpl(
buildMetadata( ann ),
ann,
ann.buildJandexView()
);
testOrderNonAggregatedEntitySources( annProcessor ); testOrderNonAggregatedEntitySources( annProcessor );
} }

View File

@ -22,12 +22,17 @@
*/ */
package org.hibernate.jpa.test.connection; package org.hibernate.jpa.test.connection;
import javax.persistence.EntityManagerFactory;
import java.io.File; import java.io.File;
import org.junit.Assert; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.jpa.HibernatePersistenceProvider;
import org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl;
import org.junit.Test; import org.junit.Test;
import org.hibernate.ejb.HibernatePersistence; import static org.hibernate.testing.junit4.ExtraAssertions.assertTyping;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard
@ -40,8 +45,12 @@ public class DataSourceInjectionTest {
sub.mkdir(); sub.mkdir();
PersistenceUnitInfoImpl info = new PersistenceUnitInfoImpl( sub.toURI().toURL(), new String[]{} ); PersistenceUnitInfoImpl info = new PersistenceUnitInfoImpl( sub.toURI().toURL(), new String[]{} );
try { try {
new HibernatePersistence().createContainerEntityManagerFactory( info, null ); EntityManagerFactory emf = new HibernatePersistenceProvider().createContainerEntityManagerFactory( info, null );
Assert.fail( "FakeDatasource should have been used" ); DatasourceConnectionProviderImpl cp = assertTyping(
DatasourceConnectionProviderImpl.class,
emf.unwrap( SessionFactoryImplementor.class ).getConnectionProvider()
);
assertTyping( FakeDataSource.class, cp.getDataSource() );
} }
catch (FakeDataSourceException fde) { catch (FakeDataSourceException fde) {
//success //success

View File

@ -35,7 +35,7 @@ import javax.persistence.spi.PersistenceUnitTransactionType;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.ejb.HibernatePersistence; import org.hibernate.jpa.HibernatePersistenceProvider;
import org.hibernate.jpa.test.Distributor; import org.hibernate.jpa.test.Distributor;
import org.hibernate.jpa.test.Item; import org.hibernate.jpa.test.Item;
import org.hibernate.jpa.test.xml.Light; import org.hibernate.jpa.test.xml.Light;
@ -60,7 +60,7 @@ public class PersistenceUnitInfoImpl implements PersistenceUnitInfo {
} }
public String getPersistenceProviderClassName() { public String getPersistenceProviderClassName() {
return HibernatePersistence.class.getName(); return HibernatePersistenceProvider.class.getName();
} }
public DataSource getJtaDataSource() { public DataSource getJtaDataSource() {