use of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in project cloudbreak by hortonworks.
the class DatabaseConfig method entityManagerFactory.
@Bean
@DependsOn("databaseUpMigration")
public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws SQLException {
LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean();
entityManagerFactory.setPackagesToScan("com.sequenceiq.cloudbreak.domain");
entityManagerFactory.setDataSource(dataSource());
entityManagerFactory.setJpaVendorAdapter(jpaVendorAdapter());
entityManagerFactory.setJpaProperties(jpaProperties());
entityManagerFactory.afterPropertiesSet();
return entityManagerFactory;
}
use of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in project spring-security by spring-projects.
the class ApplicationConfig method entityManagerFactory.
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
vendorAdapter.setDatabase(Database.HSQL);
vendorAdapter.setGenerateDdl(true);
vendorAdapter.setShowSql(true);
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
factory.setJpaVendorAdapter(vendorAdapter);
factory.setPackagesToScan(User.class.getPackage().getName());
factory.setDataSource(dataSource());
return factory;
}
use of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in project Asqatasun by Asqatasun.
the class PersistenceCommonConfig method entityManagerFactory.
/**
* @param dataSource
* @param url
* @param packagesToScan
* @return
*/
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource, String url, String... packagesToScan) {
LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
emf.setDataSource(dataSource);
emf.setPackagesToScan(packagesToScan);
HibernateJpaVendorAdapter hibernateAdapter = new HibernateJpaVendorAdapter();
hibernateAdapter.setShowSql(hibernateShowSql);
final Properties jpaProperties = new Properties();
jpaProperties.put(HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE, hibernateUse2ndLevelQueryCache);
jpaProperties.put(HIBERNATE_CACHE_USE_QUERY_CACHE, hibernateUseQueryCache);
jpaProperties.put(HIBERNATE_CACHE_REGION_FACTORY_CLASS, hibernateRegionFactory);
jpaProperties.put(HIBERNATE_GENERATE_STATISTICS, false);
jpaProperties.put(HIBERNATE_JDBC_BATCH_SIZE, hibernateJdbcBatchSize);
jpaProperties.put(HIBERNATE_MAX_FETCH_DEPTH, hibernateMaxFetchDepth);
jpaProperties.put(HIBERNATE_USE_OUTER_JOIN, hibernateUseOuterJoin);
jpaProperties.put(HIBERNATE_DEFAULT_BATCH_FETCH_SIZE, hibernateDefaultBatchFetchSize);
jpaProperties.put(HIBERNATE_DIALECT, getHibernateDialedFromUrl(url));
if (PersistenceCommonConfig.isHsqlDb(url)) {
jpaProperties.put("javax.persistence.schema-generation.database.action", "drop-and-create");
}
emf.setJpaProperties(jpaProperties);
emf.setJpaVendorAdapter(hibernateAdapter);
return emf;
}
use of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in project spring-boot by spring-projects.
the class AbstractJpaAutoConfigurationTests method usesManuallyDefinedLocalContainerEntityManagerFactoryBeanIfAvailable.
@Test
void usesManuallyDefinedLocalContainerEntityManagerFactoryBeanIfAvailable() {
this.contextRunner.withUserConfiguration(TestConfigurationWithLocalContainerEntityManagerFactoryBean.class).run((context) -> {
LocalContainerEntityManagerFactoryBean factoryBean = context.getBean(LocalContainerEntityManagerFactoryBean.class);
Map<String, Object> map = factoryBean.getJpaPropertyMap();
assertThat(map.get("configured")).isEqualTo("manually");
});
}
use of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in project kylo by Teradata.
the class OperationalMetadataConfig method entityManagerFactory.
/**
* Return the entity manager factory for Hibernate
*
* @return the Hibernate entity manager factory
*/
@Bean(name = "operationalMetadataEntityManagerFactory")
public EntityManagerFactory entityManagerFactory(@Qualifier("dataSource") DataSource dataSource) {
LocalContainerEntityManagerFactoryBean emfBean = new LocalContainerEntityManagerFactoryBean();
emfBean.setDataSource(dataSource);
emfBean.setPackagesToScan("com.thinkbiganalytics.jobrepo.jpa", "com.thinkbiganalytics.metadata.jpa");
emfBean.setJpaVendorAdapter(jpaVendorAdapter());
emfBean.afterPropertiesSet();
return emfBean.getObject();
}
Aggregations