Java Code Examples for org.hibernate.cache.CacheException

The following examples show how to use org.hibernate.cache.CacheException. These examples are extracted from open source projects. 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
@Override
public boolean afterInsert(SharedSessionContractImplementor session, Object key, Object value, Object version) throws CacheException {
    region().writeLock( key );
    try {
        final AbstractReadWriteJ2CacheAccessStrategy.Lockable item = (AbstractReadWriteJ2CacheAccessStrategy.Lockable) region().get( key );
        if ( item == null ) {
            region().put( key, new AbstractReadWriteJ2CacheAccessStrategy.Item( value, version, region().nextTimestamp() ) );
            return true;
        }
        else {
            return false;
        }
    }
    finally {
        region().writeUnlock( key );
    }
}
 
Example 2
@Override
public void unlockItem(SharedSessionContractImplementor session, Object key, SoftLock lock) throws CacheException {
    try {
        this.actualStrategy.unlockItem(session, key, lock);
    } catch (NonStopCacheException nonStopCacheException) {
        hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException);
    }
}
 
Example 3
Source Project: mPass   Source File: RedissonCacheRegionFactory.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 准备阶段
 */
@Override
protected void prepareForUse(SessionFactoryOptions settings, Map properties) throws CacheException {
    this.context = ApplicationContextHolder.getApplicationContext();
    this.defaultConfig = context.getBean(Config.class);
    super.prepareForUse(settings, properties);
}
 
Example 4
@Override
public void unlockItem(SharedSessionContractImplementor session, Object key, SoftLock lock) throws CacheException {
    try {
        this.actualStrategy.unlockItem(session, key, lock);
    } catch (NonStopCacheException nonStopCacheException) {
        hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException);
    }
}
 
Example 5
@Override
public void unlockRegion(SoftLock lock) throws CacheException {
    try {
        this.actualStrategy.unlockRegion(lock);
    } catch (NonStopCacheException nonStopCacheException) {
        hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException);
    }
}
 
Example 6
@Override
public boolean insert(Object key, Object value) throws CacheException {
    try {
        return actualStrategy.insert(key, value);
    } catch (NonStopCacheException nonStopCacheException) {
        hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException);
        return false;
    }
}
 
Example 7
@Override
public boolean afterUpdate(Object key, Object value, SoftLock lock) throws CacheException {
    try {
        return actualStrategy.afterUpdate(key, value, lock);
    } catch (NonStopCacheException nonStopCacheException) {
        hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException);
        return false;
    }
}
 
Example 8
Source Project: J2Cache   Source File: J2HibernateCache.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Object get(Object key) throws CacheException {
    CacheObject cobj = cache.get(region, key.toString());
    if (log.isDebugEnabled())
        log.debug("get value for j2cache which key:" + key + ",value:" + cobj.getValue());
    return cobj.getValue();
}
 
Example 9
@Override
public void remove(SharedSessionContractImplementor session, Object key) throws CacheException {
    try {
        this.actualStrategy.remove(session, key);
    } catch (NonStopCacheException nonStopCacheException) {
        hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException);
    }
}
 
Example 10
@Override
public void remove(Object key) throws CacheException {
    try {
        actualStrategy.remove(key);
    } catch (NonStopCacheException nonStopCacheException) {
        hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException);
    }
}
 
Example 11
@Override
public void removeAll() throws CacheException {
    try {
        actualStrategy.removeAll();
    } catch (NonStopCacheException nonStopCacheException) {
        hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException);
    }
}
 
Example 12
@Override
public void unlockRegion(SoftLock lock) throws CacheException {
    try {
        actualStrategy.unlockRegion(lock);
    } catch (NonStopCacheException nonStopCacheException) {
        hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException);
    }
}
 
Example 13
@Override
public SoftLock lockItem(SharedSessionContractImplementor session, Object key, Object version) throws CacheException {
    try {
        return this.actualStrategy.lockItem(session, key, version);
    } catch (NonStopCacheException nonStopCacheException) {
        hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException);
        return null;
    }
}
 
Example 14
@Override
public SoftLock lockItem(Object key, Object version) throws CacheException {
    try {
        return actualStrategy.lockItem(key, version);
    } catch (NonStopCacheException nonStopCacheException) {
        hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException);
        return null;
    }
}
 
