List of usage examples for org.springframework.orm.jpa LocalContainerEntityManagerFactoryBean setJpaProperties
public void setJpaProperties(Properties jpaProperties)
From source file:fredboat.db.DatabaseManager.java
/** * @param jdbcUrl connection to the database * @param dialect set to null or empty String to have it autodetected by Hibernate, chosen jdbc driver must support that *///from ww w. ja v a2s. c o m public static void startup(String jdbcUrl, String dialect, int poolSize) { state = DatabaseState.INITIALIZING; try { if (Config.CONFIG.isUseSshTunnel()) { connectSSH(); } //These are now located in the resources directory as XML Properties properties = new Properties(); properties.put("configLocation", "hibernate.cfg.xml"); properties.put("hibernate.connection.provider_class", "org.hibernate.hikaricp.internal.HikariCPConnectionProvider"); properties.put("hibernate.connection.url", jdbcUrl); if (dialect != null && !"".equals(dialect)) properties.put("hibernate.dialect", dialect); properties.put("hibernate.cache.region.factory_class", "org.hibernate.cache.ehcache.EhCacheRegionFactory"); //properties.put("hibernate.show_sql", "true"); //automatically update the tables we need //caution: only add new columns, don't remove or alter old ones, otherwise manual db table migration needed properties.put("hibernate.hbm2ddl.auto", "update"); properties.put("hibernate.hikari.maximumPoolSize", Integer.toString(poolSize)); properties.put("hibernate.hikari.idleTimeout", Integer.toString(Config.HIKARI_TIMEOUT_MILLISECONDS)); LocalContainerEntityManagerFactoryBean emfb = new LocalContainerEntityManagerFactoryBean(); emfb.setPackagesToScan("fredboat.db.entity"); emfb.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); emfb.setJpaProperties(properties); emfb.setPersistenceUnitName("fredboat.test"); emfb.setPersistenceProviderClass(HibernatePersistenceProvider.class); emfb.afterPropertiesSet(); emf = emfb.getObject(); log.info("Started Hibernate"); state = DatabaseState.READY; } catch (Exception ex) { state = DatabaseState.FAILED; throw new RuntimeException("Failed starting database connection", ex); } }
From source file:corner.orm.gae.GaeModule.java
public static EntityManagerFactory buildEntityManagerFactory( @Autobuild DatastorePersistenceProvider persistenceProvider) { LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); entityManagerFactoryBean.setPersistenceProvider(persistenceProvider); Properties jpaProperties = new Properties(); jpaProperties.put("datanucleus.NontransactionalRead", "true"); jpaProperties.put("datanucleus.NontransactionalWrite", "true"); jpaProperties.put("datanucleus.ConnectionURL", "appengine"); jpaProperties.put("datanucleus.jpa.addClassTransformer", "false"); entityManagerFactoryBean.setJpaProperties(jpaProperties); LoadTimeWeaver loadTimeWeaver = new SimpleLoadTimeWeaver(); entityManagerFactoryBean.setLoadTimeWeaver(loadTimeWeaver); entityManagerFactoryBean.afterPropertiesSet(); return entityManagerFactoryBean.getObject(); }
From source file:io.cloudslang.schema.context.ScoreDatabaseContext.java
@Bean @DependsOn("liquibase") LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) { //Init the IdentityManager SimpleHiloIdentifierGenerator.setDataSource(dataSource); //Now create the bean LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean(); emf.setDataSource(dataSource);/*from ww w . j a v a 2 s. com*/ emf.setJpaProperties(jpaProperties()); emf.setJpaVendorAdapter(jpaVendorAdapter()); emf.setPersistenceProviderClass(HibernatePersistence.class); emf.setPackagesToScan("io.cloudslang"); return emf; }
From source file:uk.ac.ebi.ep.data.testConfig.SpringDataMockConfig.java
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { Properties properties = new Properties(); properties.setProperty("hibernate.cache.provider_class", "org.hibernate.cache.NoCacheProvider"); properties.setProperty("hibernate.format_sql", "true"); properties.setProperty(" hibernate.dialect", "org.hibernate.dialect.H2Dialect"); //properties.setProperty("hibernate.hbm2ddl.auto", "create-drop"); //properties.setProperty("hibernate.ejb.naming_strategy", "org.hibernate.cfg.ImprovedNamingStrategy"); properties.setProperty("spring.jpa.hibernate.ddl-auto", "update"); HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setDatabase(Database.H2); vendorAdapter.setGenerateDdl(true);// ww w. ja v a 2s . c o m vendorAdapter.setShowSql(false); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); factory.setJpaProperties(properties); factory.setPackagesToScan("uk.ac.ebi.ep.data.domain"); factory.setDataSource(dataSource()); return factory; }
From source file:io.gravitee.repository.jdbc.config.JdbcRepositoryConfiguration.java
@Bean public LocalContainerEntityManagerFactoryBean graviteeEntityManagerFactory(DataSource dataSource) { final Properties hibernateProperties = new Properties(); hibernateProperties.put("hibernate.show_sql", showSql); final LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); entityManagerFactoryBean.setPackagesToScan("io.gravitee.repository.jdbc.model"); entityManagerFactoryBean.setJpaProperties(hibernateProperties); entityManagerFactoryBean.setPersistenceProvider(new HibernatePersistenceProvider()); entityManagerFactoryBean.setPersistenceUnitName("graviteePU"); entityManagerFactoryBean.setDataSource(dataSource); return entityManagerFactoryBean; }
From source file:org.drugis.addis.config.MainConfig.java
@Bean(name = "emAddisCore") public LocalContainerEntityManagerFactoryBean entityManagerFactory() { HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setGenerateDdl(false); vendorAdapter.setShowSql(false);// ww w . j a v a 2 s . c o m LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setJpaProperties(additionalProperties()); em.setJpaVendorAdapter(vendorAdapter); em.setPackagesToScan("org.drugis.addis.projects", "org.drugis.addis.outcomes", "org.drugis.addis.interventions", "org.drugis.addis.security", "org.drugis.addis.analyses", "org.drugis.addis.scenarios", "org.drugis.addis.models", "org.drugis.addis.problems", "org.drugis.addis.covariates", "org.drugis.trialverse", "org.drugis.addis.scaledUnits", "org.drugis.addis.subProblems", "org.drugis.addis.ordering", "org.drugis.addis.workspaceSettings"); em.setDataSource(dataSource()); em.setPersistenceUnitName("addisCore"); em.setLoadTimeWeaver(new InstrumentationLoadTimeWeaver()); em.afterPropertiesSet(); return em; }
From source file:br.com.joaops.smt.configuration.PersistenceConfig.java
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setPackagesToScan(this.getPackagesToScan()); JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); em.setJpaVendorAdapter(vendorAdapter); em.setJpaProperties(getAdditionalProperties()); return em;//from ww w . ja va 2s .com }
From source file:ru.langboost.config.DBConfig.java
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { EclipseLinkJpaVendorAdapter vendorAdapter = new EclipseLinkJpaVendorAdapter(); vendorAdapter.setGenerateDdl(true);//from w w w . jav a 2s . c o m vendorAdapter.setShowSql(true); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan(Environment.BASE_PACKAGE); factory.setDataSource(dataSource()); factory.setJpaProperties(jpaProperties()); return factory; }
From source file:fr.lepellerin.ecole.config.GestEcolePersistenceConfig.java
/** * * @return retourne l'entity manager.// w ww . j a va 2 s. c o m */ @Bean @Autowired public LocalContainerEntityManagerFactoryBean entityManagerFactory(final DataSource datasource) { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(datasource); em.setPackagesToScan(new String[] { "fr.lepellerin.ecole.bean" }); em.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); em.setJpaProperties(additionalProperties()); return em; }
From source file:br.com.joaops.springdatajpajavaconfigfirebird.configuration.DataConfiguration.java
@Bean public EntityManagerFactory entityManagerFactory() { HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setGenerateDdl(true);//w ww.j av a2 s .c o m Properties jpaProperties = new Properties(); jpaProperties.put("hibernate.hbm2ddl.auto", "create-drop"); jpaProperties.put("hibernate.dialect", "org.hibernate.dialect.FirebirdDialect"); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setDataSource(dataSource()); factory.setPackagesToScan("br.com.joaops.springdatajpajavaconfigfirebird.model"); factory.setJpaVendorAdapter(vendorAdapter); factory.setJpaProperties(jpaProperties); factory.afterPropertiesSet(); return factory.getObject(); }