當前位置: 首頁>>代碼示例>>Java>>正文


Java LocalContainerEntityManagerFactoryBean.setDataSource方法代碼示例

本文整理匯總了Java中org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.setDataSource方法的典型用法代碼示例。如果您正苦於以下問題:Java LocalContainerEntityManagerFactoryBean.setDataSource方法的具體用法?Java LocalContainerEntityManagerFactoryBean.setDataSource怎麽用?Java LocalContainerEntityManagerFactoryBean.setDataSource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean的用法示例。


在下文中一共展示了LocalContainerEntityManagerFactoryBean.setDataSource方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: entityManagerFactory

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
@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;
}
 
開發者ID:sysuOTS,項目名稱:TicketServer,代碼行數:17,代碼來源:SpringBusinessConfig.java

示例2: entityManagerFactory

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
@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", true);
    jpaProperties.put("hibernate.show_sql", Boolean.parseBoolean(databaseShowSQL));
    lcemfb.setJpaProperties(jpaProperties);
    lcemfb.setPackagesToScan("cn.org.once.cstack.model");
    lcemfb.afterPropertiesSet();
    return lcemfb.getObject();
}
 
開發者ID:oncecloud,項目名稱:devops-cstack,代碼行數:19,代碼來源:DatabaseConfigurationTest.java

示例3: orderEntityManagerFactory

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
@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;
}
 
開發者ID:Just-Fun,項目名稱:spring-data-examples,代碼行數:15,代碼來源:OrderConfig.java

示例4: getLocalContainerEntityManagerFactoryBean

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
@Bean
public LocalContainerEntityManagerFactoryBean getLocalContainerEntityManagerFactoryBean() {
	LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean();
	bean.setJpaProperties(hibernateProperties());
	bean.setPackagesToScan(TestEntity.class.getPackage().getName());
	bean.setDataSource(testDataSource());
	bean.setPersistenceUnitName("TEST");
	return bean;
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:10,代碼來源:JpaTestConfig.java

示例5: entityManagerFactory

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
    emf.setDataSource(dataSource);
    emf.setPackagesToScan(Constants.BASE_PACKAGE);
    emf.setPersistenceProvider(new HibernatePersistenceProvider());
    emf.setJpaProperties(jpaProperties());
    return emf;
}
 
開發者ID:lordking,項目名稱:spring-rest-sample,代碼行數:10,代碼來源:JpaConfig.java

示例6: newHibernateEntityManagerFactoryBean

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:34,代碼來源:Beans.java

示例7: entityManagerFactory

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
@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;
}
 
開發者ID:hantsy,項目名稱:spring-reactive-sample,代碼行數:10,代碼來源:JpaConfig.java

示例8: entityManagerFactory

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
@Bean
public EntityManagerFactory entityManagerFactory(JpaVendorAdapter jpaVendorAdapter, DataSource dataSource) {
	LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
	factory.setJpaVendorAdapter(jpaVendorAdapter);
	factory.setPackagesToScan("hello.entities");
	factory.setDataSource(dataSource);
	factory.afterPropertiesSet();
	return factory.getObject();
}
 
開發者ID:Julien35,項目名稱:dev-courses,代碼行數:10,代碼來源:Config.java

示例9: getLocalContainerEntityManagerFactoryBean

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
@Bean
public LocalContainerEntityManagerFactoryBean getLocalContainerEntityManagerFactoryBean() {
	LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean();
	bean.setJpaProperties(hibernateProperties());
	bean.setPackagesToScan(MovieEntity.class.getPackage().getName());
	bean.setDataSource(testDataSource());
	bean.setPersistenceUnitName("TEST");
	return bean;
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:10,代碼來源:OperationsTestConfig.java

示例10: entityManagerFactory

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource());
em.setPackagesToScan("org.restaurant.repository.model");

JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
em.setJpaVendorAdapter(vendorAdapter);
em.setJpaProperties(additionalProperties());

return em;
}
 
開發者ID:juanjo8600,項目名稱:restaurant,代碼行數:13,代碼來源:RepositoryConfiguration.java

