Java Code Examples for org.hibernate.cfg.Settings#getCacheRegionPrefix()

The following examples show how to use org.hibernate.cfg.Settings#getCacheRegionPrefix() . 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: StandardQueryCache.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public StandardQueryCache(
		final Settings settings, 
		final Properties props, 
		final UpdateTimestampsCache updateTimestampsCache, 
		String regionName) throws HibernateException {
	if ( regionName == null ) {
		regionName = StandardQueryCache.class.getName();
	}
	String prefix = settings.getCacheRegionPrefix();
	if ( prefix != null ) {
		regionName = prefix + '.' + regionName;
	}
	log.info( "starting query cache at region: " + regionName );

	this.queryCache = settings.getCacheProvider().buildCache(regionName, props);
	this.updateTimestampsCache = updateTimestampsCache;
	this.regionName = regionName;
}
 
Example 2
Source File: CacheFactory.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static CacheConcurrencyStrategy createCache(
	final String concurrencyStrategy, 
	String regionName, 
	final boolean mutable, 
	final Settings settings,
	final Properties properties) 
throws HibernateException {
	
	if ( concurrencyStrategy==null || !settings.isSecondLevelCacheEnabled() ) return null; //no cache
	
	String prefix = settings.getCacheRegionPrefix();
	if ( prefix!=null ) regionName = prefix + '.' + regionName;
	
	if ( log.isDebugEnabled() ) log.debug("instantiating cache region: " + regionName + " usage strategy: " + concurrencyStrategy);
	
	final CacheConcurrencyStrategy ccs;
	if ( concurrencyStrategy.equals(READ_ONLY) ) {
		if (mutable) log.warn( "read-only cache configured for mutable class: " + regionName );
		ccs = new ReadOnlyCache();
	}
	else if ( concurrencyStrategy.equals(READ_WRITE) ) {
		ccs = new ReadWriteCache();
	}
	else if ( concurrencyStrategy.equals(NONSTRICT_READ_WRITE) ) {
		ccs = new NonstrictReadWriteCache();
	}
	else if ( concurrencyStrategy.equals(TRANSACTIONAL) ) {
		ccs = new TransactionalCache();
	}
	else {
		throw new MappingException("cache usage attribute should be read-write, read-only, nonstrict-read-write or transactional");
	}
	
	final Cache impl;
	try {
		impl = settings.getCacheProvider().buildCache(regionName, properties);
	}
	catch (CacheException e) {
		throw new HibernateException( "Could not instantiate cache implementation", e );
	}
	ccs.setCache(impl);
	
	return ccs;
}
 
Example 3
Source File: UpdateTimestampsCache.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public UpdateTimestampsCache(Settings settings, Properties props) throws HibernateException {
	String prefix = settings.getCacheRegionPrefix();
	regionName = prefix == null ? REGION_NAME : prefix + '.' + REGION_NAME;
	log.info( "starting update timestamps cache at region: " + regionName );
	this.updateTimestamps = settings.getCacheProvider().buildCache( regionName, props );
}