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


Java LocalContainerEntityManagerFactoryBean.setSharedCacheMode方法代碼示例

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


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

示例1: 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", false);
    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,代碼來源:DatabaseConfiguration.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: entityManagerFactory

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
/**
 * Create new EntityManagerFactory
 *
 * @param dataSource          the data source
 * @param hibernateProperties the hibernate properties
 * @return the entity manager factory
 */
@Bean
public EntityManagerFactory entityManagerFactory(final DataSource dataSource, final Properties hibernateProperties) {
    final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource);
    em.setPackagesToScan(entitymanagerPackagesToScan);
    em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    em.setJpaProperties(hibernateProperties);
    em.setPersistenceUnitName("nestedbird");
    em.setSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
    em.setPersistenceProviderClass(HibernatePersistenceProvider.class);
    em.afterPropertiesSet();

    return em.getObject();
}
 
開發者ID:mhaddon,項目名稱:Sound.je,代碼行數:22,代碼來源:DatabaseConfig.java

示例4: entityManagerFactory

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
/**
 * Creates the entity manager factory.
 *
 * @param dataSource the data source to use
 * @return entity manager factory
 */
@Bean
@Primary
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) {
  LocalContainerEntityManagerFactoryBean entityManagerFactoryBean =
      new LocalContainerEntityManagerFactoryBean();

  entityManagerFactoryBean.setDataSource(dataSource);

  JpaVendorAdapter jpaVendorAdapter = createJpaVendorAdapter();
  entityManagerFactoryBean.setJpaVendorAdapter(jpaVendorAdapter);

  Map<String, String> jpaPropertyMap = getJpaPropertyMap();
  entityManagerFactoryBean.setJpaPropertyMap(jpaPropertyMap);

  getMappingResources().ifPresent(entityManagerFactoryBean::setMappingResources);
  getPackagesToScan().ifPresent(entityManagerFactoryBean::setPackagesToScan);

  // https://hibernate.atlassian.net/browse/HHH-5303#comment-44439
  entityManagerFactoryBean.setSharedCacheMode(ENABLE_SELECTIVE);

  customizeEntityManagerFactoryBean(entityManagerFactoryBean);

  return entityManagerFactoryBean;
}
 
開發者ID:springuni,項目名稱:springuni-particles,代碼行數:31,代碼來源:AbstractJpaRepositoryConfiguration.java

示例5: 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

示例6: configure

import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; //導入方法依賴的package包/類
/**
 * Configure given bean using provided configuration settings
 * @param emf Bean to configure
 */
public void configure(LocalContainerEntityManagerFactoryBean emf) {

	if (dataContextId != null) {
		emf.setPersistenceUnitName(dataContextId);
	}

	if (!entityPackages.isEmpty()) {
		emf.setPackagesToScan(entityPackages.toArray(new String[0]));
	}

	if (validationMode != null) {
		emf.setValidationMode(validationMode);
	}

	if (sharedCacheMode != null) {
		emf.setSharedCacheMode(sharedCacheMode);
	}

	if (jpaProperties != null) {
		emf.setJpaProperties(jpaProperties);
	}

	// ORM adapter
	ORMPlatform orm = ormPlatform;
	if (orm == null) {
		// try to detect
		try {
			orm = ORMPlatform.detectFromClasspath();
		} catch (IllegalStateException e) {
			logger.warn("Ensure to declare ORM platfrom through property or persistence.xml", e);
		}
	}

	if (orm != null) {

		JpaVendorAdapter adapter = buildJpaVendorAdapter(orm);

		if (adapter != null) {
			emf.setJpaVendorAdapter(adapter);
		} else {
			logger.warn("Failed to detect JpaVendorAdapter to use. "
					+ "Delegating adapter setup to LocalContainerEntityManagerFactoryBean");
		}

	} else {
		logger.warn("Failed to detect ORM platform to use. "
				+ "Delegating JpaVendorAdapter setup to LocalContainerEntityManagerFactoryBean");
	}
}
 
開發者ID:holon-platform,項目名稱:holon-datastore-jpa,代碼行數:54,代碼來源:EntityManagerFactoryConfigurator.java


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