HHH-14356 Avoid NPE when booting with xml_mapping_enabled=false
Introduced by HHH-14334
when use Envers with hibernate.xml_mapping_enabled=false
see 34151a9660 (r44735539)
This commit is contained in:
parent
0009fec578
commit
04c97c2293
|
@ -203,23 +203,24 @@ public class ScanningCoordinator {
|
|||
nonLocatedMappingFileNames.addAll( explicitMappingFileNames );
|
||||
}
|
||||
|
||||
for ( MappingFileDescriptor mappingFileDescriptor : scanResult.getLocatedMappingFiles() ) {
|
||||
managedResources.addXmlBinding( xmlMappingBinderAccess.bind( mappingFileDescriptor.getStreamAccess() ) );
|
||||
nonLocatedMappingFileNames.remove( mappingFileDescriptor.getName() );
|
||||
}
|
||||
|
||||
for ( String name : nonLocatedMappingFileNames ) {
|
||||
final URL url = classLoaderService.locateResource( name );
|
||||
if ( url == null ) {
|
||||
throw new MappingException(
|
||||
"Unable to resolve explicitly named mapping-file : " + name,
|
||||
new Origin( SourceType.RESOURCE, name )
|
||||
);
|
||||
if ( xmlMappingBinderAccess != null ) { // xml mapping is not disabled
|
||||
for ( MappingFileDescriptor mappingFileDescriptor : scanResult.getLocatedMappingFiles() ) {
|
||||
managedResources.addXmlBinding( xmlMappingBinderAccess.bind( mappingFileDescriptor.getStreamAccess() ) );
|
||||
nonLocatedMappingFileNames.remove( mappingFileDescriptor.getName() );
|
||||
}
|
||||
final UrlInputStreamAccess inputStreamAccess = new UrlInputStreamAccess( url );
|
||||
managedResources.addXmlBinding( xmlMappingBinderAccess.bind( inputStreamAccess ) );
|
||||
}
|
||||
|
||||
for ( String name : nonLocatedMappingFileNames ) {
|
||||
final URL url = classLoaderService.locateResource( name );
|
||||
if ( url == null ) {
|
||||
throw new MappingException(
|
||||
"Unable to resolve explicitly named mapping-file : " + name,
|
||||
new Origin( SourceType.RESOURCE, name )
|
||||
);
|
||||
}
|
||||
final UrlInputStreamAccess inputStreamAccess = new UrlInputStreamAccess( url );
|
||||
managedResources.addXmlBinding( xmlMappingBinderAccess.bind( inputStreamAccess ) );
|
||||
}
|
||||
}
|
||||
|
||||
// classes and packages ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
@ -294,28 +294,30 @@ public class MetadataBuildingProcess {
|
|||
|
||||
metadataCollector.processSecondPasses( rootMetadataBuildingContext );
|
||||
|
||||
Iterable<AdditionalJaxbMappingProducer> producers = classLoaderService.loadJavaServices( AdditionalJaxbMappingProducer.class );
|
||||
if ( producers != null ) {
|
||||
final EntityHierarchyBuilder hierarchyBuilder = new EntityHierarchyBuilder();
|
||||
// final MappingBinder mappingBinder = new MappingBinder( true );
|
||||
// We need to disable validation here. It seems Envers is not producing valid (according to schema) XML
|
||||
final MappingBinder mappingBinder = options.isXmlMappingEnabled() ? new MappingBinder( classLoaderService, false ) : null;
|
||||
for ( AdditionalJaxbMappingProducer producer : producers ) {
|
||||
log.tracef( "Calling AdditionalJaxbMappingProducer : %s", producer );
|
||||
Collection<MappingDocument> additionalMappings = producer.produceAdditionalMappings(
|
||||
metadataCollector,
|
||||
jandexView,
|
||||
mappingBinder,
|
||||
rootMetadataBuildingContext
|
||||
);
|
||||
for ( MappingDocument mappingDocument : additionalMappings ) {
|
||||
hierarchyBuilder.indexMappingDocument( mappingDocument );
|
||||
if ( options.isXmlMappingEnabled() ) {
|
||||
Iterable<AdditionalJaxbMappingProducer> producers = classLoaderService.loadJavaServices( AdditionalJaxbMappingProducer.class );
|
||||
if ( producers != null ) {
|
||||
final EntityHierarchyBuilder hierarchyBuilder = new EntityHierarchyBuilder();
|
||||
// final MappingBinder mappingBinder = new MappingBinder( true );
|
||||
// We need to disable validation here. It seems Envers is not producing valid (according to schema) XML
|
||||
final MappingBinder mappingBinder = new MappingBinder( classLoaderService, false );
|
||||
for ( AdditionalJaxbMappingProducer producer : producers ) {
|
||||
log.tracef( "Calling AdditionalJaxbMappingProducer : %s", producer );
|
||||
Collection<MappingDocument> additionalMappings = producer.produceAdditionalMappings(
|
||||
metadataCollector,
|
||||
jandexView,
|
||||
mappingBinder,
|
||||
rootMetadataBuildingContext
|
||||
);
|
||||
for ( MappingDocument mappingDocument : additionalMappings ) {
|
||||
hierarchyBuilder.indexMappingDocument( mappingDocument );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ModelBinder binder = ModelBinder.prepare( rootMetadataBuildingContext );
|
||||
for ( EntityHierarchySourceImpl entityHierarchySource : hierarchyBuilder.buildHierarchies() ) {
|
||||
binder.bindEntityHierarchy( entityHierarchySource );
|
||||
ModelBinder binder = ModelBinder.prepare( rootMetadataBuildingContext );
|
||||
for ( EntityHierarchySourceImpl entityHierarchySource : hierarchyBuilder.buildHierarchies() ) {
|
||||
binder.bindEntityHierarchy( entityHierarchySource );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue