use of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in project Activiti by Activiti.
the class DatabaseConfiguration method entityManagerFactory.
@Bean(name = "entityManagerFactory")
public EntityManagerFactory entityManagerFactory() {
LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
entityManagerFactoryBean.setDataSource(dataSource());
entityManagerFactoryBean.setPackagesToScan("org.activiti.rest.api.jpa.model");
entityManagerFactoryBean.setPersistenceUnitName("test");
HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
hibernateJpaVendorAdapter.setShowSql(false);
hibernateJpaVendorAdapter.setGenerateDdl(true);
hibernateJpaVendorAdapter.setDatabase(Database.H2);
entityManagerFactoryBean.setJpaVendorAdapter(hibernateJpaVendorAdapter);
entityManagerFactoryBean.afterPropertiesSet();
return entityManagerFactoryBean.getObject();
}
use of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in project Protocol-Adapter-IEC61850 by OSGP.
the class Iec61850OsgpCoreDbApiPersistenceConfig method iec61850OsgpCoreDbApiEntityManagerFactory.
/**
* Method for creating the Entity Manager Factory Bean.
*
* @return LocalContainerEntityManagerFactoryBean
* @throws ClassNotFoundException
* when class not found
*/
@Bean
public LocalContainerEntityManagerFactoryBean iec61850OsgpCoreDbApiEntityManagerFactory() throws ClassNotFoundException {
final LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
entityManagerFactoryBean.setPersistenceUnitName("OSGP_CORE_DB_API_IEC61850");
entityManagerFactoryBean.setDataSource(this.getOsgpCoreDbApiDataSource());
entityManagerFactoryBean.setPackagesToScan(ENVIRONMENT.getRequiredProperty(PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN));
entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistence.class);
final Properties jpaProperties = new Properties();
jpaProperties.put(HIBERNATE_DIALECT_KEY, ENVIRONMENT.getRequiredProperty(PROPERTY_NAME_HIBERNATE_DIALECT_VALUE));
jpaProperties.put(HIBERNATE_FORMAT_SQL_KEY, ENVIRONMENT.getRequiredProperty(PROPERTY_NAME_HIBERNATE_FORMAT_SQL_VALUE));
jpaProperties.put(HIBERNATE_NAMING_STRATEGY_KEY, ENVIRONMENT.getRequiredProperty(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY_VALUE));
jpaProperties.put(HIBERNATE_SHOW_SQL_KEY, ENVIRONMENT.getRequiredProperty(PROPERTY_NAME_HIBERNATE_SHOW_SQL_VALUE));
entityManagerFactoryBean.setJpaProperties(jpaProperties);
return entityManagerFactoryBean;
}
use of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in project cas by apereo.
the class JpaBeans method newHibernateEntityManagerFactoryBean.
/**
* New entity manager factory bean.
*
* @param config the config
* @param jpaProperties the jpa properties
* @return the local container entity manager factory bean
*/
public static LocalContainerEntityManagerFactoryBean newHibernateEntityManagerFactoryBean(final JpaConfigDataHolder config, final AbstractJpaProperties jpaProperties) {
final LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean();
bean.setJpaVendorAdapter(config.getJpaVendorAdapter());
if (StringUtils.isNotBlank(config.getPersistenceUnitName())) {
bean.setPersistenceUnitName(config.getPersistenceUnitName());
}
bean.setPackagesToScan(config.getPackagesToScan().toArray(new String[] {}));
if (config.getDataSource() != null) {
bean.setDataSource(config.getDataSource());
}
final Properties properties = new Properties();
properties.put(Environment.DIALECT, jpaProperties.getDialect());
properties.put(Environment.HBM2DDL_AUTO, jpaProperties.getDdlAuto());
properties.put(Environment.STATEMENT_BATCH_SIZE, jpaProperties.getBatchSize());
if (StringUtils.isNotBlank(jpaProperties.getDefaultCatalog())) {
properties.put(Environment.DEFAULT_CATALOG, jpaProperties.getDefaultCatalog());
}
if (StringUtils.isNotBlank(jpaProperties.getDefaultSchema())) {
properties.put(Environment.DEFAULT_SCHEMA, jpaProperties.getDefaultSchema());
}
properties.put(Environment.ENABLE_LAZY_LOAD_NO_TRANS, Boolean.TRUE);
properties.put(Environment.FORMAT_SQL, Boolean.TRUE);
properties.putAll(jpaProperties.getProperties());
bean.setJpaProperties(properties);
return bean;
}
use of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in project av-service by dvoraka.
the class DbConfig method entityManagerFactory.
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) {
LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
entityManagerFactoryBean.setDataSource(dataSource);
entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
entityManagerFactoryBean.setPackagesToScan("dvoraka.avservice.db.model");
entityManagerFactoryBean.setJpaProperties(hibernateProperties());
return entityManagerFactoryBean;
}
use of org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean in project perry by ca-cwds.
the class CMSConfiguration method entityManagerFactory.
@Bean
@Primary
@Autowired
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) {
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource);
em.setJpaPropertyMap(jpaProperties().getHibernateProperties(dataSource));
em.setPackagesToScan("gov.ca.cwds.data.persistence.auth", "gov.ca.cwds.data.auth");
em.setPersistenceUnitName("default");
em.setJpaVendorAdapter(jpaVendorAdapter());
return em;
}
Aggregations