@Bean public EntityManagerFactory entityManagerFactory() { HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setDatabase(Database.H2); vendorAdapter.setGenerateDdl(jpaGenerateDdl); vendorAdapter.setShowSql(jpaShowSql); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan("org.bricket.b4.*.entity"); factory.setDataSource(dataSource()); factory.setJpaDialect(jpaDialect()); Map<String, String> jpaProperties = new HashMap<String, String>(); jpaProperties.put("hibernate.dialect", H2Dialect.class.getName()); jpaProperties.put("hibernate.cache.region.factory_class", EhCacheRegionFactory.class.getName()); jpaProperties.put("hibernate.cache.use_second_level_cache", "true"); jpaProperties.put("hibernate.cache.use_query_cache", "true"); jpaProperties.put("hibernate.cache.use_minimal_puts", "true"); factory.setJpaPropertyMap(jpaProperties); factory.afterPropertiesSet(); return factory.getObject(); }