Search in sources :

Example 1 with HibernateSettings

use of org.springframework.boot.autoconfigure.orm.jpa.HibernateSettings in project ArachneCentralAPI by OHDSI.

the class HibernateConfig method entityManagerFactory.

@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource, MultiTenantConnectionProvider multiTenantConnectionProviderImpl, CurrentTenantIdentifierResolver currentTenantIdentifierResolverImpl, HibernateProperties hibernateProperties) {
    Map<String, Object> properties = hibernateProperties.determineHibernateProperties(jpaProperties.getProperties(), new HibernateSettings());
    // NOTE:
    // dummy setting, just to force Hibernate to use custom connection provider through which we pass current tenant id to DB
    properties.put(Environment.MULTI_TENANT, MultiTenancyStrategy.SCHEMA);
    properties.put(Environment.MULTI_TENANT_CONNECTION_PROVIDER, multiTenantConnectionProviderImpl);
    properties.put(Environment.MULTI_TENANT_IDENTIFIER_RESOLVER, currentTenantIdentifierResolverImpl);
    properties.put("hibernate.ejb.interceptor", queryInterceptor);
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource);
    em.setPackagesToScan("com.odysseusinc.arachne.*");
    em.setJpaVendorAdapter(jpaVendorAdapter());
    em.setJpaPropertyMap(properties);
    return em;
}
Also used : HibernateSettings(org.springframework.boot.autoconfigure.orm.jpa.HibernateSettings) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Aggregations

HibernateSettings (org.springframework.boot.autoconfigure.orm.jpa.HibernateSettings)1 Bean (org.springframework.context.annotation.Bean)1 LocalContainerEntityManagerFactoryBean (org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)1