Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixing test failures in the merge

  • Loading branch information...
commit 53483676652e1f6f97c86ce6d3ed573a55118876 1 parent c48de9e
@stliu stliu authored
View
2  ...e-core/src/main/java/org/hibernate/jpa/metamodel/internal/legacy/AbstractManagedType.java
@@ -138,7 +138,7 @@ public void lock() {
* {@inheritDoc}
*/
public Attribute<X, ?> getDeclaredAttribute(String name) {
- final Attribute<X, ?> attr = declaredSingularAttributes.get( name );
+ final Attribute<X, ?> attr = declaredAttributes.get( name );
checkNotNull( "Attribute ", attr, name );
return attr;
}
View
310 ...anager/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java
@@ -33,7 +33,9 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -61,6 +63,7 @@
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.registry.internal.ConfigLoader;
import org.hibernate.boot.registry.selector.spi.StrategySelector;
import org.hibernate.boot.spi.CacheRegionDefinition;
import org.hibernate.boot.spi.JaccDefinition;
@@ -74,6 +77,7 @@
import org.hibernate.id.factory.spi.MutableIdentifierGeneratorFactory;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.internal.util.StringHelper;
+import org.hibernate.jaxb.spi.cfg.JaxbHibernateConfiguration;
import org.hibernate.jaxb.spi.cfg.JaxbHibernateConfiguration.JaxbSessionFactory.JaxbMapping;
import org.hibernate.internal.util.ValueHolder;
import org.hibernate.jpa.AvailableSettings;
@@ -237,182 +241,6 @@ private BootstrapServiceRegistry buildBootstrapServiceRegistry(Map integrationSe
}
}
- ClassLoader classLoader = (ClassLoader) integrationSettings.get( org.hibernate.cfg.AvailableSettings.APP_CLASSLOADER );
- if ( classLoader != null ) {
- integrationSettings.remove( org.hibernate.cfg.AvailableSettings.APP_CLASSLOADER );
- }
- else {
- classLoader = persistenceUnit.getClassLoader();
- }
- bootstrapServiceRegistryBuilder.withApplicationClassLoader( classLoader );
-
- return bootstrapServiceRegistryBuilder.build();
- }
-
- @SuppressWarnings("unchecked")
- private Map mergePropertySources(
- PersistenceUnitDescriptor persistenceUnit,
- Map integrationSettings,
- final BootstrapServiceRegistry bootstrapServiceRegistry) {
-
- JpaUnifiedSettingsBuilder.Result mergedResult = JpaUnifiedSettingsBuilder.mergePropertySources(
- persistenceUnit,
- integrationSettings,
- bootstrapServiceRegistry
- );
-
- cfgXmlNamedMappings.addAll( mergedResult.getCfgXmlMappingArtifacts().getMappings() );
- cacheRegionDefinitions.addAll( mergedResult.getCfgXmlMappingArtifacts().getCacheRegionDefinitions() );
- jaccDefinitions.addAll( mergedResult.getCfgXmlMappingArtifacts().getJaccDefinitions() );
-
- return mergedResult.getSettings();
- }
-
- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- // temporary!
- @SuppressWarnings("unchecked")
- public Map getConfigurationValues() {
- return Collections.unmodifiableMap( configurationValues );
- }
-
- public Configuration getHibernateConfiguration() {
- return hibernateConfiguration;
- }
- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-
- @SuppressWarnings("unchecked")
- private MetadataSources prepareMetadataSources(
- IndexView jandexIndex,
- Set<String> collectedManagedClassNames,
- ScanResult scanResult,
- BootstrapServiceRegistry bootstrapServiceRegistry) {
- // todo : this needs to tie into the metamodel branch...
- MetadataSources metadataSources = new MetadataSources();
-
- for ( String className : collectedManagedClassNames ) {
- final ClassInfo classInfo = jandexIndex.getClassByName( DotName.createSimple( className ) );
- if ( classInfo == null ) {
- // Not really sure what this means. Most likely it is explicitly listed in the persistence unit,
- // but mapped via mapping file. Anyway assume its a mapping class...
- metadataSources.annotatedMappingClassNames.add( className );
- continue;
- }
-
- // logic here assumes an entity is not also a converter...
- AnnotationInstance converterAnnotation = JandexHelper.getSingleAnnotation(
- classInfo.annotations(),
- JPADotNames.CONVERTER
- );
- if ( converterAnnotation != null ) {
- metadataSources.converterDescriptors.add(
- new MetadataSources.ConverterDescriptor(
- className,
- JandexHelper.getValue( converterAnnotation, "autoApply", boolean.class )
- )
- );
- }
- else {
- metadataSources.annotatedMappingClassNames.add( className );
- }
- }
-
- metadataSources.packageNames.addAll( scanResult.getPackageNames() );
-
- metadataSources.namedMappingFileInputStreams.addAll( scanResult.getHbmFiles() );
-
- metadataSources.mappingFileResources.addAll( scanResult.getMappingFiles() );
- final String explicitHbmXmls = (String) configurationValues.remove( AvailableSettings.HBXML_FILES );
- if ( explicitHbmXmls != null ) {
- metadataSources.mappingFileResources.addAll( Arrays.asList( StringHelper.split( ", ", explicitHbmXmls ) ) );
- }
- final List<String> explicitOrmXml = (List<String>) configurationValues.remove( AvailableSettings.XML_FILE_NAMES );
- if ( explicitOrmXml != null ) {
- metadataSources.mappingFileResources.addAll( explicitOrmXml );
- }
-
- return metadataSources;
- }
-
- private Set<String> collectManagedClassNames(ScanResult scanResult) {
- Set<String> collectedNames = new HashSet<String>();
- if ( persistenceUnit.getManagedClassNames() != null ) {
- collectedNames.addAll( persistenceUnit.getManagedClassNames() );
- }
- collectedNames.addAll( scanResult.getManagedClassNames() );
- return collectedNames;
- }
-
- private IndexView locateOrBuildJandexIndex(
- Set<String> collectedManagedClassNames,
- List<String> packageNames,
- BootstrapServiceRegistry bootstrapServiceRegistry) {
- // for now create a whole new Index to work with, eventually we need to:
- // 1) accept an Index as an incoming config value
- // 2) pass that Index along to the metamodel code...
- //
- // (1) is mocked up here, but JBoss AS does not currently pass in any Index to use...
- IndexView jandexIndex = (IndexView) configurationValues.get( JANDEX_INDEX );
- if ( jandexIndex == null ) {
- jandexIndex = buildJandexIndex( collectedManagedClassNames, packageNames, bootstrapServiceRegistry );
- }
- return jandexIndex;
- }
-
- private IndexView buildJandexIndex(Set<String> classNamesSource, List<String> packageNames, BootstrapServiceRegistry bootstrapServiceRegistry) {
- Indexer indexer = new Indexer();
-
- for ( String className : classNamesSource ) {
- indexResource( className.replace( '.', '/' ) + ".class", indexer, bootstrapServiceRegistry );
- }
-
- // add package-info from the configured packages
- for ( String packageName : packageNames ) {
- indexResource( packageName.replace( '.', '/' ) + "/package-info.class", indexer, bootstrapServiceRegistry );
- }
-
- // for now we just skip entities defined in (1) orm.xml files and (2) hbm.xml files. this part really needs
- // metamodel branch...
-
- // for now, we also need to wrap this in a CompositeIndex until Jandex is updated to use a common interface
- // between the 2...
- return CompositeIndex.create( indexer.complete() );
- }
-
- private void indexResource(String resourceName, Indexer indexer, BootstrapServiceRegistry bootstrapServiceRegistry) {
- InputStream stream = bootstrapServiceRegistry.getService( ClassLoaderService.class ).locateResourceStream(
- resourceName
- );
- try {
- indexer.index( stream );
- }
- catch ( IOException e ) {
- throw persistenceException( "Unable to open input stream for resource " + resourceName, e );
- }
- }
-
-<<<<<<< HEAD
-=======
- /**
- * Builds the {@link BootstrapServiceRegistry} used to eventually build the {@link org.hibernate.boot.registry.StandardServiceRegistryBuilder}; mainly
- * used here during instantiation to define class-loading behavior.
- *
- * @param integrationSettings Any integration settings passed by the EE container or SE application
- *
- * @return The built BootstrapServiceRegistry
- */
- private BootstrapServiceRegistry buildBootstrapServiceRegistry(Map integrationSettings) {
- final BootstrapServiceRegistryBuilder bootstrapServiceRegistryBuilder = new BootstrapServiceRegistryBuilder();
- bootstrapServiceRegistryBuilder.with( new JpaIntegrator() );
-
- final IntegratorProvider integratorProvider = (IntegratorProvider) integrationSettings.get( INTEGRATOR_PROVIDER );
- if ( integratorProvider != null ) {
- integrationSettings.remove( INTEGRATOR_PROVIDER );
- for ( Integrator integrator : integratorProvider.getIntegrators() ) {
- bootstrapServiceRegistryBuilder.with( integrator );
- }
- }
-
// TODO: If providedClassLoader is present (OSGi, etc.) *and*
// an APP_CLASSLOADER is provided, should throw an exception or
// warn?
@@ -433,6 +261,7 @@ else if ( appClassLoader != null ) {
return bootstrapServiceRegistryBuilder.build();
}
+
@SuppressWarnings("unchecked")
private Map mergePropertySources(
PersistenceUnitDescriptor persistenceUnit,
@@ -531,7 +360,7 @@ private void processHibernateConfigurationElement(
= (JaxbHibernateConfiguration.JaxbSessionFactory.JaxbClassCache) cacheDeclaration;
cacheRegionDefinitions.add(
new CacheRegionDefinition(
- CacheRegionDefinition.CacheType.ENTITY,
+ CacheRegionDefinition.CacheRegionType.ENTITY,
jaxbClassCache.getClazz(),
jaxbClassCache.getUsage().value(),
jaxbClassCache.getRegion(),
@@ -544,7 +373,7 @@ private void processHibernateConfigurationElement(
= (JaxbHibernateConfiguration.JaxbSessionFactory.JaxbCollectionCache) cacheDeclaration;
cacheRegionDefinitions.add(
new CacheRegionDefinition(
- CacheRegionDefinition.CacheType.COLLECTION,
+ CacheRegionDefinition.CacheRegionType.COLLECTION,
jaxbCollectionCache.getCollection(),
jaxbCollectionCache.getUsage().value(),
jaxbCollectionCache.getRegion(),
@@ -569,7 +398,130 @@ private void processHibernateConfigurationElement(
}
}
->>>>>>> master
+
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ // temporary!
+ @SuppressWarnings("unchecked")
+ public Map getConfigurationValues() {
+ return Collections.unmodifiableMap( configurationValues );
+ }
+
+ public Configuration getHibernateConfiguration() {
+ return hibernateConfiguration;
+ }
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+ @SuppressWarnings("unchecked")
+ private MetadataSources prepareMetadataSources(
+ IndexView jandexIndex,
+ Set<String> collectedManagedClassNames,
+ ScanResult scanResult,
+ BootstrapServiceRegistry bootstrapServiceRegistry) {
+ // todo : this needs to tie into the metamodel branch...
+ MetadataSources metadataSources = new MetadataSources();
+
+ for ( String className : collectedManagedClassNames ) {
+ final ClassInfo classInfo = jandexIndex.getClassByName( DotName.createSimple( className ) );
+ if ( classInfo == null ) {
+ // Not really sure what this means. Most likely it is explicitly listed in the persistence unit,
+ // but mapped via mapping file. Anyway assume its a mapping class...
+ metadataSources.annotatedMappingClassNames.add( className );
+ continue;
+ }
+
+ // logic here assumes an entity is not also a converter...
+ AnnotationInstance converterAnnotation = JandexHelper.getSingleAnnotation(
+ classInfo.annotations(),
+ JPADotNames.CONVERTER
+ );
+ if ( converterAnnotation != null ) {
+ metadataSources.converterDescriptors.add(
+ new MetadataSources.ConverterDescriptor(
+ className,
+ JandexHelper.getValue( converterAnnotation, "autoApply", boolean.class )
+ )
+ );
+ }
+ else {
+ metadataSources.annotatedMappingClassNames.add( className );
+ }
+ }
+
+ metadataSources.packageNames.addAll( scanResult.getPackageNames() );
+
+ metadataSources.namedMappingFileInputStreams.addAll( scanResult.getHbmFiles() );
+
+ metadataSources.mappingFileResources.addAll( scanResult.getMappingFiles() );
+ final String explicitHbmXmls = (String) configurationValues.remove( AvailableSettings.HBXML_FILES );
+ if ( explicitHbmXmls != null ) {
+ metadataSources.mappingFileResources.addAll( Arrays.asList( StringHelper.split( ", ", explicitHbmXmls ) ) );
+ }
+ final List<String> explicitOrmXml = (List<String>) configurationValues.remove( AvailableSettings.XML_FILE_NAMES );
+ if ( explicitOrmXml != null ) {
+ metadataSources.mappingFileResources.addAll( explicitOrmXml );
+ }
+
+ return metadataSources;
+ }
+
+ private Set<String> collectManagedClassNames(ScanResult scanResult) {
+ Set<String> collectedNames = new HashSet<String>();
+ if ( persistenceUnit.getManagedClassNames() != null ) {
+ collectedNames.addAll( persistenceUnit.getManagedClassNames() );
+ }
+ collectedNames.addAll( scanResult.getManagedClassNames() );
+ return collectedNames;
+ }
+
+ private IndexView locateOrBuildJandexIndex(
+ Set<String> collectedManagedClassNames,
+ List<String> packageNames,
+ BootstrapServiceRegistry bootstrapServiceRegistry) {
+ // for now create a whole new Index to work with, eventually we need to:
+ // 1) accept an Index as an incoming config value
+ // 2) pass that Index along to the metamodel code...
+ //
+ // (1) is mocked up here, but JBoss AS does not currently pass in any Index to use...
+ IndexView jandexIndex = (IndexView) configurationValues.get( JANDEX_INDEX );
+ if ( jandexIndex == null ) {
+ jandexIndex = buildJandexIndex( collectedManagedClassNames, packageNames, bootstrapServiceRegistry );
+ }
+ return jandexIndex;
+ }
+
+ private IndexView buildJandexIndex(Set<String> classNamesSource, List<String> packageNames, BootstrapServiceRegistry bootstrapServiceRegistry) {
+ Indexer indexer = new Indexer();
+
+ for ( String className : classNamesSource ) {
+ indexResource( className.replace( '.', '/' ) + ".class", indexer, bootstrapServiceRegistry );
+ }
+
+ // add package-info from the configured packages
+ for ( String packageName : packageNames ) {
+ indexResource( packageName.replace( '.', '/' ) + "/package-info.class", indexer, bootstrapServiceRegistry );
+ }
+
+ // for now we just skip entities defined in (1) orm.xml files and (2) hbm.xml files. this part really needs
+ // metamodel branch...
+
+ // for now, we also need to wrap this in a CompositeIndex until Jandex is updated to use a common interface
+ // between the 2...
+ return CompositeIndex.create( indexer.complete() );
+ }
+
+ private void indexResource(String resourceName, Indexer indexer, BootstrapServiceRegistry bootstrapServiceRegistry) {
+ InputStream stream = bootstrapServiceRegistry.getService( ClassLoaderService.class ).locateResourceStream(
+ resourceName
+ );
+ try {
+ indexer.index( stream );
+ }
+ catch ( IOException e ) {
+ throw persistenceException( "Unable to open input stream for resource " + resourceName, e );
+ }
+ }
+
private String jaccContextId;
private void addJaccDefinition(String key, Object value) {
Please sign in to comment.
Something went wrong with that request. Please try again.