Java Code Examples for org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean#setBeanFactory()
The following examples show how to use
org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean#setBeanFactory() .
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: 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 2
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 3
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; }