javax.persistence.SharedCacheMode Java Examples

The following examples show how to use javax.persistence.SharedCacheMode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RdbmsPersistenceConfig.java    From devicehive-java-server with Apache License 2.0 7 votes vote down vote up
@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;
}
 
Example #2
Source File: HibernateL2CacheSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param igniteInstanceName Node name.
 * @param dfltAccessType Default cache access type.
 * @return Properties map.
 */
static Map<String, String> hibernateProperties(String igniteInstanceName, String dfltAccessType) {
    Map<String, String> map = new HashMap<>();

    map.put(HBM2DDL_AUTO, "create");
    map.put(JPA_SHARED_CACHE_MODE, SharedCacheMode.ALL.name());
    map.put(GENERATE_STATISTICS, "true");
    map.put(USE_SECOND_LEVEL_CACHE, "true");
    map.put(USE_QUERY_CACHE, "true");
    map.put(CACHE_REGION_FACTORY, HibernateRegionFactory.class.getName());
    map.put(RELEASE_CONNECTIONS, "on_close");
    map.put(IGNITE_INSTANCE_NAME_PROPERTY, igniteInstanceName);
    map.put(DFLT_ACCESS_TYPE_PROPERTY, dfltAccessType);

    return map;
}
 
Example #3
Source File: ReloadableEntityManagerFactory.java    From tomee with Apache License 2.0 5 votes vote down vote up
@ManagedOperation
@Description("change the shared cache mode if possible (value is ok)")
public void setSharedCacheMode(final String value) {
    try {
        final String v = value.trim().toUpperCase();
        final SharedCacheMode mode = v.isEmpty() ? SharedCacheMode.UNSPECIFIED : SharedCacheMode.valueOf(v);
        reloadableEntityManagerFactory.setSharedCacheMode(mode);
    } catch (final Exception iae) {
        // ignored
    }
}
 
Example #4
Source File: ReloadableEntityManagerFactory.java    From tomee with Apache License 2.0 5 votes vote down vote up
public synchronized void setSharedCacheMode(final SharedCacheMode mode) {
    final PersistenceUnitInfoImpl info = entityManagerFactoryCallable.getUnitInfo();
    info.setSharedCacheMode(mode);

    final Properties properties = entityManagerFactoryCallable.getUnitInfo().getProperties();
    if (properties.containsKey(JAVAX_PERSISTENCE_SHARED_CACHE_MODE)) {
        properties.setProperty(JAVAX_PERSISTENCE_SHARED_CACHE_MODE, mode.name());
    }
}
 
Example #5
Source File: PersistenceUnitInfoImpl.java    From hibernate-master-class with Apache License 2.0 4 votes vote down vote up
@Override
public SharedCacheMode getSharedCacheMode() {
    return SharedCacheMode.UNSPECIFIED;
}
 
Example #6
Source File: PersistenceUnit.java    From tomee with Apache License 2.0 4 votes vote down vote up
public SharedCacheMode getSharedCacheMode() {
    return (sharedCacheMode == null) ? SharedCacheMode.UNSPECIFIED : sharedCacheMode;
}
 
Example #7
Source File: DelegatingPuInfo.java    From eclipselink-maven-plugin with Apache License 2.0 4 votes vote down vote up
public SharedCacheMode getSharedCacheMode()
{
    return delegate.getSharedCacheMode();
}
 
Example #8
Source File: HibernatePersistenceUnitInfo.java    From tutorials with MIT License 4 votes vote down vote up
@Override
public SharedCacheMode getSharedCacheMode() {
    return SharedCacheMode.UNSPECIFIED;
}
 
Example #9
Source File: PersistenceUnitInfoImpl.java    From tutorials with MIT License 4 votes vote down vote up
@Override
public SharedCacheMode getSharedCacheMode() {
    return SharedCacheMode.UNSPECIFIED;
}
 
Example #10
Source File: PersistenceUnitInfoImpl.java    From tomee with Apache License 2.0 4 votes vote down vote up
/**
 * @param sharedCacheMode the sharedCacheMode to set
 */
public void setSharedCacheMode(final SharedCacheMode sharedCacheMode) {
    this.sharedCacheMode = (null != sharedCacheMode ? sharedCacheMode : SharedCacheMode.UNSPECIFIED);
}
 
Example #11
Source File: PersistenceUnitInfoImpl.java    From tomee with Apache License 2.0 4 votes vote down vote up
public SharedCacheMode getSharedCacheMode() {
    return this.sharedCacheMode;
}
 
