Java Code Examples for org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean#afterPropertiesSet()
The following examples show how to use
org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean#afterPropertiesSet() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RepositorySpringConfiguration.java From personal_book_library_web_project with MIT License | 7 votes |
@Bean public EntityManagerFactory entityManagerFactory() throws SQLException { HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setGenerateDdl(true); vendorAdapter.setShowSql(true); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan("com.personal.book.library.datalayer.entity", "com.personal.book.library.datalayer.repository.jpa"); factory.setDataSource(dataSource()); factory.afterPropertiesSet(); factory.setJpaProperties(jpaProperties()); return factory.getObject(); }
Example 2
Source File: JpaTransactionManagerConfiguration.java From hypersistence-optimizer with Apache License 2.0 | 7 votes |
@Bean public EntityManagerFactory entityManagerFactory() { LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); entityManagerFactoryBean.setPersistenceUnitName(persistenceUnitName()); entityManagerFactoryBean.setPersistenceProvider(new HibernatePersistence()); entityManagerFactoryBean.setDataSource(dataSource()); entityManagerFactoryBean.setPackagesToScan(packagesToScan()); JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); entityManagerFactoryBean.setJpaVendorAdapter(vendorAdapter); entityManagerFactoryBean.setJpaProperties(additionalProperties()); entityManagerFactoryBean.afterPropertiesSet(); return HypersistenceHibernatePersistenceProvider.decorate( entityManagerFactoryBean.getNativeEntityManagerFactory() ); }
Example 3
Source File: JpaCoreConfig.java From bearchoke with Apache License 2.0 | 6 votes |
@Bean public EntityManagerFactory entityManagerFactory() { LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean(); lef.setDataSource(dataSource); lef.setJpaVendorAdapter(jpaVendorAdapter()); String[] packages = environment.getProperty("jpa.packages.to.scan").split(","); lef.setPackagesToScan(packages); Properties props = new Properties(); props.put("hibernate.show_sql", "true"); props.put("hibernate.format_sql", "true"); props.put("hibernate.ejb.naming_strategy", "org.hibernate.cfg.ImprovedNamingStrategy"); props.put("hibernate.connection.charSet", "UTF-8"); props.put("hibernate.current_session_context_class", "jta"); props.put("hibernate.archive.autodetection", "class"); props.put("hibernate.transaction.manager_lookup_class", "com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup"); props.put("hibernate.dialect", environment.getProperty("jpa.dialect")); props.put("hibernate.hbm2ddl.auto", environment.getProperty("jpa.hibernate.create.strategy")); lef.setJpaProperties(props); lef.afterPropertiesSet(); return lef.getObject(); }
Example 4
Source File: OrderConfig.java From tutorials with MIT License | 6 votes |
@Bean public EntityManagerFactory orderEntityManager() { HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan("com.baeldung.atomikos.spring.jpa.order"); factory.setDataSource(orderDataSource()); Properties jpaProperties = new Properties(); //jpaProperties.put("hibernate.show_sql", "true"); //jpaProperties.put("hibernate.format_sql", "true"); jpaProperties.put("hibernate.dialect", "org.hibernate.dialect.DerbyDialect"); jpaProperties.put("hibernate.current_session_context_class", "jta"); jpaProperties.put("javax.persistence.transactionType", "jta"); jpaProperties.put("hibernate.transaction.manager_lookup_class", "com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup"); jpaProperties.put("hibernate.hbm2ddl.auto", "create-drop"); factory.setJpaProperties(jpaProperties); factory.afterPropertiesSet(); return factory.getObject(); }
Example 5
Source File: JpaInfrastructureConfig.java From spring-content with Apache License 2.0 | 6 votes |
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setDatabase(Database.HSQL); vendorAdapter.setGenerateDdl(true); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan(packagesToScan()); factory.setPersistenceUnitName("spring-data-rest-webmvc"); factory.setDataSource(dataSource()); factory.afterPropertiesSet(); return factory; }
Example 6
Source File: InventoryConfig.java From tutorials with MIT License | 6 votes |
@Bean public EntityManagerFactory inventoryEntityManager() { HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan("com.baeldung.atomikos.spring.jpa.inventory"); factory.setDataSource(inventoryDataSource()); Properties jpaProperties = new Properties(); //jpaProperties.put("hibernate.show_sql", "true"); //jpaProperties.put("hibernate.format_sql", "true"); jpaProperties.put("hibernate.dialect", "org.hibernate.dialect.DerbyDialect"); jpaProperties.put("hibernate.current_session_context_class", "jta"); jpaProperties.put("javax.persistence.transactionType", "jta"); jpaProperties.put("hibernate.transaction.manager_lookup_class", "com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup"); jpaProperties.put("hibernate.hbm2ddl.auto", "create-drop"); factory.setJpaProperties(jpaProperties); factory.afterPropertiesSet(); return factory.getObject(); }
Example 7
Source File: DataSourceConfig.java From careconnect-reference-implementation with Apache License 2.0 | 6 votes |
@Bean public EntityManagerFactory entityManagerFactory() { // final Database database = Database.valueOf(vendor.toUpperCase()); final LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setPersistenceUnitName("CCRI_PERSISTENCE_UNIT"); // factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan("uk.nhs.careconnect.ri.database.entity"); factory.setDataSource(dataSource()); factory.setPersistenceProvider(new HibernatePersistenceProvider()); factory.setJpaProperties(jpaProperties()); factory.afterPropertiesSet(); return factory.getObject(); }
Example 8
Source File: EntityManagerFactoryServiceImpl.java From multitenant with Apache License 2.0 | 6 votes |
@Override public EntityManagerFactory createTempEntityManagerFactory( Organization organization) { SingleConnectionDataSource dataSource = dataSourceService.createSingleConnectionDataSource(organization); if (dataSource != null) { Map<String, Object> vendorProperties = getVendorProperties(dataSource); customizeVendorProperties(vendorProperties); Builder builder = getEntityManagerFactoryBuilder(dataSource).dataSource(dataSource).packages(mergePackagesToScan()) .properties(vendorProperties).jta(isJta()); LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = builder.build(); entityManagerFactoryBean.setBeanClassLoader(classLoader); entityManagerFactoryBean.setBeanFactory(beanFactory); entityManagerFactoryBean.setBeanName(beanName); entityManagerFactoryBean.setLoadTimeWeaver(loadTimeWeaver); entityManagerFactoryBean.setResourceLoader(resourceLoader); entityManagerFactoryBean.afterPropertiesSet(); return entityManagerFactoryBean.getObject(); } return null; }
Example 9
Source File: EntityManagerFactoryServiceImpl.java From multitenant with Apache License 2.0 | 6 votes |
@Override public void generateTables(Organization organization) { SingleConnectionDataSource dataSource = dataSourceService.createSingleConnectionDataSource(organization); if (dataSource != null) { Map<String, Object> vendorProperties = getVendorProperties(dataSource); customizeVendorProperties(vendorProperties); Builder builder = getEntityManagerFactoryBuilder(dataSource).dataSource(dataSource).packages(packagesToScan.split(",")) .properties(vendorProperties).jta(isJta()); LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = builder.build(); publishEvent(organization, builder); entityManagerFactoryBean.setBeanClassLoader(classLoader); entityManagerFactoryBean.setBeanFactory(beanFactory); entityManagerFactoryBean.setBeanName(beanName); entityManagerFactoryBean.setLoadTimeWeaver(loadTimeWeaver); entityManagerFactoryBean.setResourceLoader(resourceLoader); entityManagerFactoryBean.afterPropertiesSet(); entityManagerFactoryBean.destroy(); dataSource.destroy(); } }
Example 10
Source File: EntityManagerFactoryServiceImpl.java From multitenant with Apache License 2.0 | 6 votes |
@Override public EntityManagerFactory createEntityManagerFactory(Organization organization) { DataSource dataSource = dataSourceService.getOrCreateDataSource(organization); Map<String, Object> vendorProperties = getVendorProperties(dataSource); customizeVendorProperties(vendorProperties); LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = getEntityManagerFactoryBuilder(dataSource).dataSource(dataSource).packages(mergePackagesToScan()) .properties(vendorProperties).jta(isJta()).build(); entityManagerFactoryBean.setBeanClassLoader(classLoader); entityManagerFactoryBean.setBeanFactory(beanFactory); entityManagerFactoryBean.setBeanName(beanName); entityManagerFactoryBean.setLoadTimeWeaver(loadTimeWeaver); entityManagerFactoryBean.setResourceLoader(resourceLoader); entityManagerFactoryBean.setPersistenceUnitName(organization.getId()); entityManagerFactoryBean.afterPropertiesSet(); scriptService.runScripts(organization.getId(), dataSource, dataScript, "multitenant-data"); return entityManagerFactoryBean.getObject(); }
Example 11
Source File: DatabaseConfiguration.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Bean public EntityManagerFactory entityManagerFactory() { log.debug("Configuring EntityManager"); LocalContainerEntityManagerFactoryBean lcemfb = new LocalContainerEntityManagerFactoryBean(); lcemfb.setPersistenceProvider(new HibernatePersistence()); lcemfb.setPersistenceUnitName("persistenceUnit"); lcemfb.setDataSource(dataSource()); lcemfb.setJpaDialect(new HibernateJpaDialect()); lcemfb.setJpaVendorAdapter(jpaVendorAdapter()); Properties jpaProperties = new Properties(); jpaProperties.put("hibernate.cache.use_second_level_cache", false); jpaProperties.put("hibernate.generate_statistics", env.getProperty("hibernate.generate_statistics", Boolean.class, false)); lcemfb.setJpaProperties(jpaProperties); lcemfb.setPackagesToScan("com.activiti.domain"); lcemfb.afterPropertiesSet(); return lcemfb.getObject(); }
Example 12
Source File: DataConfiguration.java From Spring with Apache License 2.0 | 6 votes |
@Bean public EntityManagerFactory entityManagerFactory(){ final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setGenerateDdl(true); final Properties jpaProperties = new Properties(); jpaProperties.put("hibernate.hbm2ddl.auto", "create-drop"); jpaProperties.put("hibernate.dialect", "org.hibernate.dialect.HSQLDialect"); final LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setDataSource(dataSource()); factory.setPackagesToScan("com.oreilly.sdata"); factory.setJpaVendorAdapter(vendorAdapter); factory.setJpaProperties(jpaProperties); factory.afterPropertiesSet(); return factory.getObject(); }
Example 13
Source File: DatabaseConfiguration.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Bean(name = "entityManagerFactory") public EntityManagerFactory entityManagerFactory() { LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); entityManagerFactoryBean.setDataSource(dataSource()); entityManagerFactoryBean.setPackagesToScan("org.activiti.rest.api.jpa.model"); entityManagerFactoryBean.setPersistenceUnitName("test"); HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter(); hibernateJpaVendorAdapter.setShowSql(false); hibernateJpaVendorAdapter.setGenerateDdl(true); hibernateJpaVendorAdapter.setDatabase(Database.H2); entityManagerFactoryBean.setJpaVendorAdapter(hibernateJpaVendorAdapter); entityManagerFactoryBean.afterPropertiesSet(); return entityManagerFactoryBean.getObject(); }
Example 14
Source File: PersistenceConfig.java From Spring with Apache License 2.0 | 5 votes |
@Bean public EntityManagerFactory entityManagerFactory() { LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean(); factoryBean.setPersistenceUnitManager(persistenceUnitManager()); factoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); factoryBean.setJpaProperties(dataConfig.hibernateProperties()); factoryBean.afterPropertiesSet(); factoryBean.setLoadTimeWeaver(new InstrumentationLoadTimeWeaver()); return factoryBean.getNativeEntityManagerFactory(); }
Example 15
Source File: TenancyEclipseLinkSampleApplication.java From tenancy-sample with Apache License 2.0 | 5 votes |
@Bean public EntityManagerFactory entityManagerFactory(DataSource dataSource) { LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setDataSource(dataSource); factory.setJpaVendorAdapter(new EclipseLinkJpaVendorAdapter()); factory.setPackagesToScan(TenancyEclipseLinkSampleApplication.class.getPackage().getName()); factory.getJpaPropertyMap().put(PersistenceUnitProperties.DDL_GENERATION_MODE, PersistenceUnitProperties.DDL_DATABASE_GENERATION); factory.getJpaPropertyMap().put(PersistenceUnitProperties.LOGGING_LEVEL, "FINE"); factory.getJpaPropertyMap().put(PersistenceUnitProperties.WEAVING, "false"); factory.getJpaPropertyMap().put(TenantHolder.TENANT_ID, TenantHolder.getTenant()); factory.afterPropertiesSet(); return factory.getObject(); }
Example 16
Source File: TestDataConfig.java From Spring with Apache License 2.0 | 5 votes |
@Bean public EntityManagerFactory entityManagerFactory() { final LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean(); factoryBean.setPackagesToScan("com.ps.ents"); factoryBean.setDataSource(dataSource()); factoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); factoryBean.setJpaProperties(hibernateProperties()); factoryBean.afterPropertiesSet(); return factoryBean.getNativeEntityManagerFactory(); }
Example 17
Source File: HibernateConfig.java From logging-log4j-audit with Apache License 2.0 | 5 votes |
@Bean public EntityManagerFactory entityManagerFactory() { AbstractJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setGenerateDdl(false); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan("org.apache.logging.log4j.catalog"); factory.setDataSource(dataSourceConfig.dataSource()); factory.afterPropertiesSet(); return factory.getObject(); }
Example 18
Source File: Application.java From blog-examples with Apache License 2.0 | 5 votes |
@Bean public EntityManagerFactory entityManagerFactory() throws SQLException { HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setGenerateDdl(true); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan("com.mscharhag.springjooq.entity"); factory.setDataSource(dataSource()); factory.afterPropertiesSet(); return factory.getObject(); }
Example 19
Source File: TestDataConfig.java From Spring with Apache License 2.0 | 5 votes |
@Bean public EntityManagerFactory entityManagerFactory() { LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean(); factoryBean.setPackagesToScan("com.ps.ents"); factoryBean.setDataSource(dataSource()); factoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); factoryBean.setJpaProperties(hibernateProperties()); factoryBean.afterPropertiesSet(); return factoryBean.getNativeEntityManagerFactory(); }
Example 20
Source File: PersistenceConfig.java From Spring with Apache License 2.0 | 5 votes |
@Bean public EntityManagerFactory entityManagerFactory(){ final LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean(); factoryBean.setPersistenceUnitManager(persistenceUnitManager()); factoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); factoryBean.setJpaProperties(dataConfig.hibernateProperties()); factoryBean.afterPropertiesSet(); factoryBean.setLoadTimeWeaver(new InstrumentationLoadTimeWeaver()); return factoryBean.getNativeEntityManagerFactory(); }