当前位置: 首页>>代码示例>>Java>>正文


Java SharedCacheMode类代码示例

本文整理汇总了Java中javax.persistence.SharedCacheMode的典型用法代码示例。如果您正苦于以下问题:Java SharedCacheMode类的具体用法?Java SharedCacheMode怎么用?Java SharedCacheMode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SharedCacheMode类属于javax.persistence包,在下文中一共展示了SharedCacheMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: entityManagerFactory

import javax.persistence.SharedCacheMode; //导入依赖的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 javax.persistence.SharedCacheMode; //导入依赖的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: entityManagerFactoryBean

import javax.persistence.SharedCacheMode; //导入依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
	Map<String, Object> properties = new Hashtable<>();
	properties.put("javax.persistence.schema-generation.database.action", "none");
	properties.put("hibernate.connection.characterEncoding", "utf8");
	properties.put("hibernate.connection.useUnicode", "true");
	properties.put("hibernate.connection.charSet", "utf8");
	properties.put("hibernate.search.default.directory_provider", "filesystem");
	properties.put("hibernate.search.default.indexBase", context.getInitParameter("indexDir"));

	HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
	adapter.setDatabasePlatform("org.hibernate.dialect.MySQL5InnoDBDialect");

	LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
	factory.setJpaVendorAdapter(adapter);
	factory.setDataSource(this.bookManagerDataSource());
	factory.setPackagesToScan("net.viperfish.bookManager");
	factory.setSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
	factory.setValidationMode(ValidationMode.NONE);
	factory.setJpaPropertyMap(properties);
	return factory;
}
 
开发者ID:shilongdai,项目名称:bookManager,代码行数:23,代码来源:RootApplicationContextConfig.java

示例4: entityManagerFactory

import javax.persistence.SharedCacheMode; //导入依赖的package包/类
@Bean
@DependsOn(value = {"simpleApplicationContextHolder"})
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
    final LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
    factoryBean.setDataSource(dataSource);
    factoryBean.setSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
    factoryBean.setValidationMode(ValidationMode.CALLBACK);
    factoryBean.setJpaVendorAdapter(jpaVendorAdapter);
    factoryBean.setPackagesToScan("com.devicehive.model");

    final Properties props = new Properties();
    props.putAll(this.properties.getHibernateProperties(this.dataSource));
    if (useNativeClient) {
        props.put("hibernate.cache.hazelcast.native_client_group", groupName);
        props.put("hibernate.cache.hazelcast.native_client_password", groupPassword);
        if (!CollectionUtils.isEmpty(clusterMembers)) {
            props.put("hibernate.cache.hazelcast.native_client_address", clusterMembers.get(0));
        }
    }

    factoryBean.setJpaProperties(props);
    return factoryBean;
}
 
开发者ID:devicehive,项目名称:devicehive-java-server,代码行数:24,代码来源:RdbmsPersistenceConfig.java

示例5: endElement

import javax.persistence.SharedCacheMode; //导入依赖的package包/类
@Override
public void endElement(String uri, String localName, String name) throws SAXException {
    String s = builder.toString().trim();
    // This step is VERY important, otherwise we pollute subsequent
    // elements
    builder = new StringBuilder();

    if ("".equals(s))
        return;

    PersistenceUnit pu = persistenceUnits.peek();

    if ("provider".equals(elementName))
        pu.setProviderClassName(s);
    else if ("jta-data-source".equals(elementName))
        pu.setJtaDataSourceName(s);
    else if ("non-jta-data-source".equals(elementName))
        pu.setNonJtaDataSourceName(s);
    else if ("class".equals(elementName))
        pu.addClassName(s);
    else if("mapping-file".equals(elementName))
    	pu.addMappingFile(s);
    else if ("exclude-unlisted-classes".equals(elementName))
        pu.setExcludeUnlisted(Boolean.parseBoolean(s));
    else if ("shared-cache-mode".equals(elementName))
        pu.setSharedCacheMode(SharedCacheMode.valueOf(s));
    else if ("validation-mode".equals(elementName))
        pu.setValidationMode(ValidationMode.valueOf(s));
}
 
开发者ID:apache,项目名称:aries-jpa,代码行数:30,代码来源:JPAHandler.java

示例6: determineCacheSettings

