Java Code Examples for org.hibernate.boot.registry.BootstrapServiceRegistryBuilder#applyClassLoader()

The following examples show how to use org.hibernate.boot.registry.BootstrapServiceRegistryBuilder#applyClassLoader() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalSessionFactoryBean.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Determine the Hibernate {@link MetadataSources} to use.
 * <p>Can also be externally called to initialize and pre-populate a {@link MetadataSources}
 * instance which is then going to be used for {@link SessionFactory} building.
 * @return the MetadataSources to use (never {@code null})
 * @since 4.3
 * @see LocalSessionFactoryBuilder#LocalSessionFactoryBuilder(DataSource, ResourceLoader, MetadataSources)
 */
public MetadataSources getMetadataSources() {
	this.metadataSourcesAccessed = true;
	if (this.metadataSources == null) {
		BootstrapServiceRegistryBuilder builder = new BootstrapServiceRegistryBuilder();
		if (this.resourcePatternResolver != null) {
			builder = builder.applyClassLoader(this.resourcePatternResolver.getClassLoader());
		}
		if (this.hibernateIntegrators != null) {
			for (Integrator integrator : this.hibernateIntegrators) {
				builder = builder.applyIntegrator(integrator);
			}
		}
		this.metadataSources = new MetadataSources(builder.build());
	}
	return this.metadataSources;
}
 
Example 2
Source File: LocalSessionFactoryBean.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Determine the Hibernate {@link MetadataSources} to use.
 * <p>Can also be externally called to initialize and pre-populate a {@link MetadataSources}
 * instance which is then going to be used for {@link SessionFactory} building.
 * @return the MetadataSources to use (never {@code null})
 * @since 4.3
 * @see LocalSessionFactoryBuilder#LocalSessionFactoryBuilder(DataSource, ResourceLoader, MetadataSources)
 */
public MetadataSources getMetadataSources() {
	this.metadataSourcesAccessed = true;
	if (this.metadataSources == null) {
		BootstrapServiceRegistryBuilder builder = new BootstrapServiceRegistryBuilder();
		if (this.resourcePatternResolver != null) {
			builder = builder.applyClassLoader(this.resourcePatternResolver.getClassLoader());
		}
		if (this.hibernateIntegrators != null) {
			for (Integrator integrator : this.hibernateIntegrators) {
				builder = builder.applyIntegrator(integrator);
			}
		}
		this.metadataSources = new MetadataSources(builder.build());
	}
	return this.metadataSources;
}
 
Example 3
Source File: JpaConfiguration.java    From micronaut-sql with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the default {@link BootstrapServiceRegistryBuilder}.
 *
 * @param integrator  The integrator to use. Can be null
 * @param classLoader The class loade rto use
 * @return The BootstrapServiceRegistryBuilder
 */
@SuppressWarnings("WeakerAccess")
protected BootstrapServiceRegistryBuilder createBootstrapServiceRegistryBuilder(
        @Nullable Integrator integrator,
        ClassLoader classLoader) {
    BootstrapServiceRegistryBuilder bootstrapServiceRegistryBuilder = new BootstrapServiceRegistryBuilder();
    bootstrapServiceRegistryBuilder.applyClassLoader(classLoader);
    if (integrator != null) {
        bootstrapServiceRegistryBuilder.applyIntegrator(integrator);
    }
    return bootstrapServiceRegistryBuilder;
}
 
Example 4
Source File: LocalSessionFactoryBean.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Determine the Hibernate {@link MetadataSources} to use.
 * <p>Can also be externally called to initialize and pre-populate a {@link MetadataSources}
 * instance which is then going to be used for {@link SessionFactory} building.
 * @return the MetadataSources to use (never {@code null})
 * @since 4.3
 * @see LocalSessionFactoryBuilder#LocalSessionFactoryBuilder(DataSource, ResourceLoader, MetadataSources)
 */
public MetadataSources getMetadataSources() {
	this.metadataSourcesAccessed = true;
	if (this.metadataSources == null) {
		BootstrapServiceRegistryBuilder builder = new BootstrapServiceRegistryBuilder();
		if (this.resourcePatternResolver != null) {
			builder = builder.applyClassLoader(this.resourcePatternResolver.getClassLoader());
		}
		this.metadataSources = new MetadataSources(builder.build());
	}
	return this.metadataSources;
}
 
Example 5
Source File: BaseCoreFunctionalTestCase.java    From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected BootstrapServiceRegistry buildBootstrapServiceRegistry() {
  final BootstrapServiceRegistryBuilder builder = new BootstrapServiceRegistryBuilder();
  builder.applyClassLoader( getClass().getClassLoader() );
  prepareBootstrapRegistryBuilder( builder );
  return builder.build();
}