use of org.hibernate.boot.registry.BootstrapServiceRegistryBuilder 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.boot.registry.BootstrapServiceRegistryBuilder in project hibernate-orm by hibernate.
the class DialectFactoryTest method setUp.
@Before
public void setUp() {
final BootstrapServiceRegistry bootReg = new BootstrapServiceRegistryBuilder().applyClassLoader(DialectFactoryTest.class.getClassLoader()).build();
registry = new StandardServiceRegistryBuilder(bootReg).build();
dialectFactory = new DialectFactoryImpl();
dialectFactory.injectServices((ServiceRegistryImplementor) registry);
}
use of org.hibernate.boot.registry.BootstrapServiceRegistryBuilder 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());
}
this.metadataSources = new MetadataSources(builder.build());
}
return this.metadataSources;
}
use of org.hibernate.boot.registry.BootstrapServiceRegistryBuilder in project wildfly by wildfly.
the class SFSBHibernateSFNaturalId method setupConfig.
public void setupConfig() {
// static {
try {
// prepare the configuration
Configuration configuration = new Configuration().setProperty(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true");
configuration.setProperty(Environment.HBM2DDL_AUTO, "create-drop");
configuration.setProperty(Environment.DATASOURCE, "java:jboss/datasources/ExampleDS");
// configuration.configure("hibernate.cfg.xml");
// fetch the properties
Properties properties = new Properties();
properties.putAll(configuration.getProperties());
Environment.verifyProperties(properties);
ConfigurationHelper.resolvePlaceHolders(properties);
// build the serviceregistry
final BootstrapServiceRegistryBuilder bootstrapbuilder = new BootstrapServiceRegistryBuilder();
ServiceRegistry serviceRegistry = builder.build();
// Create the SessionFactory from Configuration
sessionFactory = configuration.configure("hibernate.cfg.xml").buildSessionFactory(serviceRegistry);
} catch (Throwable ex) {
throw new RuntimeException("Could not setup config", ex);
}
}
Aggregations