org.hibernate.ejb.HibernatePersistence Java Examples

The following examples show how to use org.hibernate.ejb.HibernatePersistence. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JpaTransactionManagerConfiguration.java    From hypersistence-optimizer with Apache License 2.0 7 votes vote down vote up
@Bean
public EntityManagerFactory entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
    entityManagerFactoryBean.setPersistenceUnitName(persistenceUnitName());
    entityManagerFactoryBean.setPersistenceProvider(new HibernatePersistence());
    entityManagerFactoryBean.setDataSource(dataSource());
    entityManagerFactoryBean.setPackagesToScan(packagesToScan());

    JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    entityManagerFactoryBean.setJpaVendorAdapter(vendorAdapter);
    entityManagerFactoryBean.setJpaProperties(additionalProperties());

    entityManagerFactoryBean.afterPropertiesSet();

    return HypersistenceHibernatePersistenceProvider.decorate(
        entityManagerFactoryBean.getNativeEntityManagerFactory()
    );
}
 
Example #2
Source File: DatabaseConfiguration.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Bean
public EntityManagerFactory entityManagerFactory() {
    log.debug("Configuring EntityManager");
    LocalContainerEntityManagerFactoryBean lcemfb = new LocalContainerEntityManagerFactoryBean();
    lcemfb.setPersistenceProvider(new HibernatePersistence());
    lcemfb.setPersistenceUnitName("persistenceUnit");
    lcemfb.setDataSource(dataSource());
    lcemfb.setJpaDialect(new HibernateJpaDialect());
    lcemfb.setJpaVendorAdapter(jpaVendorAdapter());

    Properties jpaProperties = new Properties();
    jpaProperties.put("hibernate.cache.use_second_level_cache", false);
    jpaProperties.put("hibernate.generate_statistics", env.getProperty("hibernate.generate_statistics", Boolean.class, false));
    lcemfb.setJpaProperties(jpaProperties);

    lcemfb.setPackagesToScan("com.activiti.domain");
    lcemfb.afterPropertiesSet();
    return lcemfb.getObject();
}
 
Example #3
Source File: SpringWebConfig.java    From spring-mvc-react with MIT License 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
	LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
	entityManagerFactoryBean.setDataSource(dataSource());
	entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistence.class);
	entityManagerFactoryBean.setPackagesToScan(env.getRequiredProperty(PROP_ENTITYMANAGER_PACKAGES_TO_SCAN));

	entityManagerFactoryBean.setJpaProperties(getHibernateProperties());

	return entityManagerFactoryBean;
}
 
Example #4
Source File: AbstractTest.java    From hibernate-types with Apache License 2.0 5 votes vote down vote up
protected EntityManagerFactory newEntityManagerFactory() {
    PersistenceUnitInfo persistenceUnitInfo = persistenceUnitInfo(getClass().getSimpleName());
    Map<String, Object> configuration = new HashMap<String, Object>();

    HibernatePersistence hibernatePersistence = new HibernatePersistence();
    return hibernatePersistence.createContainerEntityManagerFactory(persistenceUnitInfo, configuration);
}
 
Example #5
Source File: SpringWebConfig.java    From spring-mvc-react with MIT License 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
	LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
	entityManagerFactoryBean.setDataSource(dataSource());
	entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistence.class);
	entityManagerFactoryBean.setPackagesToScan(env.getRequiredProperty(PROP_ENTITYMANAGER_PACKAGES_TO_SCAN));

	entityManagerFactoryBean.setJpaProperties(getHibernateProperties());

	return entityManagerFactoryBean;
}
 
Example #6
Source File: WebConfig.java    From maven-framework-project with MIT License 5 votes vote down vote up
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
	LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
	entityManagerFactoryBean.setDataSource(dataSource());
	entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistence.class);
	entityManagerFactoryBean.setPackagesToScan(env.getRequiredProperty(PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN));
	
	entityManagerFactoryBean.setJpaProperties(hibProperties());
	
	return entityManagerFactoryBean;
}
 
Example #7
Source File: PersistenceUnitInfoImpl.java    From hibernate-types with Apache License 2.0 4 votes vote down vote up
@Override
public String getPersistenceProviderClassName() {
    return HibernatePersistence.class.getName();
}