示例11: entityManagerFactory

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
@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");
	emf.getJpaPropertyMap().put("hibernate.jdbc.batch_size", 5);
	return emf;
}
 
開發者ID:holon-platform,項目名稱:holon-datastore-jpa,代碼行數:13,代碼來源:TestJpaDatastoreHibernate.java

示例12: entityManagerFactory

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
@Bean
@Primary
public FactoryBean<EntityManagerFactory> entityManagerFactory(DataSource dataSource) {
	LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
	emf.setDataSource(dataSource);
	HibernateJpaVendorAdapter va = new HibernateJpaVendorAdapter();
	va.setShowSql(true);
	emf.setJpaVendorAdapter(va);
	emf.setPackagesToScan(TestJpaDomain1.class.getPackage().getName());
	return emf;
}
 
開發者ID:holon-platform,項目名稱:holon-datastore-jpa,代碼行數:12,代碼來源:TestEnableDatastore.java

示例13: entityManagerFactory1

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
@Bean
@Primary
public FactoryBean<EntityManagerFactory> entityManagerFactory1(@Qualifier("one") DataSource dataSource) {
	LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
	emf.setDataSource(dataSource);
	HibernateJpaVendorAdapter va = new HibernateJpaVendorAdapter();
	va.setShowSql(true);
	emf.setJpaVendorAdapter(va);
	emf.setPackagesToScan(TestJpaDomain1.class.getPackage().getName());
	emf.setPersistenceUnitName("one");
	return emf;
}
 
開發者ID:holon-platform,項目名稱:holon-datastore-jpa,代碼行數:13,代碼來源:TestEnableDatastoreMulti.java

示例14: entityManagerFactoryBean

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
    Map<String, Object> properties = new HashMap<>();
    // properties.put("javax.persistence.schema-generation.database.action", "none"); // 沒有update選項,隻有:none、create、drop-and-create、drop,不滿足開發需求
    // properties.put("hibernate.hbm2ddl.auto", "update"); // 使用adapter.setGenerateDdl(true),避免拚寫錯誤;
    properties.put("hibernate.ejb.use_class_enhancer", "true");
    properties.put("hibernate.search.default.directory_provider", "filesystem");
    properties.put("hibernate.search.lucene_version", "5.3.1"); // 避免控製台警告,默認使用LUCENE_CURRENT
    properties.put("hibernate.search.default.indexBase", "../amanda/searchIndexes");

    // properties.put("hibernate.show_sql", "true");
    // properties.put("hibernate.format_sql", "true");
    properties.put("hibernate.use_sql_comments", "true");
    properties.put("hibernate.physical_naming_strategy", "com.timeyang.amanda.core.jpa.naming.PhysicalNamingStrategyImpl");

    LocalContainerEntityManagerFactoryBean factory =
            new LocalContainerEntityManagerFactoryBean();
    factory.setDataSource(this.dataSource);
    factory.setJpaVendorAdapter(jpaVendorAdapter());
    factory.setPackagesToScan(AmandaApplication.class.getPackage().getName());
    factory.setSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
    factory.setValidationMode(ValidationMode.NONE);
    factory.setLoadTimeWeaver(this.loadTimeWeaver()); // TODO: remove when SPR-10856 fixed
    factory.setJpaPropertyMap(properties);
    return factory;
}
 
開發者ID:chaokunyang,項目名稱:amanda,代碼行數:27,代碼來源:RootContextConfiguration.java

示例15: getEntityManagerFactoryBean

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
@Bean
public LocalContainerEntityManagerFactoryBean getEntityManagerFactoryBean() {
    final LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(getJpaVendorAdapter());
    factory.setPersistenceXmlLocation("classpath:META-INF/test-persistence.xml");
    factory.setDataSource(getDataSource());
    factory.setJpaProperties(getJpaProperties());
    return factory;
}
 
開發者ID:cerner,項目名稱:jwala,代碼行數:10,代碼來源:TestJpaConfiguration.java


注:本文中的org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.setDataSource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。