Search in sources :

Example 11 with Integrator

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[]
}
Also used : BootstrapServiceRegistryBuilder(org.hibernate.boot.registry.BootstrapServiceRegistryBuilder) BeanValidationIntegrator(org.hibernate.cfg.beanvalidation.BeanValidationIntegrator) BeanValidationIntegrator(org.hibernate.cfg.beanvalidation.BeanValidationIntegrator) Integrator(org.hibernate.integrator.spi.Integrator) BootstrapServiceRegistry(org.hibernate.boot.registry.BootstrapServiceRegistry) Test(org.junit.Test)

Example 12 with Integrator

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;
}
Also used : BootstrapServiceRegistryBuilder(org.hibernate.boot.registry.BootstrapServiceRegistryBuilder) MetadataSources(org.hibernate.boot.MetadataSources) Integrator(org.hibernate.integrator.spi.Integrator)

Aggregations

Integrator (org.hibernate.integrator.spi.Integrator)12 Metadata (org.hibernate.boot.Metadata)7 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)7 SessionFactoryServiceRegistry (org.hibernate.service.spi.SessionFactoryServiceRegistry)7 BootstrapServiceRegistryBuilder (org.hibernate.boot.registry.BootstrapServiceRegistryBuilder)4 EventListenerRegistry (org.hibernate.event.service.spi.EventListenerRegistry)4 StrategyRegistrationProvider (org.hibernate.boot.registry.selector.StrategyRegistrationProvider)3 MetadataSources (org.hibernate.boot.MetadataSources)2 TypeContributor (org.hibernate.boot.model.TypeContributor)2 BootstrapServiceRegistry (org.hibernate.boot.registry.BootstrapServiceRegistry)2 BeanValidationIntegrator (org.hibernate.cfg.beanvalidation.BeanValidationIntegrator)2 IntegratorProvider (org.hibernate.jpa.boot.spi.IntegratorProvider)2 StrategyRegistrationProviderList (org.hibernate.jpa.boot.spi.StrategyRegistrationProviderList)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Properties (java.util.Properties)1 MetadataBuilder (org.hibernate.boot.MetadataBuilder)1 StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)1 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)1 TypeContributorList (org.hibernate.jpa.boot.spi.TypeContributorList)1