public static EntityManagerFactory newEntityManagerFactory(DataSource dataSource, Class<?> ... entityPackages){ HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setGenerateDdl(true); BasicDataSource basicDataSource = (BasicDataSource)dataSource; Database jpaDatabase = DatabaseType.findTypeByJdbcUrl(basicDataSource.getUrl()).getJpaDatabase(); vendorAdapter.setDatabase(jpaDatabase); HashMap<String, Object> properties = new HashMap<String, Object>(); //properties.put("hibernate.dialect", "org.hibernate.dialect.MySQL5InnoDBDialect"); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); //import @Entity classes factory.setPackagesToScan(Arrays.stream(entityPackages).map(thing -> thing.getPackage().getName()).toArray(String[]::new)); //factory.setPersistenceUnitName("jproject"); factory.setDataSource(dataSource); factory.setJpaPropertyMap(properties); factory.afterPropertiesSet(); return factory.getObject(); }
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory( DataSource dataSource, MultiTenantConnectionProvider multiTenantConnectionProviderImpl, CurrentTenantIdentifierResolver currentTenantIdentifierResolverImpl) { Map<String, Object> properties = new HashMap<>(); properties.putAll(jpaProperties.getHibernateProperties(dataSource)); properties.put(org.hibernate.cfg.Environment.MULTI_TENANT, MultiTenancyStrategy.SCHEMA); properties .put(org.hibernate.cfg.Environment.MULTI_TENANT_CONNECTION_PROVIDER, multiTenantConnectionProviderImpl); properties .put(org.hibernate.cfg.Environment.MULTI_TENANT_IDENTIFIER_RESOLVER, currentTenantIdentifierResolverImpl); LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource); em.setPackagesToScan(JPA_PACKAGES); em.setJpaVendorAdapter(jpaVendorAdapter()); em.setJpaPropertyMap(properties); return em; }
/** * EntityManager configuration. */ @Bean(name = "entityManagerFactory") public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(getDatasource()); em.setJpaDialect(jpaDialect()); em.setPackagesToScan(entityManagerProperties.getPackagesToScan()); em.setPersistenceUnitName(eclipseLinkProperties.getPersistenceUnitName()); final DatabasePlatform dp = new MySQLPlatform(); em.setJpaVendorAdapter(getEclipseLinkJpaVendorAdapter()); //following code will be used for static weaving. Uncomment when creating war. final Map<String, String> propMap = new HashMap<String, String>(); propMap.put("eclipselink.weaving", eclipseLinkProperties.getWeaving()); em.setJpaPropertyMap(propMap); // em.setLoadTimeWeaver(loadTimeWeaver()); //comment this when using static weaving. Mostly in development environment inside eclipse return em; }
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { // JPA settings HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); // vendorAdapter.setGenerateDdl(true); // vendorAdapter.setShowSql(true); vendorAdapter.setDatabase(Database.MYSQL); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan("org.amv.access.model"); factory.setDataSource(dataSource); factory.setJpaProperties(jpaProperties()); factory.afterPropertiesSet(); return factory; }
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory( EntityManagerFactoryBuilder factoryBuilder) { Map<String, Object> vendorProperties = getVendorProperties(); customizeVendorProperties(vendorProperties); LocalContainerEntityManagerFactoryBean emfb = factoryBuilder.dataSource(getDataSource()) .packages(getPackagesToScan()) .persistenceUnit("default") .properties(vendorProperties) .jta(isJta()) .build(); emfb.setPersistenceUnitPostProcessors(new JPosPersistentUnitPostProcessor()); return emfb; }
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory( DataSource dataSource, MultiTenantConnectionProvider multiTenantConnectionProviderImpl, CurrentTenantIdentifierResolver currentTenantIdentifierResolverImpl, LocalValidatorFactoryBean localValidatorFactoryBean) { Map<String, Object> properties = new HashMap<>(); properties.putAll(jpaProperties.getHibernateProperties(dataSource)); properties.put(MULTI_TENANT, MultiTenancyStrategy.SCHEMA); properties.put(MULTI_TENANT_CONNECTION_PROVIDER, multiTenantConnectionProviderImpl); properties.put(MULTI_TENANT_IDENTIFIER_RESOLVER, currentTenantIdentifierResolverImpl); properties.put(JPA_VALIDATION_FACTORY, localValidatorFactoryBean); LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource); em.setPackagesToScan(JPA_PACKAGES); em.setJpaVendorAdapter(jpaVendorAdapter()); em.setJpaPropertyMap(properties); return em; }
@Bean public EntityManagerFactory entityManagerFactory() { logger.debug("Configuring EntityManager"); LocalContainerEntityManagerFactoryBean lcemfb = new LocalContainerEntityManagerFactoryBean(); lcemfb.setPersistenceProvider(new HibernatePersistenceProvider()); lcemfb.setPersistenceUnitName("persistenceUnit"); lcemfb.setDataSource(dataSource()); lcemfb.setJpaDialect(new HibernateJpaDialect()); lcemfb.setJpaVendorAdapter(jpaVendorAdapter()); lcemfb.setSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE); Properties jpaProperties = new Properties(); jpaProperties.put("hibernate.generate_statistics", false); jpaProperties.put("hibernate.show_sql", Boolean.parseBoolean(databaseShowSQL)); lcemfb.setJpaProperties(jpaProperties); lcemfb.setPackagesToScan("cn.org.once.cstack.model"); lcemfb.afterPropertiesSet(); return lcemfb.getObject(); }
@Bean public EntityManagerFactory entityManagerFactory() { LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean(); emf.setDataSource(dataSource()); emf.setPackagesToScan("io.github.azanx.shopping_list.domain"); emf.setPersistenceUnitName("spring-jpa-unit"); emf.setJpaVendorAdapter(getHibernateAdapter()); Properties jpaProperties = new Properties(); jpaProperties.put("hibernate.dialect", env.getProperty("hibernate.dialect")); jpaProperties.put("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); jpaProperties.put("hibernate.show_sql", env.getProperty("hibernate.show_sql")); jpaProperties.put("hibernate.format_sql", env.getProperty("hibernate.format_sql")); emf.setJpaProperties(jpaProperties); emf.afterPropertiesSet(); return emf.getObject(); }
@Bean public EntityManagerFactory entityManagerFactory(DataSource dataSource) { final Database database = Database.valueOf(vendor.toUpperCase()); /* final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setShowSql(showSql); vendorAdapter.setGenerateDdl(showDdl); vendorAdapter.setDatabase(database); */ final LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setPersistenceUnitName("CCRI_PU"); // factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan("uk.nhs.careconnect.ri.entity"); factory.setDataSource(dataSource); factory.setPersistenceProvider(new HibernatePersistenceProvider()); factory.setJpaProperties(jpaProperties()); factory.afterPropertiesSet(); return factory.getObject(); }
@Bean(EntityManagerFactoryBeanName) @Primary public LocalContainerEntityManagerFactoryBean entityManagerFactory( @Qualifier(DataSourceBeanName) DataSource dataSource, @Qualifier(JpaVendorAdapterBeanName) JpaVendorAdapter vendorAdapter) { LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); entityManagerFactoryBean.setDataSource(dataSource); entityManagerFactoryBean.setJpaVendorAdapter(vendorAdapter); entityManagerFactoryBean.setJpaDialect(new HibernateJpaDialect()); entityManagerFactoryBean.setPackagesToScan(Organization.class.getPackage().getName()); entityManagerFactoryBean.setPersistenceUnitName("mysqlsource1"); entityManagerFactoryBean.afterPropertiesSet(); return entityManagerFactoryBean; }
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource, MultiTenantConnectionProvider multiTenantConnectionProvider, CurrentTenantIdentifierResolver tenantIdentifierResolver) { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource); em.setPackagesToScan("com.mycompany.models"); em.setJpaVendorAdapter(this.jpaVendorAdapter()); final Map<String, Object> jpaProperties = new HashMap<>(); jpaProperties.put(Environment.MULTI_TENANT, MultiTenancyStrategy.SCHEMA); jpaProperties.put(Environment.MULTI_TENANT_CONNECTION_PROVIDER, multiTenantConnectionProvider); jpaProperties.put(Environment.MULTI_TENANT_IDENTIFIER_RESOLVER, tenantIdentifierResolver); jpaProperties.put(Environment.FORMAT_SQL, true); em.setJpaPropertyMap(jpaProperties); return em; }
@Bean public EntityManagerFactory entityManagerFactory() throws SQLException { HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); // vendorAdapter.setGenerateDdl(true); // Crea la tabella e le colonne quando non esistono vendorAdapter.setShowSql(config.getShowSql()); vendorAdapter.setDatabasePlatform("org.hibernate.dialect.MySQL5InnoDBDialect"); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); List<String> packages = config.getDbEntityPackages(); packages.add("net.yadaframework.persistence.entity"); packages.add("net.yadaframework.security.persistence.entity"); packages.add("net.yadaframework.cms.persistence.entity"); packages.add("net.yadaframework.commerce.persistence.entity"); log.info("Scanning packages for entities: {}", StringUtils.join(packages, ",")); factory.setPackagesToScan(packages.toArray(new String[]{})); factory.setDataSource(dataSource()); factory.afterPropertiesSet(); return factory.getObject(); }
@Bean public FactoryBean<EntityManagerFactory> entityManagerFactory() { LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean(); emf.setDataSource(dataSource()); emf.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); emf.setPackagesToScan(TestJpaDomain.class.getPackage().getName()); emf.setPersistenceUnitName("test"); return emf; }
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource()); em.setPackagesToScan("com.tickets.business.entities"); final Properties hibernateProperties = new Properties(); hibernateProperties.setProperty("hibernate.hbm2ddl.auto", "update"); hibernateProperties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect"); em.setJpaProperties(hibernateProperties); final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); em.setJpaVendorAdapter(vendorAdapter); return em; }
/** * Big Note: For spring based applications, the difference between different types of the entity manager factory bean is not so much. Spring will * always play the role, as container if you configure {@link LocalContainerEntityManagerFactoryBean} and as application if you configure * {@link org.springframework.orm.jpa.LocalEntityManagerFactoryBean} * * @param dataSource Factory for connections to the physical data source * @param environment Interface representing the environment in which the current application is running. * @return suitable entity manager factor bean bean for */ @Bean LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource, Environment environment) { Properties jpaProperties = new Properties(); jpaProperties.put("hibernate.dialect", environment.getRequiredProperty("hibernate.dialect")); jpaProperties.put("hibernate.hbm2ddl.auto", environment.getRequiredProperty("hibernate.hbm2ddl.auto")); jpaProperties.put("hibernate.ejb.naming_strategy", environment.getRequiredProperty("hibernate.ejb.naming_strategy")); jpaProperties.put("hibernate.show_sql", environment.getRequiredProperty("hibernate.show_sql")); jpaProperties.put("hibernate.format_sql", environment.getRequiredProperty("hibernate.format_sql")); LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); entityManagerFactoryBean.setDataSource(dataSource); entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); entityManagerFactoryBean.setPackagesToScan("com.logicify.d2g.models"); entityManagerFactoryBean.setJpaProperties(jpaProperties); return entityManagerFactoryBean; }
@Lazy @Bean public LocalContainerEntityManagerFactoryBean eventsEntityManagerFactory() { final LocalContainerEntityManagerFactoryBean bean = Beans.newHibernateEntityManagerFactoryBean( new JpaConfigDataHolder( jpaEventVendorAdapter(), "jpaEventRegistryContext", jpaEventPackagesToScan(), dataSourceEvent()), casProperties.getEvents().getJpa()); return bean; }
@Lazy @Bean public LocalContainerEntityManagerFactoryBean googleAuthenticatorEntityManagerFactory() { final LocalContainerEntityManagerFactoryBean bean = Beans.newHibernateEntityManagerFactoryBean( new JpaConfigDataHolder( jpaGoogleAuthenticatorVendorAdapter(), "jpaGoogleAuthenticatorContext", jpaPackagesToScanGoogleAuthenticator(), dataSourceGoogleAuthenticator()), casProperties.getAuthn().getMfa().getGauth().getJpa().getDatabase()); return bean; }
@Lazy @Bean public LocalContainerEntityManagerFactoryBean inspektrAuditEntityManagerFactory() { return Beans.newHibernateEntityManagerFactoryBean( new JpaConfigDataHolder( Beans.newHibernateJpaVendorAdapter(casProperties.getJdbc()), "jpaInspektrAuditContext", new String[]{"org.apereo.cas.audit.entity"}, inspektrAuditTrailDataSource()), casProperties.getAudit().getJdbc()); }
@Lazy @Bean public LocalContainerEntityManagerFactoryBean mfaTrustedAuthnEntityManagerFactory() { final LocalContainerEntityManagerFactoryBean bean = Beans.newHibernateEntityManagerFactoryBean( new JpaConfigDataHolder( jpaMfaTrustedAuthnVendorAdapter(), "jpaMfaTrustedAuthnContext", jpaMfaTrustedAuthnPackagesToScan(), dataSourceMfaTrustedAuthn()), casProperties.getAuthn().getMfa().getTrusted().getJpa()); return bean; }
@Lazy @Bean public LocalContainerEntityManagerFactoryBean serviceEntityManagerFactory() { return newHibernateEntityManagerFactoryBean( new JpaConfigDataHolder( jpaServiceVendorAdapter(), "jpaServiceRegistryContext", jpaServicePackagesToScan(), dataSourceService()), casProperties.getServiceRegistry().getJpa()); }
@Lazy @Bean public LocalContainerEntityManagerFactoryBean ticketEntityManagerFactory() { return Beans.newHibernateEntityManagerFactoryBean( new JpaConfigDataHolder( Beans.newHibernateJpaVendorAdapter(casProperties.getJdbc()), "jpaTicketRegistryContext", ticketPackagesToScan(), dataSourceTicket()), casProperties.getTicket().getRegistry().getJpa()); }
@Lazy @Bean public LocalContainerEntityManagerFactoryBean consentEntityManagerFactory() { final LocalContainerEntityManagerFactoryBean bean = Beans.newHibernateEntityManagerFactoryBean( new JpaConfigDataHolder( jpaConsentVendorAdapter(), "jpaConsentContext", jpaConsentPackagesToScan(), dataSourceConsent()), casProperties.getConsent().getJpa()); return bean; }
/** * New entity manager factory bean. * * @param config the config * @param jpaProperties the jpa properties * @return the local container entity manager factory bean */ public static LocalContainerEntityManagerFactoryBean newHibernateEntityManagerFactoryBean(final JpaConfigDataHolder config, final AbstractJpaProperties jpaProperties) { final LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean(); bean.setJpaVendorAdapter(config.getJpaVendorAdapter()); if (StringUtils.isNotBlank(config.getPersistenceUnitName())) { bean.setPersistenceUnitName(config.getPersistenceUnitName()); } bean.setPackagesToScan(config.getPackagesToScan()); bean.setDataSource(config.getDataSource()); final Properties properties = new Properties(); properties.put("hibernate.dialect", jpaProperties.getDialect()); properties.put("hibernate.hbm2ddl.auto", jpaProperties.getDdlAuto()); properties.put("hibernate.jdbc.batch_size", jpaProperties.getBatchSize()); if (StringUtils.isNotBlank(jpaProperties.getDefaultCatalog())) { properties.put("hibernate.default_catalog", jpaProperties.getDefaultCatalog()); } if (StringUtils.isNotBlank(jpaProperties.getDefaultSchema())) { properties.put("hibernate.default_schema", jpaProperties.getDefaultSchema()); } bean.setJpaProperties(properties); bean.getJpaPropertyMap().put("hibernate.enable_lazy_load_no_trans", Boolean.TRUE); return bean; }
@Primary @Bean(name = "oneEntityManagerFactory") public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder) { DataSource dataSource = dataSource(); return builder.dataSource(dataSource).packages("com.easynetcn.cloud.one.web.data.entity") .persistenceUnit("onePersistenceUnit").build(); }
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) { LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean(); emf.setDataSource(dataSource); emf.setPackagesToScan(Post.class.getPackage().getName()); emf.setPersistenceProvider(new HibernatePersistenceProvider()); emf.setJpaProperties(jpaProperties()); return emf; }
@Bean(name = "entityManagerFactoryUser") public LocalContainerEntityManagerFactoryBean entityManagerFactoryUser (EntityManagerFactoryBuilder builder) { return builder .dataSource(userDataSource) .properties(getVendorProperties(userDataSource)) .packages(new String[]{ "com.myspringboot.repository.user", "com.myspringboot.entity" }) //设置应用userDataSource的基础包名 .persistenceUnit("userPersistenceUnit") .build(); }
@Primary @Bean(name = "entityManagerFactoryBook") public LocalContainerEntityManagerFactoryBean entityManagerFactoryBook (EntityManagerFactoryBuilder builder) { return builder .dataSource(bookDataSource) .properties(getVendorProperties(bookDataSource)) .packages(new String[]{"com.myspringboot.repository.book", "com.myspringboot.entity"}) //设置应用bookDataSource的基础包名 .persistenceUnit("bookPersistenceUnit") .build(); }
@Bean LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource, Environment env) { LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); entityManagerFactoryBean.setDataSource(dataSource); entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); entityManagerFactoryBean.setPackagesToScan("com.luke"); Properties jpaProperties = new Properties(); jpaProperties.put("hibernate.dialect", env.getRequiredProperty("hibernate.dialect")); jpaProperties.put("hibernate.hbm2ddl.auto", env.getRequiredProperty("hibernate.hbm2ddl.auto") ); jpaProperties.put("hibernate.show_sql", env.getRequiredProperty("hibernate.show_sql") ); jpaProperties.put("hibernate.format_sql", env.getRequiredProperty("hibernate.format_sql") ); entityManagerFactoryBean.setJpaProperties(jpaProperties); return entityManagerFactoryBean; }
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean retVal = new LocalContainerEntityManagerFactoryBean(); //retVal.setPersistenceUnitManager(persistenceUnitManager()); retVal.setMappingResources(orm); retVal.setPackagesToScan("org.partners.usciitg_prep.terminology.jpa"); retVal.setPersistenceUnitName(persistenceUnitName); retVal.setDataSource(dataSource()); retVal.setPersistenceProvider(new HibernatePersistenceProvider()); retVal.setJpaProperties(jpaProperties()); return retVal; }
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean retVal = new LocalContainerEntityManagerFactoryBean(); //retVal.setPersistenceUnitManager(persistenceUnitManager()); retVal.setPackagesToScan(new String[]{"org.partners.usciitg_prep.terminology.jpa","org.partners.usciitg_prep.fhir.model"}); retVal.setMappingResources(orm); retVal.setPersistenceUnitName(defaultPersistenceUnitName); retVal.setDataSource(dataSource()); retVal.setPersistenceProvider(new HibernatePersistenceProvider()); retVal.setJpaProperties(jpaProperties()); return retVal; }
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean retVal = new LocalContainerEntityManagerFactoryBean(); //retVal.setPersistenceUnitManager(persistenceUnitManager()); retVal.setPackagesToScan("org.partners.usciitg_prep.terminology.jpa","org.partners.usciitg_prep.fhir"); retVal.setMappingResources(orm); retVal.setPersistenceUnitName(defaultPersistenceUnitName); retVal.setDataSource(dataSource()); retVal.setPersistenceProvider(new HibernatePersistenceProvider()); retVal.setJpaProperties(jpaProperties()); return retVal; }
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean(); factoryBean.setDataSource(dataSource()); factoryBean.setPackagesToScan("com"); factoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); factoryBean.setJpaProperties(getJpaProperties()); return factoryBean; }
@Bean public EntityManagerFactory entityManagerFactory(DataSource dataSource, Properties dbProperties) throws SQLException { HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setGenerateDdl(true); LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); factory.setJpaVendorAdapter(vendorAdapter); String dialect = dbProperties.getProperty("hibernateDialect"); factory.getJpaPropertyMap().put("hibernate.dialect", dialect); factory.setPackagesToScan("hei2017.entity"); factory.setDataSource(dataSource); factory.afterPropertiesSet(); return factory.getObject(); }
@Bean public FactoryBean<EntityManagerFactory> entityManagerFactory() { LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean(); emf.setDataSource(dataSource()); HibernateJpaVendorAdapter va = new HibernateJpaVendorAdapter(); va.setShowSql(true); emf.setJpaVendorAdapter(va); emf.setPackagesToScan(TestJpaDomain.class.getPackage().getName()); emf.setPersistenceUnitName("test"); return emf; }
@Bean public FactoryBean<EntityManagerFactory> entityManagerFactory() { LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean(); emf.setDataSource(dataSource()); emf.setJpaVendorAdapter(new EclipseLinkJpaVendorAdapter()); emf.setPackagesToScan(TestJpaDomain.class.getPackage().getName()); emf.setPersistenceUnitName("test"); emf.getJpaPropertyMap().put("eclipselink.weaving", "false"); return emf; }
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory() { HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter(); adapter.setDatabase(Database.HSQL); adapter.setGenerateDdl(true); LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean(); factoryBean.setDataSource(dataSource()); factoryBean.setJpaVendorAdapter(adapter); factoryBean.setPackagesToScan(JpaEventPublicationConfiguration.class.getPackage().getName()); return factoryBean; }
@Bean public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource, JpaVendorAdapter jpaVendorAdapter) { LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean(); lef.setDataSource(dataSource); lef.setJpaVendorAdapter(jpaVendorAdapter); lef.setPackagesToScan("de.adesso.jenkinshue.entity"); lef.setJpaProperties(dataSourceConfig.getJpaProperties()); lef.afterPropertiesSet(); return lef; }
@Bean LocalContainerEntityManagerFactoryBean customerEntityManagerFactory() { HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter(); jpaVendorAdapter.setGenerateDdl(true); LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean(); factoryBean.setDataSource(customerDataSource()); factoryBean.setJpaVendorAdapter(jpaVendorAdapter); factoryBean.setPackagesToScan(CustomerConfig.class.getPackage().getName()); return factoryBean; }
@Bean LocalContainerEntityManagerFactoryBean orderEntityManagerFactory() { HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setGenerateDdl(true); LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean(); factoryBean.setDataSource(orderDataSource()); factoryBean.setJpaVendorAdapter(vendorAdapter); factoryBean.setPackagesToScan(OrderConfig.class.getPackage().getName()); return factoryBean; }