List of usage examples for org.springframework.orm.jpa LocalContainerEntityManagerFactoryBean LocalContainerEntityManagerFactoryBean
LocalContainerEntityManagerFactoryBean
From source file:fr.univlorraine.mondossierweb.config.JpaConfigApogee.java
/** * EntityManager Factory/*from ww w . j av a2 s. c o m*/ * @return */ @Bean public LocalContainerEntityManagerFactoryBean entityManagerFactoryApogee() { LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); localContainerEntityManagerFactoryBean.setPersistenceUnitName(PERSISTENCE_UNIT_NAME); localContainerEntityManagerFactoryBean.setPackagesToScan(VObjSeApogee.class.getPackage().getName()); localContainerEntityManagerFactoryBean.setDataSource(dataSourceApogee()); localContainerEntityManagerFactoryBean.setJpaDialect(new EclipseLinkJpaDialect()); Properties jpaProperties = new Properties(); /* Active le static weaving d'EclipseLink */ jpaProperties.put(PersistenceUnitProperties.WEAVING, "static"); /* Dsactive le cache partag */ jpaProperties.put(PersistenceUnitProperties.CACHE_SHARED_DEFAULT, String.valueOf(false)); localContainerEntityManagerFactoryBean.setSharedCacheMode(SharedCacheMode.NONE); localContainerEntityManagerFactoryBean.setJpaProperties(jpaProperties); EclipseLinkJpaVendorAdapter jpaVendorAdapter = new EclipseLinkJpaVendorAdapter(); jpaVendorAdapter.setGenerateDdl(false); jpaVendorAdapter.setShowSql(false); localContainerEntityManagerFactoryBean.setJpaVendorAdapter(jpaVendorAdapter); return localContainerEntityManagerFactoryBean; }
From source file:todos.EmbeddedDataSourceConfig.java
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean(); lef.setDataSource(dataSource());//from www. ja v a2 s. c om lef.setJpaPropertyMap(this.jpaProperties()); lef.setJpaVendorAdapter(this.jpaVendorAdapter()); lef.setPackagesToScan("hello"); return lef; }
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);//from w w w . j a va 2 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:com.xpeppers.phonedirectory.config.DatastoreConfig.java
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setDatabase(Database.POSTGRESQL); vendorAdapter.setGenerateDdl(false); vendorAdapter.setShowSql(true);//from w ww. j a va2 s . co m LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean(); factoryBean.setJpaVendorAdapter(vendorAdapter); factoryBean.setPackagesToScan(DOMAIN_PACKAGE); factoryBean.setDataSource(dataSource); return factoryBean; }
From source file:org.csc.phynixx.spring.integration.config.NonJtaPersistenceConfig.java
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws Exception { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(this.dataSource()); em.setPersistenceUnitName("test"); em.setPersistenceXmlLocation("classpath:META-INF/nonjta-persistence.xml"); final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setDatabasePlatform(this.hibernateDialect()); vendorAdapter.setShowSql(this.hibernateShowSql()); em.setJpaVendorAdapter(vendorAdapter); em.setJpaProperties(this.jpaProperties()); return em;//from w w w . j a v a 2 s .c o m }
From source file:de.bstreit.java.oscr.SpringConfigurationDoesComponentScan.java
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource, JpaVendorAdapter jpaVendorAdapter) { final LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean(); lef.setDataSource(dataSource);//from w ww.j av a2 s .c o m lef.setJpaVendorAdapter(jpaVendorAdapter); // Packages to scan for hibernate entities final String thisPackageAndSubpackages = this.getClass().getPackage().getName(); lef.setPackagesToScan(thisPackageAndSubpackages); return lef; }
From source file:com.github.fharms.camel.entitymanager.config.PersistenceJPAConfig.java
@Bean(name = "emf2") public LocalContainerEntityManagerFactoryBean entityManagerFactory2() { LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setPackagesToScan("com.github.fharms"); JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); em.setJpaVendorAdapter(vendorAdapter); em.setJpaProperties(additionalProperties()); return em;/*w ww . jav a 2 s .c om*/ }
From source file:org.csc.phynixx.spring.integration.config.EntityManagerConfig.java
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws Exception { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); // em.setJtaDataSource(this.dataSource()); em.setPersistenceUnitName("test"); em.setPersistenceXmlLocation("classpath:META-INF/bitronix-persistence.xml"); em.setPackagesToScan(ItemData.class.getPackage().toString()); final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setDatabasePlatform(this.hibernateDialect()); vendorAdapter.setShowSql(this.hibernateShowSql()); em.setJpaVendorAdapter(vendorAdapter); em.setJpaProperties(this.jpaProperties()); return em;//from w ww . j a v a 2 s.c o m }
From source file:br.com.joaops.awc.configuration.PersistenceConfig.java
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource());/*ww w . j av a 2 s .c o m*/ em.setPackagesToScan(this.getPackagesToScan()); JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); em.setJpaVendorAdapter(vendorAdapter); em.setJpaProperties(getAdditionalProperties()); return em; }
From source file:se.kth.csc.config.JpaConfig.java
/** * Creates a new entity manager factory bean using the provided settings. * * @param dataSource The JDBC data source to use. * @param hbm2ddlAuto The Hibernate setting controlling how database schemas should be automatically migrated. * @param dialect The SQL dialect that Hibernate should use. *//*w w w .ja v a2 s . co m*/ @Autowired @Bean public LocalContainerEntityManagerFactoryBean configureEntityManagerFactory(DataSource dataSource, @Value("${hibernate.hbm2ddl.auto}") String hbm2ddlAuto, @Value("${hibernate.dialect}") String dialect) { LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); entityManagerFactoryBean.setDataSource(dataSource); entityManagerFactoryBean.setPackagesToScan(Application.class.getPackage().getName()); entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); Properties jpaProperties = new Properties(); jpaProperties.put(Environment.DIALECT, dialect); jpaProperties.put(Environment.HBM2DDL_AUTO, hbm2ddlAuto); entityManagerFactoryBean.setJpaProperties(jpaProperties); log.info( "Creating entity manager factory bean with automatic \"{}\" schema management and the {} SQL dialect", hbm2ddlAuto, dialect); return entityManagerFactoryBean; }