import javax.persistence.SharedCacheMode; //导入依赖的package包/类
private static Cache determineCacheSettings(XClass clazzToProcess, Mappings mappings) {
	Cache cacheAnn = clazzToProcess.getAnnotation( Cache.class );
	if ( cacheAnn != null ) {
		return cacheAnn;
	}

	Cacheable cacheableAnn = clazzToProcess.getAnnotation( Cacheable.class );
	SharedCacheMode mode = determineSharedCacheMode( mappings );
	switch ( mode ) {
		case ALL: {
			cacheAnn = buildCacheMock( clazzToProcess.getName(), mappings );
			break;
		}
		case ENABLE_SELECTIVE: {
			if ( cacheableAnn != null && cacheableAnn.value() ) {
				cacheAnn = buildCacheMock( clazzToProcess.getName(), mappings );
			}
			break;
		}
		case DISABLE_SELECTIVE: {
			if ( cacheableAnn == null || cacheableAnn.value() ) {
				cacheAnn = buildCacheMock( clazzToProcess.getName(), mappings );
			}
			break;
		}
		default: {
			// treat both NONE and UNSPECIFIED the same
			break;
		}
	}
	return cacheAnn;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:33,代码来源:AnnotationBinder.java

示例7: entityManagerFactory

import javax.persistence.SharedCacheMode; //导入依赖的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

示例8: entityManagerFactoryBean

import javax.persistence.SharedCacheMode; //导入依赖的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

示例9: getSharedCacheMode

import javax.persistence.SharedCacheMode; //导入依赖的package包/类
@Override
public SharedCacheMode getSharedCacheMode() {
    // for develop
    return SharedCacheMode.NONE;
    // for production
    // return SharedCacheMode.ENABLE_SELECTIVE;
}
 
开发者ID:ShotaOd,项目名称:carbon,代码行数:8,代码来源:DefaultPersistenceUnitInfo.java

示例10: createPersistenceUnitInfo

import javax.persistence.SharedCacheMode; //导入依赖的package包/类
private PersistenceUnitInfo createPersistenceUnitInfo() {
    PersistenceUnitInfo persistenceUnitInfo = mock(PersistenceUnitInfo.class);
    when(persistenceUnitInfo.getPersistenceUnitRootUrl()).thenReturn(createPersistenceUnitRootUrl());
    when(persistenceUnitInfo.getPersistenceUnitName()).thenReturn("annotation-based-field-access");
    when(persistenceUnitInfo.getTransactionType())
        .thenReturn(PersistenceUnitTransactionType.RESOURCE_LOCAL);
    when(persistenceUnitInfo.getValidationMode()).thenReturn(ValidationMode.AUTO);
    when(persistenceUnitInfo.getSharedCacheMode()).thenReturn(SharedCacheMode.UNSPECIFIED);
    when(persistenceUnitInfo.getJtaDataSource()).thenReturn(null);
    when(persistenceUnitInfo.getNonJtaDataSource()).thenReturn(null);
    when(persistenceUnitInfo.getNewTempClassLoader()).thenReturn(null);
    when(persistenceUnitInfo.getMappingFileNames()).thenReturn(Collections.<String>emptyList());
    when(persistenceUnitInfo.getJarFileUrls()).thenReturn(Collections.<URL>emptyList());
    when(persistenceUnitInfo.getPersistenceProviderClassName())
        .thenReturn(SecurePersistenceProvider.class.getName());
    when(persistenceUnitInfo.getClassLoader())
        .thenReturn(Thread.currentThread().getContextClassLoader());
    when(persistenceUnitInfo.getManagedClassNames()).thenReturn(Arrays.asList(
        FieldAccessAnnotationTestBean.class.getName(),
        FieldAccessMapKey.class.getName(),
        FieldAccessMapValue.class.getName()
    ));
    when(persistenceUnitInfo.excludeUnlistedClasses()).thenReturn(true);
    Properties properties = new Properties();
    properties.put("org.jpasecurity.persistence.provider", "org.hibernate.ejb.HibernatePersistence");
    properties.put("org.jpasecurity.security.context",
                   "org.jpasecurity.security.authentication.TestSecurityContext");
    properties.put("org.jpasecurity.security.rules.provider",
                   "org.jpasecurity.security.rules.XmlAccessRulesProvider");
    properties.put("hibernate.hbm2ddl.auto", "create-drop");
    properties.put("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
    properties.put("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver");
    properties.put("hibernate.connection.url", "jdbc:hsqldb:mem:test");
    properties.put("hibernate.connection.username", "sa");
    properties.put("hibernate.connection.password", "");
    when(persistenceUnitInfo.getProperties()).thenReturn(properties);
    return persistenceUnitInfo;
}
 
开发者ID:ArneLimburg,项目名称:jpasecurity,代码行数:39,代码来源:SecurePersistenceProviderTest.java

示例11: entityManagerFactoryBean

import javax.persistence.SharedCacheMode; //导入依赖的package包/类
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean()
		throws ConfigurationException, IOException {
	Map<String, Object> properties = new Hashtable<>();
	String indexPath = this.configuration().getString(GlobalConfig.INDEX_PATH);
	if (indexPath == null) {
		indexPath = GlobalConfig.INDEX_PATH_DEFAULT;
	}
	properties.put("javax.persistence.schema-generation.database.action", "none");
	properties.put("hibernate.connection.characterEncoding", "utf8");
	properties.put("hibernate.connection.useUnicode", "true");
	properties.put("hibernate.connection.charSet", "utf8");
	properties.put("hibernate.search.default.directory_provider", "filesystem");
	properties.put("hibernate.search.default.indexBase", indexPath);

	HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
	adapter.setDatabasePlatform("org.hibernate.dialect.MySQL5InnoDBDialect");

	LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
	factory.setJpaVendorAdapter(adapter);
	factory.setDataSource(this.chatDataSource());
	factory.setPackagesToScan("net.viperfish.chatapplication");
	factory.setSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
	factory.setValidationMode(ValidationMode.NONE);
	factory.setJpaPropertyMap(properties);
	return factory;
}
 
开发者ID:shilongdai,项目名称:LSChatServer,代码行数:28,代码来源:ApplicationRootContext.java

示例12: getSharedCacheMode

import javax.persistence.SharedCacheMode; //导入依赖的package包/类
@Override
public SharedCacheMode getSharedCacheMode() {
    if (definition.cachingType.isEmpty()) {
        return SharedCacheMode.UNSPECIFIED;
    }
    return SharedCacheMode.valueOf(definition.cachingType);
}
 
开发者ID:arievanwi,项目名称:osgi.ee,代码行数:8,代码来源:PersistenceUnitInfoImpl.java

示例13: getSharedCacheMode

import javax.persistence.SharedCacheMode; //导入依赖的package包/类
@Override
public SharedCacheMode getSharedCacheMode() {
    PersistenceUnitCachingType sharedCacheMode = persistenceUnitXml.getSharedCacheMode();
    if (sharedCacheMode == null) {
        return null;
    }

    return SharedCacheMode.valueOf(sharedCacheMode.name());
}
 
开发者ID:wisdom-framework,项目名称:wisdom-jdbc,代码行数:10,代码来源:PersistenceUnitComponent.java

示例14: entityManagerFactory

import javax.persistence.SharedCacheMode; //导入依赖的package包/类
@Bean
public EntityManagerFactory entityManagerFactory() {
   LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean();
   emf.setDataSource(dataSource());
   emf.setPackagesToScan(new String[] {"pl.edu.icm.saos.persistence"});
   emf.setSharedCacheMode(SharedCacheMode.ENABLE_SELECTIVE);
   HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
   emf.setJpaVendorAdapter(vendorAdapter);
   emf.setJpaProperties(hibernateProperties());
   emf.afterPropertiesSet();
   emf.setJpaDialect(new DefaultIsolationLevelJpaDialect());
   return emf.getObject();
}
 
开发者ID:CeON,项目名称:saos,代码行数:14,代码来源:PersistenceConfiguration.java

示例15: getSharedCacheMode

import javax.persistence.SharedCacheMode; //导入依赖的package包/类
@Override
public SharedCacheMode getSharedCacheMode() {
	PersistenceUnitCachingType sharedCacheMode = persistenceUnitXml.getSharedCacheMode();
	if (sharedCacheMode == null)
		return null;

	return SharedCacheMode.valueOf(sharedCacheMode.name());
}
 
开发者ID:osgi,项目名称:bundles,代码行数:9,代码来源:PersistenceUnitInfoImpl.java


注:本文中的javax.persistence.SharedCacheMode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。