org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder.Builder Java Examples
The following examples show how to use
org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder.Builder.
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 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 #2
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 #3
Source File: EntityManagerFactoryServiceImpl.java From multitenant with Apache License 2.0 | 5 votes |
private void publishEvent(Organization organization, Builder builder) { if (listeners != null) { for (EntityManagerFactoryCreateListener entityManagerFactoryCreateListener : listeners) { entityManagerFactoryCreateListener.onCreate(organization, builder); } } }
Example #4
Source File: OrmRepository.java From sample-boot-micro with MIT License | 5 votes |
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean(String name, final DataSource dataSource) { EntityManagerFactoryBuilder emfBuilder = new EntityManagerFactoryBuilder( vendorAdapter(), getProperties(), null); Builder builder = emfBuilder .dataSource(dataSource) .persistenceUnit(name) .properties(hibernate.determineHibernateProperties(getProperties(), new HibernateSettings())) .jta(false); if (ArrayUtils.isNotEmpty(annotatedClasses)) { builder.packages(annotatedClasses); } else { builder.packages(packageToScan); } return builder.build(); }
Example #5
Source File: OrmRepository.java From sample-boot-hibernate with MIT License | 5 votes |
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean(String name, final DataSource dataSource) { EntityManagerFactoryBuilder emfBuilder = new EntityManagerFactoryBuilder( vendorAdapter(), getProperties(), null); Builder builder = emfBuilder .dataSource(dataSource) .persistenceUnit(name) .properties(hibernate.determineHibernateProperties(getProperties(), new HibernateSettings())) .jta(false); if (ArrayUtils.isNotEmpty(annotatedClasses)) { builder.packages(annotatedClasses); } else { builder.packages(packageToScan); } return builder.build(); }
Example #6
Source File: EntityTestSupport.java From ddd-java with MIT License | 5 votes |
protected void setupEntityManagerFactory() { DataSource ds = EntityTestFactory.dataSource(); Map<String, String> props = new HashMap<>(); props.put(AvailableSettings.HBM2DDL_AUTO, "create-drop"); Builder builder = new EntityManagerFactoryBuilder(new HibernateJpaVendorAdapter(), props, null) .dataSource(ds) .jta(false); if (!targetEntities.isEmpty()) { builder.packages(targetEntities.toArray(new Class<?>[0])); } LocalContainerEntityManagerFactoryBean emfBean = builder.build(); emfBean.afterPropertiesSet(); emf = emfBean.getObject(); txm = new JpaTransactionManager(emf); }
Example #7
Source File: EntityManagerFactoryCreateListener.java From multitenant with Apache License 2.0 | votes |
void onCreate(Organization organization, Builder builder);