List of usage examples for org.springframework.orm.jpa LocalContainerEntityManagerFactoryBean setPersistenceUnitName
@Override public void setPersistenceUnitName(@Nullable String persistenceUnitName)
From source file:fr.univlorraine.mondossierweb.config.JpaConfigApogee.java
/** * EntityManager Factory/*from www. j av a 2s .com*/ * @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:org.duracloud.mill.credentials.impl.CredentialsRepoConfig.java
@Bean(name = ENTITY_MANAGER_FACTORY_BEAN) public LocalContainerEntityManagerFactoryBean credentialsRepoEntityManagerFactory( @Qualifier(CREDENTIALS_REPO_DATA_SOURCE_BEAN) DataSource dataSource) { LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean(); emf.setDataSource(dataSource);//from w ww. j a v a 2 s . c o m emf.setPersistenceUnitName("credentials-repo-pu"); emf.setPackagesToScan("org.duracloud.account.db.model"); HibernateJpaVendorAdapter va = new HibernateJpaVendorAdapter(); va.setDatabase(Database.MYSQL); emf.setJpaVendorAdapter(va); Properties props = new Properties(); props.setProperty("hibernate.hbm2ddl.auto", "validate"); props.setProperty("hibernate.dialect", MySQL5Dialect.class.getName()); props.setProperty("hibernate.ejb.naming_strategy", ImprovedNamingStrategy.class.getName()); props.setProperty("hibernate.cache.provider_class", "org.hibernate.cache.HashtableCacheProvider"); props.setProperty("jadira.usertype.autoRegisterUserTypes", "true"); props.setProperty("jadira.usertype.databaseZone", "jvm"); props.setProperty("hibernate.show_sql", "false"); props.setProperty("hibernate.format_sql", "false"); props.setProperty("hibernate.show_comments", "false"); emf.setJpaProperties(props); return emf; }
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;// w w w . ja v a 2s . c o m }
From source file:gov.nih.nci.cacis.xds.authz.config.JpaConfig.java
/** * Entity manager factory./*from w w w . j a va 2s. com*/ * * @return the entity manager factory */ @Bean(name = "entityManagerFactory") public EntityManagerFactory entityManagerFactory() { final LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); entityManagerFactoryBean.setPersistenceUnitName(PERSISTENCE_UNIT_NAME); entityManagerFactoryBean.setDataSource(dataSource()); entityManagerFactoryBean.setJpaVendorAdapter(jpaVendorAdapter()); entityManagerFactoryBean.setPersistenceXmlLocation("classpath*:META-INF/xds-beans-persistence.xml"); // must set the properties entityManagerFactoryBean.afterPropertiesSet(); return entityManagerFactoryBean.getObject(); }
From source file:gov.nih.nci.integration.dao.JpaConfig.java
/** * Entity manager factory./* w w w .java 2s.c o m*/ * * @return the entity manager factory */ @Bean(name = "entityManagerFactory") public EntityManagerFactory entityManagerFactory() { final LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); entityManagerFactoryBean.setPersistenceUnitName(PERSISTENCE_UNIT_NAME); entityManagerFactoryBean.setDataSource(dataSource()); entityManagerFactoryBean.setJpaVendorAdapter(jpaVendorAdapter()); entityManagerFactoryBean.setPersistenceXmlLocation("classpath*:META-INF/ihub-messages-persistence.xml"); // must set the properties entityManagerFactoryBean.afterPropertiesSet(); return entityManagerFactoryBean.getObject(); }
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 www . java2 s . c o m }
From source file:com.greendot.db.jpa.configuration.JpaDatabaseConfiguration.java
@Bean public LocalContainerEntityManagerFactoryBean hibernateBackedJpaEntityManagerFactory() { final LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean(); entityManagerFactory.setDataSource(dataSource()); entityManagerFactory.setPersistenceUnitName(environment.getProperty("db.persistenceUnitName")); entityManagerFactory.setPackagesToScan(environment.getProperty("db.entityPackageToScan")); final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); entityManagerFactory.setJpaVendorAdapter(vendorAdapter); entityManagerFactory.setJpaProperties(jpaHibernateProperties()); return entityManagerFactory; }
From source file:fr.univlorraine.mondossierweb.config.JpaConfig.java
/** * EntityManager Factory/*from w w w. j a v a 2 s . c om*/ * @return */ @Bean @DependsOn("flyway") public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); localContainerEntityManagerFactoryBean.setPersistenceUnitName(PERSISTENCE_UNIT_NAME); localContainerEntityManagerFactoryBean.setPackagesToScan(Favoris.class.getPackage().getName()); localContainerEntityManagerFactoryBean.setDataSource(dataSource()); 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.setJpaProperties(jpaProperties); EclipseLinkJpaVendorAdapter jpaVendorAdapter = new EclipseLinkJpaVendorAdapter(); jpaVendorAdapter.setGenerateDdl(false); jpaVendorAdapter.setShowSql(false); localContainerEntityManagerFactoryBean.setJpaVendorAdapter(jpaVendorAdapter); return localContainerEntityManagerFactoryBean; }
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/>/*from w w w .j a v a 2 s . com*/ * 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:ca.n4dev.dev.worktime.config.SpringHibernateJPAConfig.java
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setPersistenceXmlLocation("classpath*:META-INF/persistence.xml"); em.setPersistenceUnitName("hibernatePersistenceUnit"); em.setDataSource(dataSource());//from w w w . j a va 2 s . c o m HibernateJpaVendorAdapter vendor = new HibernateJpaVendorAdapter(); vendor.setShowSql(false); em.setJpaVendorAdapter(vendor); return em; }