LocalSessionFactoryBuilder provides ClassLoader to Hibernate BootstrapServiceRegistry
Issue: SPR-13879
This commit is contained in:
parent
64ce8a81c3
commit
64e77de23b
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -344,7 +344,11 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
|
|||
*/
|
||||
public MetadataSources getMetadataSources() {
|
||||
if (this.metadataSources == null) {
|
||||
this.metadataSources = new MetadataSources(new BootstrapServiceRegistryBuilder().build());
|
||||
BootstrapServiceRegistryBuilder builder = new BootstrapServiceRegistryBuilder();
|
||||
if (this.resourcePatternResolver != null) {
|
||||
builder = builder.applyClassLoader(this.resourcePatternResolver.getClassLoader());
|
||||
}
|
||||
this.metadataSources = new MetadataSources(builder.build());
|
||||
}
|
||||
return this.metadataSources;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -118,7 +118,8 @@ public class LocalSessionFactoryBuilder extends Configuration {
|
|||
* @param resourceLoader the ResourceLoader to load application classes from
|
||||
*/
|
||||
public LocalSessionFactoryBuilder(DataSource dataSource, ResourceLoader resourceLoader) {
|
||||
this(dataSource, resourceLoader, new MetadataSources(new BootstrapServiceRegistryBuilder().build()));
|
||||
this(dataSource, resourceLoader, new MetadataSources(
|
||||
new BootstrapServiceRegistryBuilder().applyClassLoader(resourceLoader.getClassLoader()).build()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue