@Bean public EntityManagerFactory entityManagerFactory() { Properties jpaProterties = new Properties(); jpaProterties.put("hibernate.dialect", environment.getRequiredProperty("hibernate.dialect")); jpaProterties.put( "hibernate.format_sql", environment.getRequiredProperty("hibernate.format_sql")); jpaProterties.put( "hibernate.ejb.naming_strategy", environment.getRequiredProperty("hibernate.ejb.naming_strategy")); jpaProterties.put("hibernate.show_sql", environment.getRequiredProperty("hibernate.show_sql")); jpaProterties.put( "hibernate.generate_statistics", environment.getRequiredProperty("hibernate.generate_statistics")); HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setGenerateDdl(false); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan("br.com.uol.cubus.support.domain"); factory.setDataSource(dataSource()); factory.setJpaProperties(jpaProterties); factory.afterPropertiesSet(); return factory.getObject(); }
@Bean public EntityManagerFactory entityManagerFactory() { HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setGenerateDdl(true); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan("com.kjipo.event"); // TODO Is there another way to attach the data source to the EntityManagerFactory? factory.setDataSource(dataSource); factory.afterPropertiesSet(); return factory.getObject(); }
@Bean public EntityManagerFactory entityManagerFactory() { HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setShowSql(showSql()); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan("com.softtech.web.model"); factory.setJpaProperties(additionalProperties()); factory.setDataSource(dataSource()); factory.afterPropertiesSet(); return factory.getObject(); }
@Bean public EntityManagerFactory entityManagerFactory() { HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setShowSql(true); HashMap<String, String> hibernateProperties = new HashMap<String, String>(); hibernateProperties.put("hibernate.hbm2ddl.auto", "create-drop"); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan("org.chikoo.core.model.entity"); factory.setJpaPropertyMap(hibernateProperties); factory.setDataSource(dataSource()); factory.afterPropertiesSet(); return factory.getObject(); }
@Bean public EntityManagerFactory entityManagerFactory() { HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter(); hibernateJpaVendorAdapter.setGenerateDdl(true); hibernateJpaVendorAdapter.setShowSql(true); LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean(); emf.setDataSource(dataSource); emf.setPackagesToScan("po"); emf.setJpaVendorAdapter(hibernateJpaVendorAdapter); Properties properties = new Properties(); properties.setProperty("hibernate.hbm2ddl.auto", "create-drop"); properties.setProperty("hibernate.dialect", "org.hibernate.dialect.Oracle10gDialect"); emf.setJpaProperties(properties); emf.afterPropertiesSet(); return emf.getObject(); }
@Bean public EntityManagerFactory entityManagerFactory() { HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setGenerateDdl(true); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan( new ConfigAccessor() .get() .getDataSources() .get(new ConfigAccessor().get().getDefaultDataSourceName()) .toArray(new String[0])); factory.setDataSource(dataSource); factory.afterPropertiesSet(); return factory.getObject(); }
@Bean public JpaTransactionManager jpaTransactionManager() { return new JpaTransactionManager(emf.getObject()); }