Example #12
Source File: PersistenceUnit.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void setSharedCacheMode(final SharedCacheMode sharedCacheMode) {
    this.sharedCacheMode = sharedCacheMode;
}
 
Example #13
Source File: PersistenceUnitInfoBuilder.java    From openwebbeans-meecrowave with Apache License 2.0 4 votes vote down vote up
public PersistenceUnitInfoBuilder setSharedCacheMode(final SharedCacheMode sharedCacheMode) {
    this.sharedCacheMode = sharedCacheMode;
    return this;
}
 
Example #14
Source File: DynamicEntityUnitInfo.java    From we-cmdb with Apache License 2.0 4 votes vote down vote up
@Override
public SharedCacheMode getSharedCacheMode() {
    return SharedCacheMode.UNSPECIFIED;
}
 
Example #15
Source File: RapidoidPersistenceUnitInfo.java    From rapidoid with Apache License 2.0 4 votes vote down vote up
@Override
public SharedCacheMode getSharedCacheMode() {
	return null;
}
 
Example #16
Source File: PersistenceUnitInfoImpl.java    From high-performance-java-persistence with Apache License 2.0 4 votes vote down vote up
@Override
public SharedCacheMode getSharedCacheMode() {
    return SharedCacheMode.UNSPECIFIED;
}
 
Example #17
Source File: HammockPersistenceUnitInfo.java    From hammock with Apache License 2.0 4 votes vote down vote up
@Override
public SharedCacheMode getSharedCacheMode() {
   return SharedCacheMode.NONE;
}
 
Example #18
Source File: PersistenceUnitInfoBuilder.java    From openwebbeans-meecrowave with Apache License 2.0 4 votes vote down vote up
public PersistenceUnitInfo toInfo() {
    if (providerClass == null) {
        providerClass = ServiceLoader.load(PersistenceProvider.class).iterator().next().getClass().getName();
    }
    requireNonNull(dataSource, "datasource not provided");
    return new PersistenceUnitInfo() {
        @Override
        public String getPersistenceUnitName() {
            return unitName;
        }

        @Override
        public String getPersistenceProviderClassName() {
            return providerClass;
        }

        @Override
        public PersistenceUnitTransactionType getTransactionType() {
            return transactionType;
        }

        @Override
        public DataSource getJtaDataSource() {
            return jtaDataSource;
        }

        @Override
        public DataSource getNonJtaDataSource() {
            return dataSource;
        }

        @Override
        public List<String> getMappingFileNames() {
            return mappingFiles;
        }

        @Override
        public List<URL> getJarFileUrls() {
            return jarFiles;
        }

        @Override
        public URL getPersistenceUnitRootUrl() {
            return rootUrl;
        }

        @Override
        public List<String> getManagedClassNames() {
            return managedClasses;
        }

        @Override
        public boolean excludeUnlistedClasses() {
            return excludeUnlistedClasses;
        }

        @Override
        public SharedCacheMode getSharedCacheMode() {
            return sharedCacheMode;
        }

        @Override
        public ValidationMode getValidationMode() {
            return validationMode;
        }

        @Override
        public Properties getProperties() {
            return properties;
        }

        @Override
        public String getPersistenceXMLSchemaVersion() {
            return version;
        }

        @Override
        public ClassLoader getClassLoader() {
            return loader;
        }

        @Override
        public void addTransformer(final ClassTransformer transformer) {
            // no-op: not supported
        }

        @Override
        public ClassLoader getNewTempClassLoader() {
            return new URLClassLoader(new URL[0], Thread.currentThread().getContextClassLoader());
        }
    };
}
 
Example #19
Source File: CustomDescriptor.java    From rapidoid with Apache License 2.0 4 votes vote down vote up
@Override
public SharedCacheMode getSharedCacheMode() {
	return descriptor.getSharedCacheMode();
}
 
Example #20
Source File: PersistenceUnitInfoBuilder.java    From openwebbeans-meecrowave with Apache License 2.0 4 votes vote down vote up
public SharedCacheMode getSharedCacheMode() {
    return sharedCacheMode;
}
 
Example #21
Source File: MutablePersistenceUnitInfo.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public SharedCacheMode getSharedCacheMode() {
	return this.sharedCacheMode;
}
 
Example #22
Source File: MutablePersistenceUnitInfo.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
public void setSharedCacheMode(SharedCacheMode sharedCacheMode) {
	this.sharedCacheMode = sharedCacheMode;
}
 
Example #23
Source File: PersistenceUnitReader.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
/**
 * Parse the unit info DOM element.
 */
