@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder entityBuilder) { // .persistenceUnit("default").build(); Map<String, String> jpaProperties = new HashMap<>(); jpaProperties.put("hibernate.hbm2ddl.auto", ""); jpaProperties.put("hibernate.ejb.naming_strategy", "org.springframework.boot.orm.jpa.hibernate.SpringNamingStrategy"); Builder builder = entityBuilder.dataSource(dataSource); builder.jta(false); builder = builder.packages("com.aestheticsw.jobkeywords.service.termextractor.domain"); builder.persistenceUnit("jobkeywords"); builder = builder.properties(jpaProperties); LocalContainerEntityManagerFactoryBean factoryBean = builder.build(); return factoryBean; }
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder entityBuilder) { Map<String, String> jpaProperties = new HashMap<>(); // this insures that the DB will always be recreated jpaProperties.put("hibernate.hbm2ddl.auto", "create-drop"); jpaProperties.put("hibernate.ejb.naming_strategy", "org.springframework.boot.orm.jpa.hibernate.SpringNamingStrategy"); Builder builder = entityBuilder.dataSource(hbm2ddlDataSource); builder.jta(false); builder = builder.packages("com.aestheticsw.jobkeywords.service.termextractor.domain"); builder.persistenceUnit("hbm2ddl"); builder = builder.properties(jpaProperties); LocalContainerEntityManagerFactoryBean factoryBean = builder.build(); return factoryBean; }
@Bean public LocalContainerEntityManagerFactoryBean metaEntityManager(EntityManagerFactoryBuilder builder, @Qualifier("metaDataSource") DataSource dataSource) { Map<String, Object> props = new HashMap<>(); props.putAll(jpaProps.getSubProperties("properties.")); // props.put("hibernate.hbm2ddl.auto", "create"); LocalContainerEntityManagerFactoryBean factory = builder.dataSource(dataSource) .jta(true) .persistenceUnit("metaPU") .packages("de.weichert.multitenancy") .properties(props) .build(); factory.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); factory.setJpaDialect(new HibernateJpaDialect()); return factory; }
@Bean public EntityManagerFactoryBuilder entityManagerFactoryBuilder() { EntityManagerFactoryBuilder builder = new EntityManagerFactoryBuilder(jpaVendorAdapter(), jpaProperties(), null); return builder; }