List of usage examples for org.springframework.orm.jpa LocalContainerEntityManagerFactoryBean setDataSource
public void setDataSource(DataSource dataSource)
From source file:com.dominion.salud.pedicom.configuration.PEDICOMJpaConfiguration.java
@Bean(name = "MainEM") @Autowired/*from ww w. j ava 2s . c o m*/ public EntityManagerFactory entityManagerFactory() throws Exception { HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter(); adapter.setGenerateDdl( Boolean.getBoolean(StringUtils.trim(environment.getRequiredProperty("hibernate.generate_ddl")))); adapter.setShowSql( Boolean.getBoolean(StringUtils.trim(environment.getRequiredProperty("hibernate.show_sql")))); adapter.setDatabasePlatform(StringUtils.trim(environment.getRequiredProperty("hibernate.dialect"))); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setDataSource(routingDataSource()); factory.setJpaVendorAdapter(adapter); factory.setPackagesToScan("com.dominion.salud.pedicom.negocio.entities"); factory.setPersistenceUnitName("MainEM"); factory.afterPropertiesSet(); factory.setLoadTimeWeaver(new InstrumentationLoadTimeWeaver()); return factory.getObject(); }
From source file:pl.softech.eav.HSqlConfig.java
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory(final DataSource ds) { final LocalContainerEntityManagerFactoryBean lemfb = new LocalContainerEntityManagerFactoryBean(); lemfb.setDataSource(ds); lemfb.setJpaVendorAdapter(jpaVendorAdapter()); lemfb.setPackagesToScan("pl.softech.eav.domain"); final Properties jpaProperties = new Properties(); jpaProperties.setProperty("hibernate.cache.region.factory_class", "org.hibernate.cache.ehcache.EhCacheRegionFactory"); jpaProperties.setProperty("hibernate.cache.use_second_level_cache", "true"); jpaProperties.setProperty("hibernate.show_sql", "true"); jpaProperties.setProperty("hibernate.format_sql", "true"); lemfb.setJpaProperties(jpaProperties); return lemfb; }
From source file:se.ivankrizsan.messagecowboy.testconfig.PersistenceTestConfiguration.java
/** * JPA entity manager factory bean.//ww w . ja va 2 s.c o m */ @Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { /* JPA entity manager factory. */ final LocalContainerEntityManagerFactoryBean theJpaEntityManagerFactory = new LocalContainerEntityManagerFactoryBean(); theJpaEntityManagerFactory.setDataSource(dataSource()); theJpaEntityManagerFactory.setPersistenceUnitName("message-cowboy"); theJpaEntityManagerFactory.setJpaProperties(jpaProperties()); /* JPA vendor adapter. */ final EclipseLinkJpaVendorAdapter theJpaVendorAdapter = new EclipseLinkJpaVendorAdapter(); theJpaVendorAdapter.setShowSql(true); theJpaEntityManagerFactory.setJpaVendorAdapter(theJpaVendorAdapter); return theJpaEntityManagerFactory; }
From source file:ru.develgame.jflickrorganizer.MainClass.java
@Bean public EntityManagerFactory entityManagerFactory() { LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean(); emf.setDataSource(dataSource()); emf.setJpaVendorAdapter(jpaVendorAdapter()); emf.setPackagesToScan("ru.develgame.jflickrorganizer.entities"); emf.setJpaProperties(additionalProperties()); emf.afterPropertiesSet();//from www . j a va 2 s.com return emf.getObject(); }
From source file:ch.javaee.basicMvc.config.StandaloneDataConfig.java
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean lcemfb = new LocalContainerEntityManagerFactoryBean(); lcemfb.setDataSource(this.hsqlInMemory()); lcemfb.setPackagesToScan(new String[] { "ch.javaee.basicMvc.domain" }); lcemfb.setPersistenceUnitName("MyPU"); HibernateJpaVendorAdapter va = new HibernateJpaVendorAdapter(); lcemfb.setJpaVendorAdapter(va);/* w w w. j a va2 s. co m*/ va.setDatabase(Database.HSQL); va.setGenerateDdl(true); va.setShowSql(true); va.setDatabasePlatform("org.hibernate.dialect.HSQLDialect"); Properties ps = new Properties(); ps.put("hibernate.dialect", "org.hibernate.dialect.HSQLDialect"); ps.put("hibernate.hbm2ddl.auto", "create"); lcemfb.setJpaProperties(ps); lcemfb.afterPropertiesSet(); return lcemfb; }
From source file:pl.java.scalatech.config.JpaEmbeddedConfig.java
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws SQLException { LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean(); lef.setDataSource(dataSource()); lef.setJpaVendorAdapter(jpaVendorAdapter()); lef.setJpaPropertyMap(jpaProperties()); lef.setPackagesToScan(jpaPackage); // eliminate persistence.xml return lef;/* w w w. j a v a 2s . c om*/ }
From source file:com.musala.configuration.RssAplicationConfiguration.java
@Bean(name = "entityManagerFactory") public EntityManagerFactory entityManagerFactory() throws SQLException { HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setDataSource(dataSource()); factory.setPackagesToScan("com.musala.db"); //factory.setPersistenceUnitName("persistenceUnit"); //TODO check why use it factory.setJpaVendorAdapter(vendorAdapter); factory.setJpaProperties(additionalProperties()); factory.afterPropertiesSet();/*from ww w . j ava 2s . co m*/ return factory.getObject(); }
From source file:org.ngrinder.infra.config.DatabaseConfig.java
/** * Create {@link LocalContainerEntityManagerFactoryBean} bean for Hibernate. Hibernate doesn't * support the search for the {@link Entity} classes in the other Jar files. This method * directly searches the {@link Entity} classes with {@link Reflections} not using Hibernate * entity class search feature to overcome the limitation * <p/>/* w ww. j a v a 2s .co m*/ * use annotation DependsOn to insure after databaseUpdater is * * @return {@link LocalContainerEntityManagerFactoryBean} */ @Bean(name = "emf") @DependsOn("databaseUpdater") public LocalContainerEntityManagerFactoryBean emf() { LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean(); emf.setDataSource(dataSource()); emf.setPersistenceUnitName("ngrinder"); HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter(); PropertiesWrapper databaseProperties = config.getDatabaseProperties(); Database database = Database.getDatabase(databaseProperties.getProperty(PROP_DATABASE_TYPE)); if (config.isClustered() && !database.isClusterSupport()) { CoreLogger.LOGGER.error("In cluster mode, H2 is not allowed to use. Please select cubrid as database"); } hibernateJpaVendorAdapter.setDatabasePlatform(database.getDialect()); hibernateJpaVendorAdapter.setShowSql(false); emf.setJpaVendorAdapter(hibernateJpaVendorAdapter); // To search entity packages from other jar files.. emf.setPackagesToScan("empty"); emf.setPersistenceUnitPostProcessors(new PersistenceUnitPostProcessor() { @Override public void postProcessPersistenceUnitInfo(MutablePersistenceUnitInfo pui) { Reflections reflections = new Reflections(ControllerConstants.DEFAULT_PACKAGE_NAME); for (Class<?> each : reflections.getTypesAnnotatedWith(Entity.class)) { LOGGER.trace("Entity class {} is detected as the SpringData entity.", each.getName()); pui.addManagedClassName(each.getName()); } } }); return emf; }
From source file:com.redrisegames.reigninwildWeb.ui.SampleWebUiApplication.java
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean(); entityManagerFactory.setDataSource(getDataSource()); // Classpath scanning of @Component, @Service, etc annotated class entityManagerFactory.setPackagesToScan("com.redrisegames.reigninwildWeb.orm"); // Vendor adapter HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); entityManagerFactory.setJpaVendorAdapter(vendorAdapter); return entityManagerFactory; }
From source file:io.convergencia.training.Application.java
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource()); em.setJpaVendorAdapter(jpaVendorAdapter()); em.setPackagesToScan("io.convergencia.training.model"); return em;/*from w ww . j av a 2 s . c o m*/ }