protected SpringPersistenceUnitInfo parsePersistenceUnitInfo(Element persistenceUnit, String version, URL rootUrl)
		throws IOException {

	SpringPersistenceUnitInfo unitInfo = new SpringPersistenceUnitInfo();

	// set JPA version (1.0 or 2.0)
	unitInfo.setPersistenceXMLSchemaVersion(version);

	// set persistence unit root URL
	unitInfo.setPersistenceUnitRootUrl(rootUrl);

	// set unit name
	unitInfo.setPersistenceUnitName(persistenceUnit.getAttribute(UNIT_NAME).trim());

	// set transaction type
	String txType = persistenceUnit.getAttribute(TRANSACTION_TYPE).trim();
	if (StringUtils.hasText(txType)) {
		unitInfo.setTransactionType(PersistenceUnitTransactionType.valueOf(txType));
	}

	// evaluate data sources
	String jtaDataSource = DomUtils.getChildElementValueByTagName(persistenceUnit, JTA_DATA_SOURCE);
	if (StringUtils.hasText(jtaDataSource)) {
		unitInfo.setJtaDataSource(this.dataSourceLookup.getDataSource(jtaDataSource.trim()));
	}

	String nonJtaDataSource = DomUtils.getChildElementValueByTagName(persistenceUnit, NON_JTA_DATA_SOURCE);
	if (StringUtils.hasText(nonJtaDataSource)) {
		unitInfo.setNonJtaDataSource(this.dataSourceLookup.getDataSource(nonJtaDataSource.trim()));
	}

	// provider
	String provider = DomUtils.getChildElementValueByTagName(persistenceUnit, PROVIDER);
	if (StringUtils.hasText(provider)) {
		unitInfo.setPersistenceProviderClassName(provider.trim());
	}

	// exclude unlisted classes
	Element excludeUnlistedClasses = DomUtils.getChildElementByTagName(persistenceUnit, EXCLUDE_UNLISTED_CLASSES);
	if (excludeUnlistedClasses != null) {
		String excludeText = DomUtils.getTextValue(excludeUnlistedClasses);
		unitInfo.setExcludeUnlistedClasses(!StringUtils.hasText(excludeText) || Boolean.valueOf(excludeText));
	}

	// set JPA 2.0 shared cache mode
	String cacheMode = DomUtils.getChildElementValueByTagName(persistenceUnit, SHARED_CACHE_MODE);
	if (StringUtils.hasText(cacheMode)) {
		unitInfo.setSharedCacheMode(SharedCacheMode.valueOf(cacheMode));
	}

	// set JPA 2.0 validation mode
	String validationMode = DomUtils.getChildElementValueByTagName(persistenceUnit, VALIDATION_MODE);
	if (StringUtils.hasText(validationMode)) {
		unitInfo.setValidationMode(ValidationMode.valueOf(validationMode));
	}

	parseProperties(persistenceUnit, unitInfo);
	parseManagedClasses(persistenceUnit, unitInfo);
	parseMappingFiles(persistenceUnit, unitInfo);
	parseJarFiles(persistenceUnit, unitInfo);

	return unitInfo;
}
 
Example #24
Source File: PersistenceUnitInfoImpl.java    From hibernate-types with Apache License 2.0 4 votes vote down vote up
@Override
public SharedCacheMode getSharedCacheMode() {
    return SharedCacheMode.UNSPECIFIED;
}
 
Example #25
Source File: PersistenceUnitInfoImpl.java    From hibernate-types with Apache License 2.0 4 votes vote down vote up
@Override
public SharedCacheMode getSharedCacheMode() {
    return SharedCacheMode.UNSPECIFIED;
}
 
Example #26
Source File: PersistenceUnitInfoImpl.java    From hibernate-types with Apache License 2.0 4 votes vote down vote up
@Override
public SharedCacheMode getSharedCacheMode() {
    return SharedCacheMode.UNSPECIFIED;
}
 
Example #27
Source File: PersistenceUnitInfoImpl.java    From hibernate-types with Apache License 2.0 4 votes vote down vote up
@Override
public SharedCacheMode getSharedCacheMode() {
    return SharedCacheMode.UNSPECIFIED;
}
 
Example #28
Source File: MetadataBuilderImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public SharedCacheMode getSharedCacheMode() {
	return sharedCacheMode;
}
 
Example #29
Source File: MetadataBuilderImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public MetadataBuilder applySharedCacheMode(SharedCacheMode sharedCacheMode) {
	this.options.sharedCacheMode = sharedCacheMode;
	return this;
}
 
Example #30
Source File: AbstractDelegatingMetadataBuildingOptions.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public SharedCacheMode getSharedCacheMode() {
	return delegate.getSharedCacheMode();
}