use of org.hibernate.integrator.spi.Integrator in project hibernate-orm by hibernate.
the class BootstrapTest method test_bootstrap_bootstrap_native_registry_BootstrapServiceRegistry_example.
@Test
public void test_bootstrap_bootstrap_native_registry_BootstrapServiceRegistry_example() {
ClassLoader customClassLoader = Thread.currentThread().getContextClassLoader();
Integrator customIntegrator = new BeanValidationIntegrator();
// tag::bootstrap-bootstrap-native-registry-BootstrapServiceRegistry-example[]
BootstrapServiceRegistryBuilder bootstrapRegistryBuilder = new BootstrapServiceRegistryBuilder();
// add a custom ClassLoader
bootstrapRegistryBuilder.applyClassLoader(customClassLoader);
// manually add an Integrator
bootstrapRegistryBuilder.applyIntegrator(customIntegrator);
BootstrapServiceRegistry bootstrapRegistry = bootstrapRegistryBuilder.build();
// end::bootstrap-bootstrap-native-registry-BootstrapServiceRegistry-example[]
}
use of org.hibernate.integrator.spi.Integrator in project spring-framework by spring-projects.
the class LocalSessionFactoryBean method getMetadataSources.
/**
* 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;
}
Aggregations