use of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean 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;
}
use of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in project gpconnect-demonstrator by nhsconnect.
the class DataSourceConfig method entityManagerFactory.
@Bean
public EntityManagerFactory entityManagerFactory(DataSource dataSource) {
final Database database = Database.valueOf(vendor.toUpperCase());
final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
vendorAdapter.setShowSql(showSql);
vendorAdapter.setGenerateDdl(true);
vendorAdapter.setDatabase(database);
final LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
factory.setJpaVendorAdapter(vendorAdapter);
factory.setPackagesToScan("uk.gov.hscic");
factory.setDataSource(dataSource);
factory.afterPropertiesSet();
return factory.getObject();
}
use of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in project commons-dao by reportportal.
the class DatabaseConfiguration method entityManagerFactory.
@Bean
public EntityManagerFactory entityManagerFactory() {
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
vendorAdapter.setGenerateDdl(false);
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
factory.setJpaVendorAdapter(vendorAdapter);
factory.setPackagesToScan("com.epam.ta.reportportal.commons", "com.epam.ta.reportportal.entity");
factory.setDataSource(dataSource);
Properties jpaProperties = new Properties();
jpaProperties.setProperty("hibernate.dialect", "com.epam.ta.reportportal.commons.JsonbAwarePostgresDialect");
factory.setJpaProperties(jpaProperties);
factory.afterPropertiesSet();
return factory.getObject();
}
use of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in project cas by apereo.
the class JpaEventsConfiguration method eventsEntityManagerFactory.
@Lazy
@Bean
public LocalContainerEntityManagerFactoryBean eventsEntityManagerFactory() {
final LocalContainerEntityManagerFactoryBean bean = Beans.newHibernateEntityManagerFactoryBean(new JpaConfigDataHolder(jpaEventVendorAdapter(), "jpaEventRegistryContext", jpaEventPackagesToScan(), dataSourceEvent()), casProperties.getEvents().getJpa());
bean.getJpaPropertyMap().put("hibernate.enable_lazy_load_no_trans", Boolean.TRUE);
return bean;
}
use of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in project spring-security by spring-projects.
the class DataConfig method entityManagerFactory.
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
vendorAdapter.setDatabase(Database.HSQL);
vendorAdapter.setGenerateDdl(true);
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
factory.setJpaVendorAdapter(vendorAdapter);
factory.setPackagesToScan(Message.class.getPackage().getName());
factory.setDataSource(dataSource());
return factory;
}
Aggregations