Example 15
@Override
public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version, boolean minimalPutOverride)
        throws CacheException {
    try {
        return actualStrategy.putFromLoad(key, value, txTimestamp, version, minimalPutOverride);
    } catch (NonStopCacheException nonStopCacheException) {
        hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException);
        return false;
    }
}
 
Example 16
@Override
public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version) throws CacheException {
    try {
        return actualStrategy.putFromLoad(key, value, txTimestamp, version);
    } catch (NonStopCacheException nonStopCacheException) {
        hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException);
        return false;
    }
}
 
Example 17
@Override
public void remove(Object key) throws CacheException {
    try {
        actualStrategy.remove(key);
    } catch (NonStopCacheException nonStopCacheException) {
        hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException);
    }
}
 
Example 18
@Override
public boolean putFromLoad(SharedSessionContractImplementor session, Object key, Object value, long txTimestamp, Object version, boolean minimalPutOverride) throws CacheException {
    try {
        return this.actualStrategy.putFromLoad(session, key, value, txTimestamp, version, minimalPutOverride);
    } catch (NonStopCacheException nonStopCacheException) {
        hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException);
        return false;
    }
}
 
Example 19
@Override
public void evictAll() throws CacheException {
    try {
        this.actualStrategy.evictAll();
    } catch (NonStopCacheException nonStopCacheException) {
        hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException);
    }
}
 
Example 20
@Override
public void unlockRegion(SoftLock lock) throws CacheException {
    try {
        actualStrategy.unlockRegion(lock);
    } catch (NonStopCacheException nonStopCacheException) {
        hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException);
    }
}
 
Example 21
@Override
public boolean afterUpdate(Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock) throws CacheException {
    try {
        return actualStrategy.afterUpdate(key, value, currentVersion, previousVersion, lock);
    } catch (NonStopCacheException nonStopCacheException) {
        hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException);
        return false;
    }
}
 
Example 22
@Override
public void evict(Object key) throws CacheException {
    try {
        actualStrategy.evict(key);
    } catch (NonStopCacheException nonStopCacheException) {
        hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException);
    }
}
 
Example 23
@Override
public void evictAll() throws CacheException {
    try {
        actualStrategy.evictAll();
    } catch (NonStopCacheException nonStopCacheException) {
        hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException);
    }
}
 
Example 24
@Override
public boolean afterInsert(SharedSessionContractImplementor session, Object key, Object value) throws CacheException {
    try {
        return this.actualStrategy.afterInsert(session, key, value);
    } catch (NonStopCacheException nonStopCacheException) {
        hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException);
        return false;
    }
}
 
Example 25
@Override
public boolean insert(Object key, Object value, Object version) throws CacheException {
    try {
        return actualStrategy.insert(key, value, version);
    } catch (NonStopCacheException nonStopCacheException) {
        hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException);
        return false;
    }
}
 
Example 26
@Override
public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version) throws CacheException {
    try {
        return actualStrategy.putFromLoad(key, value, txTimestamp, version);
    } catch (NonStopCacheException nonStopCacheException) {
        hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException);
        return false;
    }
}
 
Example 27
@Override
public void remove(Object key) throws CacheException {
    try {
        actualStrategy.remove(key);
    } catch (NonStopCacheException nonStopCacheException) {
        hibernateNonstopExceptionHandler.handleNonstopCacheException(nonStopCacheException);
    }
}
 
Example 28
@Override
public boolean putFromLoad(SharedSessionContractImplementor session, Object key, Object value, long txTimestamp, Object version, boolean minimalPutOverride) throws CacheException {
    if (minimalPutOverride && cache.get(key) != null) {
        return false;
    }
    cache.put(key, value);
    return true;
}
 
Example 29
Source Project: J2Cache   Source File: J2CacheDataRegion.java    License: Apache License 2.0 5 votes vote down vote up
public void destroy() throws CacheException {
    try {
        getCache().clear();
    } catch (IllegalStateException e) {
        LOG.debug("This can happen if multiple frameworks both try to shutdown ehcache", e);
    }
}
 
Example 30
Source Project: J2Cache   Source File: AbstractJ2CacheRegionFactory.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public NaturalIdRegion buildNaturalIdRegion(String regionName, Properties properties, CacheDataDescription metadata)
        throws CacheException {
    return new J2CacheNaturalIdRegion(
            accessStrategyFactory,
            getCache( regionName ),
            settings,
            metadata,
            properties
    );
}